I hit an error building rust-openssl, and it looks like it's not fixable without adding functionality to Cargo:
https://github.com/sfackler/rust-openssl/issues/406
The build script there uses OPENSSL_{LIB,INCLUDE}_DIR as inputs, but it doesn't get re-run if those variables were unset and are later set, or if their values change.
It would be good if build scripts could tell Cargo about environment variables they use as input, and then Cargo could record the status of those env vars upon build script invocation, and use them as dependencies for re-running the build script.
Yeah this is kinda an unfortunate situation that this is in where in theory build scripts shouldn't rely on magical environment variables like this but in practice it's what ends up happening. I know that I've definitely run into this problem quite a few times and always have to remember to clean the right package, so it's definitely annoying!
cc @wycats
I seem to remember there being a POSIX API for "shimming" a fake environment and then jumping back to a procedure with the "real" environment on the stack with a setjmp.
Yeah this is kinda an unfortunate situation that this is in where in theory build scripts shouldn't rely on magical environment variables like this but in practice it's what ends up happening.
Any user of pkg-config relies on env variables (e.g. PKG_CONFIG_PATH) by extension.
Well there currently isn't any other way to provide information to a build script, so environment variables are a necessity. This issue has bit me before, and many other people as well.
We even have rerun-if-changed already for depending on files, so surely we can just add another key for environment variables?
Would love to see rerun-if-changed-env=FOO or something similar)
In theory this shouldn't be too hard to implement, so tagging E-help-wanted
What do you all think about opt-in whitelisting of environment variables, visible in build.rs (as proposed here)? That way, we'll make builds a little more deterministic, and will avoid a problem when someone (perhaps transitively) uses an env variable, but does not specify it in rerun-if-env-changed.
Most helpful comment
What do you all think about opt-in whitelisting of environment variables, visible in
build.rs(as proposed here)? That way, we'll make builds a little more deterministic, and will avoid a problem when someone (perhaps transitively) uses an env variable, but does not specify it inrerun-if-env-changed.