Skip to content

Commit c0d4f5f

Browse files
committed
Move the libgccjit.so file in a target directory
Since GCC is not multi-target, we need multiple libgccjit.so. Our solution to have a directory per target so that we can have multiple libgccjit.so.
1 parent 8d9b1d0 commit c0d4f5f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,18 +181,18 @@ pub struct GccCodegenBackend {
181181

182182
static LTO_SUPPORTED: AtomicBool = AtomicBool::new(false);
183183

184-
fn libgccjit_path(sysroot_path: &Path) -> PathBuf {
184+
fn libgccjit_path(sysroot_path: &Path, target_triple: &str) -> PathBuf {
185185
let sysroot_lib_dir = sysroot_path.join("lib");
186-
sysroot_lib_dir.join("libgccjit.so")
186+
sysroot_lib_dir.join(target_triple).join("libgccjit.so")
187187
}
188188

189-
fn load_libgccjit_if_needed(sysroot_path: &Path) {
189+
fn load_libgccjit_if_needed(sysroot_path: &Path, target_triple: &str) {
190190
if gccjit::is_loaded() {
191191
// Do not load a libgccjit second time.
192192
return;
193193
}
194194

195-
let libgccjit_target_lib_file = libgccjit_path(sysroot_path);
195+
let libgccjit_target_lib_file = libgccjit_path(sysroot_path, target_triple);
196196
let path = libgccjit_target_lib_file.to_str().expect("libgccjit path");
197197

198198
let string = CString::new(path).expect("string to libgccjit path");
@@ -216,9 +216,9 @@ impl CodegenBackend for GccCodegenBackend {
216216
// invalid.
217217
// This is the case for instance in Rust for Linux where they specify --sysroot=/dev/null.
218218
for path in sess.opts.sysroot.all_paths() {
219-
let libgccjit_target_lib_file = libgccjit_path(path);
219+
let libgccjit_target_lib_file = libgccjit_path(path, &sess.target.llvm_target);
220220
if let Ok(true) = fs::exists(libgccjit_target_lib_file) {
221-
load_libgccjit_if_needed(path);
221+
load_libgccjit_if_needed(path, &sess.target.llvm_target);
222222
break;
223223
}
224224
}

0 commit comments

Comments
 (0)