f0rmiga / gcc-toolchain

A fully-hermetic Bazel GCC toolchain for Linux.
Apache License 2.0
104 stars 24 forks source link

[Query] Is it possible to use a wrapper for the compiler executables #178

Closed AnithaSyed closed 1 month ago

AnithaSyed commented 2 months ago

We are using a internal wrapper tool in the make for the gcc compiler. In bazel since we need to use the toolchain, is there a way to run this wrapper in the toolchain. EG:- The default gcc command is as /usr/bin/gcc <args for compiler> (Thnx to toolchain I can directly use the arch we need) Need to run a <wrapper> <args_for_wrapper> /usr/bin/gcc <args for compiler>

Please help on a approach to achieve this using the hermatic toolchain.

f0rmiga commented 1 month ago

Are you the wrapper author? We already have a wrapper here: https://github.com/f0rmiga/gcc-toolchain/blob/36e3e1f430871b539ce9261f53491564aa91c170/toolchain/wrapper.sh.tpl.

It gets rendered here: https://github.com/f0rmiga/gcc-toolchain/blob/36e3e1f430871b539ce9261f53491564aa91c170/toolchain/defs.bzl#L229-L237.

This means you have to patch gcc_toolchain to be able to inject a custom wrapper here: https://github.com/f0rmiga/gcc-toolchain/blob/36e3e1f430871b539ce9261f53491564aa91c170/toolchain/defs.bzl#L161C1-L161C14.

If you come up with a solution that can be upstreamed, I'm happy to review a PR.

Feel free to reopen this issue if my suggestion doesn't work.