Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ $ LIBRARY_PATH="[gcc-path value]" LD_LIBRARY_PATH="[gcc-path value]" rustc +$(ca
* _**CG_GCCJIT_DUMP_EVERYTHING**_: Enables dumping of all intermediate representations and passes.
* _**CG_GCCJIT_KEEP_INTERMEDIATES**_: Keeps intermediate files generated during the compilation process.
* _**CG_GCCJIT_VERBOSE**_: Enables verbose output from the GCC driver.
* _**CG_GCCJIT_SEARCH_PATH**_: Add a custom library path to look for `libgccjit.so` in

## Extra documentation

Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ mod type_of;
use std::any::Any;
use std::ffi::CString;
use std::fmt::Debug;
use std::fs;
use std::ops::Deref;
use std::path::{Path, PathBuf};
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::{Arc, Mutex};
use std::{env, fs};

#[cfg(feature = "master")]
use gccjit::TargetInfo;
Expand Down Expand Up @@ -210,6 +210,10 @@ impl CodegenBackend for GccCodegenBackend {
lib_path.join(sess.target.llvm_target.as_ref()).join("libgccjit.so");
paths.push(llvm_target_path);
}
if let Ok(custom_path) = env::var("CG_GCCJIT_SEARCH_PATH").as_deref() {
paths.push(PathBuf::from(custom_path).join("libgccjit.so"));

@antoyo antoyo Aug 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is added last, this means that if a library is found in the sysroot, the library from the env var won't be used.
I believe it would make more sense to use the one from the env var if it is exists.
Doing that means we can probably move that check outside this function.

View changes since the review

@antoyo antoyo Aug 20, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you think it would be better to have the env var point directly at the library file?
Doing so, we could support libraries named libgccjit.so.0.

View changes since the review

}

paths
}

Expand Down
Loading