Skip to content

Commit c84f43c

Browse files
committed
When we cannot load libgccjit.so, show the paths that were tried
1 parent 5ae7550 commit c84f43c

File tree

1 file changed

+15
-2
lines changed
  • compiler/rustc_codegen_gcc/src

1 file changed

+15
-2
lines changed

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,18 +207,31 @@ impl CodegenBackend for GccCodegenBackend {
207207
}
208208

209209
fn init(&self, sess: &Session) {
210+
fn file_path(path: &Path, sess: &Session) -> PathBuf {
211+
make_target_lib_path(path, &sess.target.llvm_target).join("libgccjit.so")
212+
}
213+
210214
// We use all_paths() instead of only path() in case the path specified by --sysroot is
211215
// invalid.
212216
// This is the case for instance in Rust for Linux where they specify --sysroot=/dev/null.
213217
for path in sess.opts.sysroot.all_paths() {
214-
let libgccjit_target_lib_file =
215-
make_target_lib_path(path, &sess.target.llvm_target).join("libgccjit.so");
218+
let libgccjit_target_lib_file = file_path(path, &sess);
216219
if let Ok(true) = fs::exists(&libgccjit_target_lib_file) {
217220
load_libgccjit_if_needed(&libgccjit_target_lib_file);
218221
break;
219222
}
220223
}
221224

225+
if !gccjit::is_loaded() {
226+
let mut paths = vec![];
227+
for path in sess.opts.sysroot.all_paths() {
228+
let libgccjit_target_lib_file = file_path(path, &sess);
229+
paths.push(libgccjit_target_lib_file);
230+
}
231+
232+
panic!("Could not load libgccjit.so. Attempted paths: {:#?}", paths);
233+
}
234+
222235
#[cfg(feature = "master")]
223236
{
224237
let target_cpu = target_cpu(sess);

0 commit comments

Comments
 (0)