Skip to content

Add a new environment variable for adding a custom libgccjit path - #957

Open
techmetx11 wants to merge 1 commit into
rust-lang:masterfrom
techmetx11:custom-search-path
Open

Add a new environment variable for adding a custom libgccjit path#957
techmetx11 wants to merge 1 commit into
rust-lang:masterfrom
techmetx11:custom-search-path

Conversation

@techmetx11

@techmetx11 techmetx11 commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

This PR adds a environment variable, that lets the user choose where should the driver look for libgccjit in.

This is better (in my opinion) than making a symlink in the Rust toolchain directory, because you don't have to assume which toolchain and host CPU architecture the user is using

Comment thread src/lib.rs
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

Comment thread src/lib.rs
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.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants