bazel
bazel copied to clipboard
C++: strip action ignores environment passed through toolchain features
Description of the problem / feature request:
When passing custom environment variables to compile actions using env_sets parameter of a feature, stripping action ignores it.
I found this while using bazel_rules_cc_toolchain, which passes path to the compiler into the wrapper script using environment variables. While most of the compilation works ok, it seems to fail with stripping step, because bazel does not pass the expected variable STRIP_TOOL_PATH, which is set by a feature.
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
git clone -b strip https://gitlab.com/DCNick3/bazel_rules_cc_toolchain_repro.git
bazel build '//main:hello-world.stripped'
What operating system are you running Bazel on?
GNU/Linux
What's the output of bazel info release?
release 4.2.1
Have you found anything relevant by searching the web?
Nope
Any other information, logs, or outputs that you want to share?
I took a glance at the source code surrounding the potential problem and found a suspicious difference between the stripping and usual compilation: while CppCompileActions gets the provided environment from featureConfiguration (through compileCommandLine.getEnvironment()), I can't see it being called by code creating the strip action, and it has even more suspicious call to useDefaultShellEnvironment.
It also seems that other actions in the CppHelper class may be affected.
While I am completely unsure if this analysis is 100% correct, I hope it helps to find the underlying issue and fix it.
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!
@bazelbuild/triage Can you please check if it's possible to reopen this issue? Sadly some custom toolchains request certain information to be present in environment (for example license information) and without possibility to send environment variables over feature we are forced to invoke strip over custom rule.
@bazelbuild/triage Can you please check if it's possible to reopen this issue? Sadly some custom toolchains request certain information to be present in environment (for example license information) and without possibility to send environment variables over feature we are forced to invoke strip over custom rule.
Fully endorse this comment, should be reopened
@bazelbuild/triage Could you reopen this issue?
Any progress on this issue? Would come in handy :)
@tomaspipes Could you test out https://github.com/bazelbuild/bazel/pull/22590?
A fix for this issue has been included in Bazel 7.3.0 RC1. Please test out the release candidate and report any issues as soon as possible.
If you're using Bazelisk, you can point to the latest RC by setting USE_BAZEL_VERSION=7.3.0rc1. Thanks!