Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build scripts should not write outside OUT_DIR #10

Open
gmacon opened this issue Aug 28, 2024 · 0 comments
Open

Build scripts should not write outside OUT_DIR #10

gmacon opened this issue Aug 28, 2024 · 0 comments

Comments

@gmacon
Copy link

gmacon commented Aug 28, 2024

According to the Cargo book, build scripts should not modify any files outside of $OUT_DIR. The documentation here currently recommends that consumers of this crate do exactly that:

bindgen_cuda/src/lib.rs

Lines 297 to 304 in a6b0c89

/// Consumes the builder and outputs 1 ptx file for each kernels
/// found.
/// This function returns [`Bindings`] which can then be unused
/// to create a rust source file that will include those kernels.
/// ```no_run
/// let bindings = bindgen_cuda::Builder::default().build_ptx().unwrap();
/// bindings.write("src/lib.rs").unwrap();
/// ```

This caused an issue for me building candle-kernels within Nix because the source of candle-kernels is read-only when the build script is run.

It would be better for us to recommend the pattern given in the code generation example that writes to $OUT_DIR and then uses the include! macro in lib.rs.

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

No branches or pull requests

1 participant