@@ -276,18 +276,27 @@ impl<'a> Linker for GccLinker<'a> {
276
276
fn set_output_kind ( & mut self , output_kind : LinkOutputKind , out_filename : & Path ) {
277
277
match output_kind {
278
278
LinkOutputKind :: DynamicNoPicExe => {
279
- if !self . is_ld && self . sess . target . linker_is_gnu {
279
+ if !self . is_ld
280
+ && self . sess . target . linker_is_gnu
281
+ && !self . sess . target . is_like_windows
282
+ {
280
283
self . cmd . arg ( "-no-pie" ) ;
281
284
}
282
285
}
283
286
LinkOutputKind :: DynamicPicExe => {
284
- // `-pie` works for both gcc wrapper and ld.
285
- self . cmd . arg ( "-pie" ) ;
287
+ // noop on windows w/ gcc & ld, error w/ lld
288
+ if !self . sess . target . is_like_windows {
289
+ // `-pie` works for both gcc wrapper and ld
290
+ self . cmd . arg ( "-pie" ) ;
291
+ }
286
292
}
287
293
LinkOutputKind :: StaticNoPicExe => {
288
294
// `-static` works for both gcc wrapper and ld.
289
295
self . cmd . arg ( "-static" ) ;
290
- if !self . is_ld && self . sess . target . linker_is_gnu {
296
+ if !self . is_ld
297
+ && self . sess . target . linker_is_gnu
298
+ && !self . sess . target . is_like_windows
299
+ {
291
300
self . cmd . arg ( "-no-pie" ) ;
292
301
}
293
302
}
@@ -347,7 +356,7 @@ impl<'a> Linker for GccLinker<'a> {
347
356
// has -needed-l{} / -needed_library {}
348
357
// but we have no way to detect that here.
349
358
self . sess . warn ( "`as-needed` modifier not implemented yet for ld64" ) ;
350
- } else if self . sess . target . linker_is_gnu {
359
+ } else if self . sess . target . linker_is_gnu && ! self . sess . target . is_like_windows {
351
360
self . linker_arg ( "--no-as-needed" ) ;
352
361
} else {
353
362
self . sess . warn ( "`as-needed` modifier not supported for current linker" ) ;
@@ -358,7 +367,7 @@ impl<'a> Linker for GccLinker<'a> {
358
367
if !as_needed {
359
368
if self . sess . target . is_like_osx {
360
369
// See above FIXME comment
361
- } else if self . sess . target . linker_is_gnu {
370
+ } else if self . sess . target . linker_is_gnu && ! self . sess . target . is_like_windows {
362
371
self . linker_arg ( "--as-needed" ) ;
363
372
}
364
373
}
@@ -690,7 +699,7 @@ impl<'a> Linker for GccLinker<'a> {
690
699
}
691
700
692
701
fn add_as_needed ( & mut self ) {
693
- if self . sess . target . linker_is_gnu {
702
+ if self . sess . target . linker_is_gnu && ! self . sess . target . is_like_windows {
694
703
self . linker_arg ( "--as-needed" ) ;
695
704
} else if self . sess . target . is_like_solaris {
696
705
// -z ignore is the Solaris equivalent to the GNU ld --as-needed option
0 commit comments