File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 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,
669669 // if the linker doesn't support -no-pie then it should not default to
670670 // linking executables as pie. Different versions of gcc seem to use
671671 // 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" ) ||
673674 out. contains ( "unknown argument" ) ) &&
674675 out. contains ( "-no-pie" ) &&
675676 cmd. get_args ( ) . iter ( ) . any ( |e| e. to_string_lossy ( ) == "-no-pie" ) {
@@ -936,7 +937,12 @@ fn link_args(cmd: &mut Linker,
936937 if position_independent_executable {
937938 cmd. position_independent_executable ( ) ;
938939 } 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+ }
940946 }
941947 }
942948
You can’t perform that action at this time.
0 commit comments