-c dbg vs --config debug

35 views
Skip to first unread message

Barry Revzin

unread,
Jun 20, 2022, 12:00:26 PMJun 20
to bazel-discuss
Bazel appears to have two different mechanisms for specifying a build configuration.

I can do "-c dbg" or I can do "--config debug". With "--config debug", I can add things like "build 

The latter lets me add specific command-line flags to my .bazelrc, like build:debug --copt=-g or build:release --copt=-O3. But it doesn't appear that the former lets me do this? Is there a way to specify default compilation mode flags, or is the only way to do this via custom configurations? 

Barry

Keith Smiley

unread,
Jun 20, 2022, 12:44:03 PMJun 20
to Barry Revzin, bazel-discuss
If you want to configure things without configs you'll have to use your own crosstool, or macros, and add conditionals with select statements based on the current compilation_mode.

--
You received this message because you are subscribed to the Google Groups "bazel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bazel-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bazel-discuss/aae45032-3a62-4122-ae49-4aea922a4859n%40googlegroups.com.
--
--
Keith Smiley

Barry Revzin

unread,
Jun 20, 2022, 5:37:57 PMJun 20
to Keith Smiley, bazel-discuss
Is there a way to have -c dbg just behave like --config debug and -c opt just behave like --config release? I don't see anything like that in the documentation, and I'm not sure how to use select() to specify flags globally.

To be clear, it's not that I want to configure things without configs, it's that it's a bit confusing that -c dbg and --config debug seem to be mostly unrelated commands and I'd like to able to avoid surprise from the two similar-looking commands having different meanings. 

Keith Smiley

unread,
Jul 5, 2022, 5:22:28 PMJul 5
to Barry Revzin, bazel-discuss
Yea I think the confusion here is that it can be initially surprising that `-c` is short for `--compilation_mode` and not `--config`. But they are entirely unrelated, so unless you do what I mention and use select statements based on the compilation_mode you likely have to use configs
--
Keith Smiley

Reply all
Reply to author
Forward
0 new messages