Repository navigation
How to efficiently combine flags and select()s #21485
Unanswered
nicholasjng
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Hello! I'm currently porting a project from CMake to Bazel, and I'm facing a situation in which I want to pass size optimizations (-Os on clang/gcc, /Os on MSVC) to a target based on the value of a flag which I define.
Before I started implementing this flag, I had a simple
select()in mycoptssupplying the above option for "MVSC or not" based on the current toolchain compiler.Now, however, I need to also select on the value of the sizeopt flag, and to pass the right one for "MSVC or not". This results in at least 4 config settings (compiler is MSVC, compiler is not MSVC (!!!), sizeopts, no sizeopts. But there's more:
(!!!) Because both select paths have different options, each condition has to be unique, so after introducing the sizeopts flag, I cannot go with "not MSVC" anymore, but have to take in all compiler names, e.g. from
@rules_cc//cc/compilerin my case. That technically restricts me from being able to use any compiler before, to only the natively known compilers (gcc, clang, clang-cl, mingw-gcc, msvc-cl).On top of that, all of these settings clutter my build target - running
bazel query "@nanobind//:*"gives me 9 total config settings, but I guess I can make them invisible by changing the package's default visibility (right now, it's//visibility:public).Question: Is there a better way to handle these flag-guarded options for different compilers at the same time?
All reactions