bazelbuild / bazelbuild/rules_cc

[rule based toolchain] Supporting exec tools as part of cc_args

Open
#627 3 comments 0 reactions 0 assignees View on GitHub
category: toolchains P3 type: feature request
Dominant language
Starlark
Stars
247
Forks
196
PR merge metrics
No merged PRs in 30d

Description

`clang` and `gcc` both can both delegate various part of the build to external tools. `ld` and `as` are the most popular.

In the case of CUDA, extra binaries such as `ptxas` come at play.

By default `clang` expects to find it inside a bin folder under [`--cuda-path=`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-cuda-path).
Or at a custom path defined by [`--ptxas-path=`](https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-ptxas-path)

The issue is that `cc_args` to pass `--ptxas-path` is evaluated under `cc_toolchain.args` which is target configured, whereas `ptxas` needs to match the platform resolved for the toolchain.

An option is to wrap those binaries into rule that reexports the binary provided as `cfg = "exec"` but from our own experience, exec cfg isn't guaranteed to match the resolved platform for the toolchain.

Arguably, the ability to pass a custom `--ld-path` would suffer from the same issue.

From my understanding, only the `tool_map` would be guaranteed to match the resolved platform for the toolchain, and that only after #555 lands.

Has this use case ever been considered ?

cc @dzbarsky and @fmeum with whom we have regular discussion about this.

Contributor guide

Open the contributing guide

Research direction

Start by tracing how cc_args is evaluated under cc_toolchain.args and compare that with the tool_map behavior described in the issue. Review the implications of #555 for platform resolution and the examples involving --ptxas-path and --ld-path. Done should be a documented or implemented approach for resolving delegated exec tools against the toolchain platform.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
build-system, compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.