Handling environment variables for local and remote builds
- Dominant language
- Rust
- Stars
- 4.4k
- Forks
- 394
- PR merge metrics
- No merged PRs in 30d
Description
One of the most frustrating things about most build systems is that builds can be different from user to user, due to critical environment variable settings. For example [Environment Variables Affecting GCC](https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html). I see problems with environment handling within buck2, as well (#532 and #466).
The [scons build system has an environment management system](https://scons.org/doc/production/HTML/scons-user/ch07s02.html) which is a joy to work with. Since environment variables can impact the build itself, the build environment is also used as a dependency. If there is a change in the execution environment, the build signature changes, which is critical for binary caching integrity.
For example assume we start with a "-O2" build configuration:
```
env = Environment(CC='gcc', CCFLAGS='-O2')
env.Program('foo.c')
```
Later, change the build file to an "-O3" build configuration:
```
env = Environment(CC='gcc', CCFLAGS='-O3')
env.Program('foo.c')
```
The affected binaries would be rebuilt with a different build signature (O3 version of foo.o and foo instead of O2). Change the build configuration back to "-O2", and scons would pull the binaries from the first build (O2 version) instead of rebuilding.
What is the best way to handle something like this in buck2?
Contributor guide
Assessment
This issue has not been assessed yet.