lowRISC / opentitan

OpenTitan: Open source silicon root of trust
https://www.opentitan.org
Apache License 2.0
2.59k stars 780 forks source link

[bazel] Support custom environment variables in build rules #24841

Open pamaury opened 1 month ago

pamaury commented 1 month ago

Description

In #24802, it was observed that --action_env cannot be used to override environment variables for build rules (but it works for test rules). This would be useful for LD_LIBRARY_PATH to run opentitantool. A temporary fixed was merged in #24802 but we should come up with a better solution.

matutem commented 3 weeks ago

Would this be compatible with air-gapped builds?

pamaury commented 3 weeks ago

I am not entirely sure what your question is @matutem : are you asking if this env var mechanism will work in air-gapped build, or whether this mechanism might break air-gapped build? Just to add some context (more details in #24802): some OT developers might have to run tests in enviroments where they can't install anything on the system so they either need to install things locally or point to a NFS drive. The particular problem there were libraries such as libusb. The issue is that although it's possible to override environment variables for bazel test using --action_env, this does not work for bazel build unless use_default_shell is set to true, but this makes bazel less hermetic. As a workaround, we added use_default_shell in #24802 but the idea would be to add a custom setting for that and remove use_default_shell, and this would only be set by developers on their machine if they need to.