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