@@ -7,7 +7,7 @@ use crate::back::profiling::{
77use crate :: base;
88use crate :: common;
99use crate :: consts;
10- use crate :: context:: is_pie_binary ;
10+ use crate :: context:: all_outputs_are_pic_executables ;
1111use crate :: llvm:: { self , DiagnosticInfo , PassManager , SMDiagnostic } ;
1212use crate :: llvm_util;
1313use crate :: type_:: Type ;
@@ -75,19 +75,13 @@ pub fn write_output_file(
7575 }
7676}
7777
78- pub fn create_informational_target_machine (
79- sess : & Session ,
80- find_features : bool ,
81- ) -> & ' static mut llvm:: TargetMachine {
82- target_machine_factory ( sess, config:: OptLevel :: No , find_features) ( )
78+ pub fn create_informational_target_machine ( sess : & Session ) -> & ' static mut llvm:: TargetMachine {
79+ target_machine_factory ( sess, config:: OptLevel :: No ) ( )
8380 . unwrap_or_else ( |err| llvm_err ( sess. diagnostic ( ) , & err) . raise ( ) )
8481}
8582
86- pub fn create_target_machine (
87- tcx : TyCtxt < ' _ > ,
88- find_features : bool ,
89- ) -> & ' static mut llvm:: TargetMachine {
90- target_machine_factory ( & tcx. sess , tcx. backend_optimization_level ( LOCAL_CRATE ) , find_features) ( )
83+ pub fn create_target_machine ( tcx : TyCtxt < ' _ > ) -> & ' static mut llvm:: TargetMachine {
84+ target_machine_factory ( & tcx. sess , tcx. backend_optimization_level ( LOCAL_CRATE ) ) ( )
9185 . unwrap_or_else ( |err| llvm_err ( tcx. sess . diagnostic ( ) , & err) . raise ( ) )
9286}
9387
@@ -128,13 +122,9 @@ fn to_llvm_relocation_model(relocation_model: RelocModel) -> llvm::RelocModel {
128122 }
129123}
130124
131- // If find_features is true this won't access `sess.crate_types` by assuming
132- // that `is_pie_binary` is false. When we discover LLVM target features
133- // `sess.crate_types` is uninitialized so we cannot access it.
134125pub fn target_machine_factory (
135126 sess : & Session ,
136127 optlvl : config:: OptLevel ,
137- find_features : bool ,
138128) -> Arc < dyn Fn ( ) -> Result < & ' static mut llvm:: TargetMachine , String > + Send + Sync > {
139129 let reloc_model = to_llvm_relocation_model ( sess. relocation_model ( ) ) ;
140130
@@ -177,7 +167,7 @@ pub fn target_machine_factory(
177167 let features = features. join ( "," ) ;
178168 let features = CString :: new ( features) . unwrap ( ) ;
179169 let abi = SmallCStr :: new ( & sess. target . target . options . llvm_abiname ) ;
180- let is_pie_binary = !find_features && is_pie_binary ( sess) ;
170+ let pic_is_pie = all_outputs_are_pic_executables ( sess) ;
181171 let trap_unreachable = sess. target . target . options . trap_unreachable ;
182172 let emit_stack_size_section = sess. opts . debugging_opts . emit_stack_sizes ;
183173
@@ -194,7 +184,7 @@ pub fn target_machine_factory(
194184 reloc_model,
195185 opt_level,
196186 use_softfp,
197- is_pie_binary ,
187+ pic_is_pie ,
198188 ffunction_sections,
199189 fdata_sections,
200190 trap_unreachable,
0 commit comments