You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[feature request] Allow users to add extra extension names for C/C++ toolchains. #2298
P2We'll consider working on this in future. (Assignee optional)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: feature request
One of the reasons that I am still using an internal fork of Bazel is that we need to support CUDA programs with their .cu extensions. As CUDA is deeply integrated with C/C++ toolchains, and is usually supposed to be linked together with C/C++ object files with shared headers, it does not really make sense to treat it as a separate language.
My current solution to support CUDA is that I modified Bazel to include ".cu" as another file extension to indicate a C++ source file. Then I grabbed a wrapper from Tensorflow and slightly modified it so it would call nvcc when a .cu file is given and call gcc otherwise.
This works nicely. However, I believe there's some insight in this home-baked solution: a simple feature that allows us to instruct Bazel to treat some file extensions in the same way as some existing extensions, would enable users to support the many existing C/C++ compatible languages without reinventing the wheel that is C/C++ toolchain support.
We'll eventually need to do this. The original motivation is not source files, but that output files (object files, libraries, executables and such) have different extensions in different operating systems. And once we have that, it's not a big stretch to extend the same thing to source files, too.
IIUC artifact_name_pattern controls what @lberki mentioned above, but the original feature request is slightly different, it asks for adding extra extensions for input source files instead of artifacts, so I don't think this has been already done and is a documentation-only issue.
To be more precise, what is requested here is to allow modifying com.google.devtools.build.lib.rules.cpp.CppFileTypes.CPP_SOURCE and CPP_HEADER (adding .cu and .cuh correspondingly) without patching Bazel itself.
This may become irrelevant if the C++ sandwich eventually leads to a proper cuda_library implementation though.
Various compilers introduce different extension names for different kind of inputs/outputs, e.g. emscripten can compile libraries into .bc files and executable output is going to be several files of .js, .wasm and some optional extras, which currently need to be resorted to workarounds when working with bazel.
I feel like all of that configuration should be specified in the toolchain providers rather than hardcoded in bazel internals for each different os/arch/compiler combination.
I think different actions are triggered depending on the extension. Last time someone sent a PR to remove all checks, we got tests failing internally in our mono-repo because of the way a file with an assembly extension was being handled. We won't spend time on this for now but you are welcome to investigate a refactoring that would remove the restriction while keeping current behavior, i.e.: which actions are triggered by which files stays the same.
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!
P2We'll consider working on this in future. (Assignee optional)staleIssues or PRs that are stale (no activity for 30 days)team-Rules-CPPIssues for C++ rulestype: feature request
Activity
hlopko commentedon Jan 2, 2017
@lberki Wdyt?
lberki commentedon Jan 2, 2017
We'll eventually need to do this. The original motivation is not source files, but that output files (object files, libraries, executables and such) have different extensions in different operating systems. And once we have that, it's not a big stretch to extend the same thing to source files, too.
hlopko commentedon Jan 10, 2019
This has been already done (we still require the extension to be from a limited set). I see
artifact_name_patternis not documented on https://docs.bazel.build/versions/master/crosstool-reference.html so I'll leave this issue open to improve the docs.Riatre commentedon Feb 11, 2019
IIUC
artifact_name_patterncontrols what @lberki mentioned above, but the original feature request is slightly different, it asks for adding extra extensions for input source files instead of artifacts, so I don't think this has been already done and is a documentation-only issue.To be more precise, what is requested here is to allow modifying
com.google.devtools.build.lib.rules.cpp.CppFileTypes.CPP_SOURCEandCPP_HEADER(adding.cuand.cuhcorrespondingly) without patching Bazel itself.This may become irrelevant if the C++ sandwich eventually leads to a proper
cuda_libraryimplementation though.celentes commentedon Mar 13, 2021
Friendly ping. What is the status on this?
Various compilers introduce different extension names for different kind of inputs/outputs, e.g. emscripten can compile libraries into .bc files and executable output is going to be several files of .js, .wasm and some optional extras, which currently need to be resorted to workarounds when working with bazel.
I feel like all of that configuration should be specified in the toolchain providers rather than hardcoded in bazel internals for each different os/arch/compiler combination.
What is the motivation behind restricting these?
oquenchil commentedon Mar 16, 2021
I think different actions are triggered depending on the extension. Last time someone sent a PR to remove all checks, we got tests failing internally in our mono-repo because of the way a file with an assembly extension was being handled. We won't spend time on this for now but you are welcome to investigate a refactoring that would remove the restriction while keeping current behavior, i.e.: which actions are triggered by which files stays the same.
github-actions commentedon May 1, 2023
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 2+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (
@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.github-actions commentedon May 15, 2023
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (
@bazelbuild/triage). Thanks!