Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bazel select condition for a specific GCC major-version

Tags:

bazel

We have to pass a special linkopts flag to cc_library rules that use <filesystem>, specifically for the GCC version that ships with Debian 10 (gcc 8.3).

I don't want to make developers pass a --config=old_gcc or similar at the top level.

I was hoping an incantation kind of like this would work:

    linkopts = select({
       "@bazel_tools//tools/cpp:gcc": ["-lstdc++fs"],
       "//conditions:default": [],
    }),

But a) gcc is not a configurable attribute that select() can use and b) we more specifically should test the version number is 8 (we'll only support 8 or above).

How do I extract a is_gcc8-like config_setting I can select on like this for targets using <filesystem>? TIA!

like image 806
cdleary Avatar asked Nov 06 '22 07:11

cdleary


1 Answers

One way to do this is to change to using a manual CROSSTOOL setup instead of relying on the automatic crosstool setup (documentation here). This would allow you to specify a set of linker flags to apply when compiling with a certain combination of --cpu and --compiler.

like image 96
Jono Chadwell Avatar answered Nov 22 '22 10:11

Jono Chadwell