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

Custom compilation modes #24092

Open
ansonos opened this issue Oct 25, 2024 · 1 comment
Open

Custom compilation modes #24092

ansonos opened this issue Oct 25, 2024 · 1 comment
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request untriaged

Comments

@ansonos
Copy link

ansonos commented Oct 25, 2024

Description of the feature request:

It would be beneficial if users would be able to add their own "modes". Currently there are three hardcoded modes --compilation_mode (fastbuild|opt|dbg) (-c). That these modes come with default flags, which do not map well to all projects is a minor issue. The bigger issue is that probjects with more flag sets and configurations have no good way to specify a different output directory:

Bazel uses a different output directory for each different compilation mode, so you can switch between modes without needing to do a full rebuild every time.

Really the concept of compilation_modes is quite nice, but limited by being hardcoded.

Which category does this issue belong to?

Configurability, Core

What underlying problem are you trying to solve with this feature?

Different output dictionaries per user flag set.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 7.4.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

-

Have you found anything relevant by searching the web?

https://bazel.build/docs/user-manual#compilation-mode

The --compilation_mode option (often shortened to -c, especially -c opt) takes an argument of fastbuild, dbg or opt, and affects various C/C++ code-generation options, such as the level of optimization and the completeness of debug tables. Bazel uses a different output directory for each different compilation mode, so you can switch between modes without needing to do a full rebuild every time.

  • fastbuild means build as fast as possible: generate minimal debugging information (-gmlt -Wl,-S), and don't optimize. This is the default. Note: -DNDEBUG will not be set.
  • dbg means build with debugging enabled (-g), so that you can use gdb (or another debugger).
  • opt means build with optimization enabled and with assert() calls disabled (-O2 -DNDEBUG). Debugging information will not be generated in opt mode unless you also pass --copt -g.

https://bazel.build/docs/user-manual#platform-suffix

Adds a suffix to the configuration short name, which is used to determine the output directory. Setting this option to different values puts the files into different directories, for example to improve cache hit rates for builds that otherwise clobber each others output files, or to keep the output files around for comparisons.

Could be used as a way around this issue, but is rather clunky (and flags x platfrom x configuration matrix explosive) as long as there is a better way.

Any other information, logs, or outputs that you want to share?

No response

@github-actions github-actions bot added team-Configurability platforms, toolchains, cquery, select(), config transitions team-Core Skyframe, bazel query, BEP, options parsing, bazelrc labels Oct 25, 2024
@benjaminp
Copy link
Collaborator

#788

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Configurability platforms, toolchains, cquery, select(), config transitions team-Core Skyframe, bazel query, BEP, options parsing, bazelrc type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

5 participants