Skip to content

Commit 8d590eb

Browse files
committed
Fix to not require more files than libgccjit.so
1 parent d14effa commit 8d590eb

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

.github/workflows/ci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ jobs:
7979

8080
- name: Build
8181
run: |
82-
ls /home/runner/work/rustc_codegen_gcc/rustc_codegen_gcc/llvm
83-
echo Workspace ${{ env.workspace }}
84-
ls ${{ env.workspace }}/llvm
8582
./prepare_build.sh
8683
./build.sh
8784
cargo test

src/lib.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ extern crate rustc_span;
2424
extern crate rustc_symbol_mangling;
2525
extern crate rustc_target;
2626
extern crate snap;
27+
extern crate tempfile;
2728

2829
// This prevents duplicating functions and statics that are already part of the host rustc process.
2930
#[allow(unused_extern_crates)]
@@ -69,6 +70,7 @@ use rustc_session::config::{Lto, OptLevel, OutputFilenames};
6970
use rustc_session::Session;
7071
use rustc_span::Symbol;
7172
use rustc_span::fatal_error::FatalError;
73+
use tempfile::TempDir;
7274

7375
pub struct PrintOnPanic<F: Fn() -> String>(pub F);
7476

@@ -91,11 +93,13 @@ impl CodegenBackend for GccCodegenBackend {
9193
sess.warn("LTO is not supported. You may get a linker error.");
9294
}
9395

96+
let temp_dir = TempDir::new().expect("cannot create temporary directory");
97+
let temp_file = temp_dir.into_path().join("result.asm");
9498
let check_context = Context::default();
9599
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"));
97102
*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"));
99103
}
100104

101105
fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need_metadata_module: bool) -> Box<dyn Any> {

0 commit comments

Comments
 (0)