-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--action_env ignored when cfg = "exec"
is used
#17062
Comments
"host" cfg is deprecated, and "exec" cfg saves ~10% compile time on kernels like polygamma. PiperOrigin-RevId: 404540569 Change-Id: I2a8be13501a42dc9ad7fbee0ac20b6bdf3124262
Does passing in |
Yes that seems to work. But I guess now I have to duplicate all |
@Flamefire |
@fmeum I believe it's #14848 (comment) |
Seems my comment didn't got saved so again the most important bits as multiple people spent days trying to figure out why TF started to fail to compile due to the wrong/unset env variables (I finally found the commit that broke/changed it by bisecting over 2000 commits): We are in, what should be, the most simple situation: Build a software (TensorFlow) with Bazel on the machine it is supposed to run on. On other build systems it is a variation of Previously However even before the change in TF it was brittle as the used environment depended on many other factors, for example:
I don't fully understand the difference between "host" and "exec" configurations, they sound very similar. Also the observed behavior surprises me: Next question is why And finally I'd like to ask what the "correct" way would be to build something with Bazel on the machine it is to be run i.e. a local, **non-**crosscompilation build. Things that come to mind:
I would also greatly appreciate an easy way to find out why a specific C++ file is compiled (or library linked) with specific env variables (i.e. in a specific configuration). E.g. it would help if I hope that helps and Merry Christmas! 🎅 |
Generally I understand you're saying this doesn't matter for your use case, where all architectures are the same.
As @fmeum mentioned, But if your baseline is an older version where Most important, I think, is if you really need some equivalent of |
You mean "behave equivalent for" as "have no effect on", correct? As I understood
A small step would be to have What would help us even more is to have no such "transitions", i.e. keep all environment variables from the current environment for all actions. We have modules which on load set up paths in
I don't understand that part. Can you elaborate or provide a link to the docs what flags only apply to some actions and the implications? |
Yes. According to my reading The only exception to this (the only place where
Doing some spelunking, #4008 looks pretty relevant - an old bug that looks like it's asking for the same sort of thing. That was fixed by #12122 which led to the current @meteorcloudy asked me at #12122 (comment) if we could just propagate What we need is a clear owner of the
I don't think there's a clear API or documentation for this now. The authoritative source for now is looking at the code: https://cs.opensource.google/search?q=%22FragmentOptions%20getExec%22&sq=&ss=bazel. For example https://cs.opensource.google/bazel/bazel/+/master:src/main/java/com/google/devtools/build/lib/analysis/config/CoreOptions.java;l=985;drc=3d29b2e14f143cd56dfee4d49d991a6e330f3a85 has the line that propagates |
I don't think we should make |
@Flamefire Just in case you didn't know: You can use I agree with Keith that |
As someone not involved in Bazel development that is hard to understand. There are 2 lines:
My suggestion was to have a uniform notation. E.g. there could be
That would indeed be an issue. But is that situation different to passing all variables to |
I'm quite confused by that sequence of events. #4008 is an issue that happens because a lot of rules in the ecosystem don't support |
Maybe this issue is just another aspect of #3320? |
It looks like people who are most familiar with this area do not think this is a good idea so closing for now but please feel free to continue the discussion. |
That's also what confused me: The option is named "use_default" and the default for this is "False"!
Pretty much yes. It's at least another instance where env variables are not used in actions unexpectedly.
Yes maybe not "automatically apply". But there is a need for an option to pass env variables to all actions. This would even reduce the number of rebuilds because the environment is the same, wouldn't it? |
I don't think it would as the target and exec configurations differ in other ways (on purpose) even if you align @Flamefire I still think that the best solution for your use case is a
What do you think about that? Re |
Just so I understand this correctly: There are 3 configurations: host, exec and target. I don't understand the distinction between host and exec but that is what caused the issue I reported here so there seem to be differences.
We are building TensorFlow using Bazel in a fresh folder, so no cache there, and want it to apply to all actions (or just don't clear the environment in the first place) because surprisingly many tools do care about the environment which we e.g. noticed by the change in TensorFlow from exec_tools to tools (or vice versa) where the already installed protobuf compiler failed to execute due to missing libraries (caused by unset |
There is no I agree that BUILD file authors can't know which env variables are required, which is precisely why I believe |
I'm a bit confused here. In which way is there "no Or are you referring to some change in Bazel after 4.2.2 where using If you could tell me which version introduced which change related to this it would really help our tooling around that. Thanks a lot! |
@gregestren would know best when exactly |
I agree that the default for |
It sounds like in general |
Having better doc on when to use either of these flags and when some other approach is better would be very useful. You could file a doc issue for that. |
I believe Bazel 6.0.
Recently I had some more out of the box ideas on how we might determine what makes up exec configurations. But that's probably a conversation for another place. |
Description of the bug:
We need to pass some environment variables like "
$CPATH
" to the compiler when building TensorFlow with Bazel. This is cumbersome itself and has led to hard-to-debug issues like #12059 in the past already.Now we again see failures caused by action-env values not passed to the compiler invocation in TensorFlow 2.8.4 which I tracked down to tensorflow/tensorflow@07cbc7b which changes
cfg = "host"
tocfg = "exec"
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
Build TensorFlow 2.8.4 with Bazel 4.2.2 passing
--action-env=CPATH
and observe that it is not passed to some compiler invocations resulting in e.g.:So can you provide information on how to use
--action-env
(or similar) in such circumstances?An explanation on what is actually being done with the change to "exec" from "host" would also be very welcome. In our case we are not cross-compiling so host, target and build machine are all the same.
I would clearly classify this behavior as a bug because the documentation states:
But obviously there are now actions where those are missing but they should be in "all actions"
Which operating system are you running Bazel on?
REHL 7
The text was updated successfully, but these errors were encountered: