bazel-contrib / bazel-contrib/rules_foreign_cc

Allow unsetting compiler env vars

Open
#1,113 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

When I pass certain environment variables via `env = {…}`, instead of being set directly, they will be appended to the existing variables provided by the C toolchain. These are variables like `CFLAGS`, `ASFLAGS`, etc.

I hit the problem where some projects, like `x264`, need a specific assembler. So I pass in my custom-built `nasm` as a dependency, but now they will still use the compiler toolchain's `ASFLAGS` with `nasm`, which doesn't understand all the `llvm-as` flags so it fails to assemble anything.

When I pass in any other `ASFLAGS` via `env`, they simply get appended. I'd like to have a way to overwrite these flags when necessary. Not sure what would be the most elegant way to do this; it could be a separate boolean flag, something like `override_env`, which, when set to `True`, would replace these env vars instead of merging them? This would preserve existing behaviour which is probably appropriate for most other use cases.

I'm open to other suggestions too.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how env values such as CFLAGS and ASFLAGS are merged with the C toolchain environment. Done means providing a way to replace these variables instead of appending them, while preserving the existing merge behavior by default.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.