@@ -177,6 +177,8 @@ pub struct GccCodegenBackend {
177177 lto_supported : Arc < AtomicBool > ,
178178}
179179
180+ static LTO_SUPPORTED : AtomicBool = AtomicBool :: new ( false ) ;
181+
180182impl CodegenBackend for GccCodegenBackend {
181183 fn locale_resource ( & self ) -> & ' static str {
182184 crate :: DEFAULT_LOCALE_RESOURCE
@@ -200,7 +202,7 @@ impl CodegenBackend for GccCodegenBackend {
200202 * * self . target_info . info . lock ( ) . expect ( "lock" ) = context. get_target_info ( ) ;
201203 }
202204
203- // TODO : try the LTO frontend and check if it errors out. If so, do not embed the bitcode.
205+ // NOTE : try the LTO frontend and check if it errors out. If so, do not embed the bitcode.
204206 {
205207 let temp_dir = TempDir :: new ( ) . expect ( "cannot create temporary directory" ) ;
206208 let temp_file = temp_dir. into_path ( ) . join ( "result.asm" ) ;
@@ -220,6 +222,7 @@ impl CodegenBackend for GccCodegenBackend {
220222 check_context. compile ( ) ;
221223 let error = check_context. get_last_error ( ) ;
222224 let lto_supported = error == Ok ( None ) ;
225+ LTO_SUPPORTED . store ( lto_supported, Ordering :: SeqCst ) ;
223226 self . lto_supported . store ( lto_supported, Ordering :: SeqCst ) ;
224227 }
225228
@@ -308,11 +311,12 @@ impl ExtraBackendMethods for GccCodegenBackend {
308311 kind : AllocatorKind ,
309312 alloc_error_handler_kind : AllocatorKind ,
310313 ) -> Self :: Module {
314+ let lto_supported = self . lto_supported . load ( Ordering :: SeqCst ) ;
311315 let mut mods = GccContext {
312316 context : Arc :: new ( SyncContext :: new ( new_context ( tcx) ) ) ,
313317 relocation_model : tcx. sess . relocation_model ( ) ,
314318 lto_mode : LtoMode :: None ,
315- lto_supported : false ,
319+ lto_supported,
316320 temp_dir : None ,
317321 } ;
318322
0 commit comments