build: Make build.rs candle-kernels compatible with Nix and sandboxed builds#3059
Merged
greenrazer merged 3 commits intoAug 28, 2025
Merged
Conversation
ahadnagy
reviewed
Aug 26, 2025
There was a problem hiding this comment.
This file is missing some imports:
use std::env;
use std::path::PathBuf;
Contributor
Author
There was a problem hiding this comment.
That is soo stupid of me :/
There was a problem hiding this comment.
Happens to me more times than I dare to admit :)
ahadnagy
approved these changes
Aug 26, 2025
Contributor
|
Thanks! |
john-sharratt
pushed a commit
to john-sharratt/candle
that referenced
this pull request
May 7, 2026
… builds (huggingface#3059) * Use OUT_DIR for generated PTX bindings * fix: fixed the out_dir cargo problem in examples * fix: added imports in build.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue where the build.rs script writes generated files directly to the src/ directory. This practice violates Cargo's guidelines and causes build failures in sandboxed environments like Nix, where the source directory is read-only.
Changes:
build.rs: The script is updated to write ptx.rs to the Cargo-designated $OUT_DIR instead of src/.
src/lib.rs: The ptx module is now loaded using the include!(concat!(env!("OUT_DIR"), "/ptx.rs")); macro, which is the standard pattern for including code generated by a build script.
This makes the crate compliant with Cargo best practices and significantly improves its compatibility with reproducible build systems.