@@ -43,6 +43,7 @@ use rustc_fs_util::try_canonicalize;
43
43
use rustc_serialize:: { Decodable , Decoder , Encodable , Encoder } ;
44
44
use rustc_span:: symbol:: { kw, sym, Symbol } ;
45
45
use serde_json:: Value ;
46
+ use std:: assert_matches:: assert_matches;
46
47
use std:: borrow:: Cow ;
47
48
use std:: collections:: BTreeMap ;
48
49
use std:: hash:: { Hash , Hasher } ;
@@ -437,6 +438,17 @@ impl LinkerFlavor {
437
438
| LinkerFlavor :: Ptx => false ,
438
439
}
439
440
}
441
+
442
+ pub fn uses_clang ( self ) -> bool {
443
+ match self {
444
+ LinkerFlavor :: Gnu ( Cc :: Clang , _)
445
+ | LinkerFlavor :: Darwin ( Cc :: Clang , _)
446
+ | LinkerFlavor :: WasmLld ( Cc :: Clang )
447
+ | LinkerFlavor :: Unix ( Cc :: Clang )
448
+ | LinkerFlavor :: EmCc => true ,
449
+ _ => false ,
450
+ }
451
+ }
440
452
}
441
453
442
454
macro_rules! linker_flavor_cli_impls {
@@ -2185,21 +2197,34 @@ fn add_link_args_iter(
2185
2197
match flavor {
2186
2198
LinkerFlavor :: Gnu ( cc, lld) => {
2187
2199
assert_eq ! ( lld, Lld :: No ) ;
2200
+ assert_matches ! ( cc, Cc :: No | Cc :: Yes ) ;
2188
2201
insert ( LinkerFlavor :: Gnu ( cc, Lld :: Yes ) ) ;
2202
+ if cc == Cc :: Yes {
2203
+ insert ( LinkerFlavor :: Gnu ( Cc :: Clang , Lld :: No ) ) ;
2204
+ insert ( LinkerFlavor :: Gnu ( Cc :: Clang , Lld :: Yes ) ) ;
2205
+ }
2189
2206
}
2190
2207
LinkerFlavor :: Darwin ( cc, lld) => {
2191
2208
assert_eq ! ( lld, Lld :: No ) ;
2209
+ assert_matches ! ( cc, Cc :: No | Cc :: Yes ) ;
2192
2210
insert ( LinkerFlavor :: Darwin ( cc, Lld :: Yes ) ) ;
2211
+ if cc == Cc :: Yes {
2212
+ insert ( LinkerFlavor :: Darwin ( Cc :: Clang , Lld :: No ) ) ;
2213
+ insert ( LinkerFlavor :: Darwin ( Cc :: Clang , Lld :: Yes ) ) ;
2214
+ }
2193
2215
}
2194
2216
LinkerFlavor :: Msvc ( lld) => {
2195
2217
assert_eq ! ( lld, Lld :: No ) ;
2196
2218
insert ( LinkerFlavor :: Msvc ( Lld :: Yes ) ) ;
2197
2219
}
2198
- LinkerFlavor :: WasmLld ( ..)
2199
- | LinkerFlavor :: Unix ( ..)
2200
- | LinkerFlavor :: EmCc
2201
- | LinkerFlavor :: Bpf
2202
- | LinkerFlavor :: Ptx => { }
2220
+ LinkerFlavor :: WasmLld ( cc) | LinkerFlavor :: Unix ( cc) => {
2221
+ assert_matches ! ( cc, Cc :: No | Cc :: Yes ) ;
2222
+ if cc == Cc :: Yes {
2223
+ insert ( LinkerFlavor :: Gnu ( Cc :: Clang , Lld :: No ) ) ;
2224
+ insert ( LinkerFlavor :: Gnu ( Cc :: Clang , Lld :: Yes ) ) ;
2225
+ }
2226
+ }
2227
+ LinkerFlavor :: EmCc | LinkerFlavor :: Bpf | LinkerFlavor :: Ptx => { }
2203
2228
}
2204
2229
}
2205
2230
0 commit comments