bazel-contrib / rules_cuda

Starlark implementation of bazel rules for CUDA.
https://bazel-contrib.github.io/rules_cuda/
MIT License
85 stars 43 forks source link

Add support for external_includes #267

Closed layus closed 1 month ago

layus commented 1 month ago

With this PR I get a strange error about forbidden internal API.

Fixes #266

cloudhan commented 1 month ago

Seems comming from here https://togithub.com/bazelbuild/bazel/blob/3324f06cbd55ffadd497ca21e94ddb30a7675898/src/main/starlark/builtins_bzl/common/cc/cc_common.bzl#L454

cloudhan commented 1 month ago

There is a chain of something like external_includes != _UNBOUND or \, and the external_includes triggers the forbidden internal API..., looking into the _PRIVATE_STARLARKIFICATION_ALLOWLIST and you will notice that they are doing really dumb things and violate the open–closed principle by hardcoding the rule name... 🤦

layus commented 1 month ago

So it seems that external_includes are part of the internal API, and we are not supposed to use them. Maybe there is a way to merge compilation contexts without tearing it apart and recreating it like we do here ?

For now, I found a simple hotfix:

cuda_library(
    ...
    features = ["-external_include_paths"],
)
cloudhan commented 1 month ago

I think it is workaroundable, you might just want to consume the external_includes (direct on the target or from deps), but dont propagate it forward by the cc_info.