File tree 1 file changed +8
-2
lines changed
1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -669,7 +669,8 @@ fn link_natively(sess: &Session,
669
669
// if the linker doesn't support -no-pie then it should not default to
670
670
// linking executables as pie. Different versions of gcc seem to use
671
671
// different quotes in the error message so don't check for them.
672
- if ( out. contains ( "unrecognized command line option" ) ||
672
+ if sess. target . target . options . linker_is_gnu &&
673
+ ( out. contains ( "unrecognized command line option" ) ||
673
674
out. contains ( "unknown argument" ) ) &&
674
675
out. contains ( "-no-pie" ) &&
675
676
cmd. get_args ( ) . iter ( ) . any ( |e| e. to_string_lossy ( ) == "-no-pie" ) {
@@ -936,7 +937,12 @@ fn link_args(cmd: &mut Linker,
936
937
if position_independent_executable {
937
938
cmd. position_independent_executable ( ) ;
938
939
} else {
939
- cmd. no_position_independent_executable ( ) ;
940
+ // recent versions of gcc can be configured to generate position
941
+ // independent executables by default. We have to pass -no-pie to
942
+ // explicitly turn that off.
943
+ if sess. target . target . options . linker_is_gnu {
944
+ cmd. no_position_independent_executable ( ) ;
945
+ }
940
946
}
941
947
}
942
948
You can’t perform that action at this time.
0 commit comments