Skip to content
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

bazelrc, --announce_rc, --enable_platform_specific_config disagree on precedence of platform-specific flags #10781

Closed
kevingessner opened this issue Feb 13, 2020 · 4 comments
Assignees

Comments

@kevingessner
Copy link
Contributor

Description of the problem:

--announce_rc prints the flags that are being applied from bazelrc files and the command line. The order isn't documented in the bazel docs but the command parsing blog post says "Use --announce_rc to see the order used!". So I expect the order the flags are announced to be their precedence: last announced flag wins.

When --enable_platform_specific_config is used, the order is wrong: the platform-specific flags are always announced last, even though they do not take priority. Instead, it appears that the platform-specific flags are expanded at the point of --enable_platform_specific_config earlier in the announcement, not the order of the bazelrc nor of the announcement.

The log should be fixed to announce the flags in the correct place in the order. Alternatively, enable_platform_specific_config's behavior should be changed to apply those flags last, matching the announcement -- this would make platform-specific configs more useful as predictable flag overrides (though this would be a breaking change).

In either case, the documentation should be updated to reflect the true priority of platform-specific configs.

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  1. clone https://github.com/kevingessner/bazel-options-repro. This repo has platform-specific configs that exercise the precedence.
  2. run bazel build --announce_rc :env -- note that the platform specific override of MY_OPTION is announced after --action_env=MY_OPTION=global
  3. cat bazel-bin/env.txt -- note that it contains the global value, not the platform-specific one.

What operating system are you running Bazel on?

centos and macos

What's the output of bazel info release?

repro'd on 2.0.0 and 2.1.0

Have you found anything relevant by searching the web?

@gregestren
Copy link
Contributor

Assigning to @meteorcloudy for triage / prioritization, who I believed touched this code last.

@meteorcloudy meteorcloudy added P2 We'll consider working on this in future. (Assignee optional) type: bug z-category: extensibility > configurability and removed untriaged labels Feb 14, 2020
@meteorcloudy
Copy link
Member

@kevingessner Thanks for reporting this bug and providing the reproduce case. I'll look into this.

@meteorcloudy
Copy link
Member

Hi @kevingessner , I did some investigation on this. It seems like the problem has nothing to do with --enable_platform_specific_config.

If you replace --enable_platform_specific_config with --config=linux and run the same command on Linux. You'll get exact same result (same log output and same env value printed).

Bazel always expands --config in place, indeed it's better to print the log also in the correct order. But looks like it's not an regression with --enable_platform_specific_config.

@meteorcloudy meteorcloudy added more data needed and removed P2 We'll consider working on this in future. (Assignee optional) type: bug more data needed labels Feb 28, 2020
@meteorcloudy
Copy link
Member

Since this is not a Bazel bug, I'll close it now :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants