Hi, I am trying to compile tbb using the zig build system. Tbb's CMakeLists.txt passes the -mwaitpkg flag to the compiler to activate the relevant cpu flag.
I do the same in my build program by passing it as part of .flags when calling addCSourceFiles, like so
.flags = &.{
"-std=c++11",
"-fstack-protector-strong",
"-ffp-model=precise",
"-mrtm",
"-mwaitpkg",
},
However, invoking zig build fails with error: always_inline function '_tpause' requires target feature 'waitpkg', but would be inlined into function 'prolonged_pause' that is compiled without support for 'waitpkg'
I can see the flag being passed along correctly:
error: the following command failed with 2 compilation errors:
/usr/bin/zig build-lib -cflags -std=c++11 -fstack-protector-strong -ffp-model=precise -mrtm -mwaitpkg -- ...
What does work is specifying the feature flag via -Dcpu, e.g. this command completes and generates libraries
zig build -Dcpu=x86_64_v2+waitpkg
Is passing -mxxx as part of the compiler flags incorrect, or what am I doing wrong?