Skip to content

Commit 36ef284

Browse files
committed
Fix to not require more files than libgccjit.so
1 parent 08a8f23 commit 36ef284

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
@@ -22,6 +22,7 @@ extern crate rustc_middle;
2222
extern crate rustc_session;
2323
extern crate rustc_span;
2424
extern crate rustc_target;
25+
extern crate tempfile;
2526

2627
// This prevents duplicating functions and statics that are already part of the host rustc process.
2728
#[allow(unused_extern_crates)]
@@ -67,6 +68,7 @@ use rustc_session::config::{Lto, OptLevel, OutputFilenames};
6768
use rustc_session::Session;
6869
use rustc_span::Symbol;
6970
use rustc_span::fatal_error::FatalError;
71+
use tempfile::TempDir;
7072

7173
pub struct PrintOnPanic<F: Fn() -> String>(pub F);
7274

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

94+
let temp_dir = TempDir::new().expect("cannot create temporary directory");
95+
let temp_file = temp_dir.into_path().join("result.asm");
9296
let check_context = Context::default();
9397
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"));
95100
*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"));
97101
}
98102

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

0 commit comments

Comments
 (0)