0

I have a cc_library (tbb) that requires the compiler flag -mwaitpkg on some compilers (Clang) to compile successfully. At the same time, there are older versions of GCC (4.9) that do not know this flag, and therefore the compilation via GCC 4.9 leads to an error:

gcc: error: unrecognized command line option '-mwaitpkg'

In a more advanced Bazel setup, I guess one would work around this using hermetic toolchains. This way every toolchain could provide its own set of compiler flags. Nevertheless, I do not want to enforce any specific toolchain and I am not sure if this is the right way to go (move copts to toolchain?).

Also introducing a config would be a way to solve this problem. E.g. bazel build --config=waitpkg //.... But this would require that a user is aware of this config and also knows the details of using waitpkg.

What is a proper "Bazel-way" to handle different compiler flags for different compilers?

Vertexwahn
  • 7,709
  • 6
  • 64
  • 90

1 Answers1

-2

The flag '-mwaitpkg' is supported by GCC version 9.3, Clang* 12, and newer versions of those tools. If you build Bazel with earlier versions of GCC, you should remove the flag otherwise it gives compilation errors.