bazel-contrib / bazel-contrib/rules_foreign_cc

wrapper_build_script.sh: line 20: BUILD_LOG: unbound variable

Open
#1,417 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

After upgrading from rules_foreign_cc version 0.14.0 to 0.15.0, I've started seeing some problems:

1. Firstly, this error message when using the cmake rule: `wrapper_build_script.sh: line 20: BUILD_LOG: unbound variable`

All of my builds were successful with 0.14.0, but now:
- Some of my cmake targets are building successfully
- Other targets promptly fail with the `unbound variable` error. I'm attaching one the wrapper scripts for these: [wrapper_build_script.sh.txt](https://github.com/user-attachments/files/20734249/wrapper_build_script.sh.txt)

What I think happens is that setting one of my environment variables fails, thus triggering the trap. BUILD_LOG needs to be the first one being assigned.

2. Even though I'm only using the cmake rule, Bazel is now compiling BootstrapGNUMake and BootstrapPkgConfig which aren't needed.

3. My cmake rule instance is the dependency of another rule that applies an 1:N transition (thus building my library for multiple target platforms). The issue I see is that the number of times BootstrapGNUMake and BootstrapPkgConfig are building is equal to the number of target platforms. I was expecting them to be built differently only based on the execution platforms. The selected host compiler is the same across all these builds.

I'm running Bazel 8.2.1 with bzlmod only.

Contributor guide

Open the contributing guide

Research direction

Start with the attached wrapper_build_script.sh and the cmake rule changes between rules_foreign_cc 0.14.0 and 0.15.0. Reproduce the failure under Bazel 8.2.1, then inspect how BootstrapGNUMake and BootstrapPkgConfig are selected during the 1:N transition. Done means the wrapper no longer fails on BUILD_LOG and the bootstrap targets build only when required across target platforms.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.