@@ -22,6 +22,7 @@ extern crate rustc_middle;
22
22
extern crate rustc_session;
23
23
extern crate rustc_span;
24
24
extern crate rustc_target;
25
+ extern crate tempfile;
25
26
26
27
// This prevents duplicating functions and statics that are already part of the host rustc process.
27
28
#[ allow( unused_extern_crates) ]
@@ -67,6 +68,7 @@ use rustc_session::config::{Lto, OptLevel, OutputFilenames};
67
68
use rustc_session:: Session ;
68
69
use rustc_span:: Symbol ;
69
70
use rustc_span:: fatal_error:: FatalError ;
71
+ use tempfile:: TempDir ;
70
72
71
73
pub struct PrintOnPanic < F : Fn ( ) -> String > ( pub F ) ;
72
74
@@ -89,11 +91,13 @@ impl CodegenBackend for GccCodegenBackend {
89
91
sess. warn ( "LTO is not supported. You may get a linker error." ) ;
90
92
}
91
93
94
+ let temp_dir = TempDir :: new ( ) . expect ( "cannot create temporary directory" ) ;
95
+ let temp_file = temp_dir. into_path ( ) . join ( "result.asm" ) ;
92
96
let check_context = Context :: default ( ) ;
93
97
let _int128_ty = check_context. new_c_type ( CType :: UInt128t ) ;
94
- check_context. compile ( ) ;
98
+ // NOTE: we cannot just call compile() as this would require other files than libgccjit.so.
99
+ check_context. compile_to_file ( gccjit:: OutputKind :: Assembler , temp_file. to_str ( ) . expect ( "path to str" ) ) ;
95
100
* self . supports_128bit_integers . lock ( ) . expect ( "lock" ) = check_context. get_last_error ( ) == Ok ( None ) ;
96
- println ! ( "128-bit integers are supported: {}" , self . supports_128bit_integers. lock( ) . expect( "lock" ) ) ;
97
101
}
98
102
99
103
fn codegen_crate < ' tcx > ( & self , tcx : TyCtxt < ' tcx > , metadata : EncodedMetadata , need_metadata_module : bool ) -> Box < dyn Any > {
0 commit comments