@@ -202,39 +202,14 @@ impl CodegenBackend for GccCodegenBackend {
202202 * * self . target_info . info . lock ( ) . expect ( "lock" ) = context. get_target_info ( ) ;
203203 }
204204
205- // While not required by the API, we gate this code on the master feature to make sure we
206- // don't abort the process while checking if LTO is supported.
207- // The following could will emit a fatal error if LTO is not supported and older versions
208- // of libgccjit (the ones without this commit:
209- // https://github.com/rust-lang/gcc/commit/a073b06800f064b3917a6113d4cc2a0c19a10fda) will
210- // abort on fatal errors.
211205 #[ cfg( feature = "master" ) ]
212206 {
213- // NOTE: try the LTO frontend and check if it errors out. If so, do not embed the bitcode.
214- let temp_dir = TempDir :: new ( ) . expect ( "cannot create temporary directory" ) ;
215- let temp_file = temp_dir. keep ( ) . join ( "result.asm" ) ;
216- let context = Context :: default ( ) ;
217- let object_file_path = temp_file. to_str ( ) . expect ( "path to str" ) ;
218- context. compile_to_file ( gccjit:: OutputKind :: ObjectFile , object_file_path) ;
219-
220- //let temp_dir = TempDir::new().expect("cannot create temporary directory");
221- //let temp_file = temp_dir.into_path().join("result.asm");
222- let check_context = Context :: default ( ) ;
223- check_context. add_driver_option ( "-x" ) ;
224- check_context. add_driver_option ( "lto" ) ;
225- check_context. add_driver_option ( object_file_path) ;
226- check_context. set_print_errors_to_stderr ( false ) ;
227- //context.compile_to_file(gccjit::OutputKind::ObjectFile, temp_file.to_str().expect("path to str"));
228- // FIXME: compile gives the error as expected, but compile_to_file doesn't.
229- check_context. compile ( ) ;
230- let error = check_context. get_last_error ( ) ;
231- let lto_supported = error == Ok ( None ) ;
207+ let lto_supported = gccjit:: is_lto_supported ( ) ;
232208 LTO_SUPPORTED . store ( lto_supported, Ordering :: SeqCst ) ;
233209 self . lto_supported . store ( lto_supported, Ordering :: SeqCst ) ;
234- }
235210
236- # [ cfg ( feature = "master" ) ]
237- gccjit :: set_global_personality_function_name ( b"rust_eh_personality \0 " ) ;
211+ gccjit :: set_global_personality_function_name ( b"rust_eh_personality \0 " ) ;
212+ }
238213
239214 #[ cfg( not( feature = "master" ) ) ]
240215 {
0 commit comments