@@ -1618,8 +1618,20 @@ fn select_debuginfo(
1618
1618
}
1619
1619
}
1620
1620
1621
- fn parse_native_lib_kind ( kind : & str , error_format : ErrorOutputType ) -> NativeLibKind {
1622
- match kind {
1621
+ fn parse_native_lib_kind (
1622
+ matches : & getopts:: Matches ,
1623
+ kind : & str ,
1624
+ error_format : ErrorOutputType ,
1625
+ ) -> ( NativeLibKind , Option < bool > ) {
1626
+ let is_nightly = nightly_options:: match_is_nightly_build ( matches) ;
1627
+ let enable_unstable = nightly_options:: is_unstable_enabled ( matches) ;
1628
+
1629
+ let ( kind, modifiers) = match kind. split_once ( ':' ) {
1630
+ None => ( kind, None ) ,
1631
+ Some ( ( kind, modifiers) ) => ( kind, Some ( modifiers) ) ,
1632
+ } ;
1633
+
1634
+ let kind = match kind {
1623
1635
"dylib" => NativeLibKind :: Dylib { as_needed : None } ,
1624
1636
"framework" => NativeLibKind :: Framework { as_needed : None } ,
1625
1637
"static" => NativeLibKind :: Static { bundle : None , whole_archive : None } ,
@@ -1629,17 +1641,49 @@ fn parse_native_lib_kind(kind: &str, error_format: ErrorOutputType) -> NativeLib
1629
1641
"library kind `static-nobundle` has been superseded by specifying \
1630
1642
`-bundle` on library kind `static`. Try `static:-bundle`",
1631
1643
) ;
1644
+ if modifiers. is_some ( ) {
1645
+ early_error (
1646
+ error_format,
1647
+ "linking modifier can't be used with library kind `static-nobundle`" ,
1648
+ )
1649
+ }
1650
+ if !is_nightly {
1651
+ early_error (
1652
+ error_format,
1653
+ "library kind `static-nobundle` are currently unstable and only accepted on \
1654
+ the nightly compiler",
1655
+ ) ;
1656
+ }
1632
1657
NativeLibKind :: Static { bundle : Some ( false ) , whole_archive : None }
1633
1658
}
1634
1659
s => early_error (
1635
1660
error_format,
1636
1661
& format ! ( "unknown library kind `{}`, expected one of dylib, framework, or static" , s) ,
1637
1662
) ,
1663
+ } ;
1664
+ match modifiers {
1665
+ None => ( kind, None ) ,
1666
+ Some ( modifiers) => {
1667
+ if !is_nightly {
1668
+ early_error (
1669
+ error_format,
1670
+ "linking modifiers are currently unstable and only accepted on \
1671
+ the nightly compiler",
1672
+ ) ;
1673
+ }
1674
+ if !enable_unstable {
1675
+ early_error (
1676
+ error_format,
1677
+ "linking modifiers are currently unstable, \
1678
+ the `-Z unstable-options` flag must also be passed to use it",
1679
+ )
1680
+ }
1681
+ parse_native_lib_modifiers ( kind, modifiers, error_format)
1682
+ }
1638
1683
}
1639
1684
}
1640
1685
1641
1686
fn parse_native_lib_modifiers (
1642
- is_nightly : bool ,
1643
1687
mut kind : NativeLibKind ,
1644
1688
modifiers : & str ,
1645
1689
error_format : ErrorOutputType ,
@@ -1655,14 +1699,6 @@ fn parse_native_lib_modifiers(
1655
1699
) ,
1656
1700
} ;
1657
1701
1658
- if !is_nightly {
1659
- early_error (
1660
- error_format,
1661
- "linking modifiers are currently unstable and only accepted on \
1662
- the nightly compiler",
1663
- ) ;
1664
- }
1665
-
1666
1702
match ( modifier, & mut kind) {
1667
1703
( "bundle" , NativeLibKind :: Static { bundle, .. } ) => {
1668
1704
* bundle = Some ( value) ;
@@ -1709,7 +1745,6 @@ fn parse_native_lib_modifiers(
1709
1745
}
1710
1746
1711
1747
fn parse_libs ( matches : & getopts:: Matches , error_format : ErrorOutputType ) -> Vec < NativeLib > {
1712
- let is_nightly = nightly_options:: match_is_nightly_build ( matches) ;
1713
1748
matches
1714
1749
. opt_strs ( "l" )
1715
1750
. into_iter ( )
@@ -1723,13 +1758,7 @@ fn parse_libs(matches: &getopts::Matches, error_format: ErrorOutputType) -> Vec<
1723
1758
let ( name, kind, verbatim) = match s. split_once ( '=' ) {
1724
1759
None => ( s, NativeLibKind :: Unspecified , None ) ,
1725
1760
Some ( ( kind, name) ) => {
1726
- let ( kind, verbatim) = match kind. split_once ( ':' ) {
1727
- None => ( parse_native_lib_kind ( kind, error_format) , None ) ,
1728
- Some ( ( kind, modifiers) ) => {
1729
- let kind = parse_native_lib_kind ( kind, error_format) ;
1730
- parse_native_lib_modifiers ( is_nightly, kind, modifiers, error_format)
1731
- }
1732
- } ;
1761
+ let ( kind, verbatim) = parse_native_lib_kind ( matches, kind, error_format) ;
1733
1762
( name. to_string ( ) , kind, verbatim)
1734
1763
}
1735
1764
} ;
0 commit comments