-
-
Notifications
You must be signed in to change notification settings - Fork 22
Use CC toolchain for linking (updated branch name for CI) #133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dcarp
merged 6 commits into
bazel-contrib:main
from
yanok:yanok/find-cc-toolchain-windows-macos
Dec 7, 2025
Merged
Use CC toolchain for linking (updated branch name for CI) #133
dcarp
merged 6 commits into
bazel-contrib:main
from
yanok:yanok/find-cc-toolchain-windows-macos
Dec 7, 2025
+151
−6
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Use `find_cpp_toolchain` from bazel_tools to find the current cc toolchain and use the compiler from it for linking. This is a bit naive, since we might need to add more flags to it. But it seems to be enough with the local toolchain from rules_cc.
Try to be smarter about linking: use the cc_toolchain to get the linking flags, filter some flags out and then pass the result to the D compiler. This works slightly better, allowing to use `toolchains_llvm` bazel module.
It seems like we need to also depend on `@rules_cc//cc:find_cc_toolchain_bzl`, which is a transitive dependency of `@bazel_tools//tools/cpp:toolchain_utils.bzl`.
Contributor
Author
|
Ok, so it fails on Windows consistently, since DMD doesn't support Another error seems to be about missing transitive bzl dependency... |
dcarp
requested changes
Dec 5, 2025
per review comments
dcarp
approved these changes
Dec 7, 2025
Collaborator
dcarp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There are two commits:
CCvariable to whatever the toolchain says is the compiler binary. This is clearly not enough for all cases, for example this doesn't work withtoolchains_llvmfor me.None of them are perfect, since the compiler options have to be filtered, also I haven't yet tested if it works on all platforms and whether cross-compilation works (not sure if it worked before this PR though, probably not).
Maybe we invert the direction here and instead of trying to give D compiler the correct way to call CC, try to link using the standard
cc_common.linkaction, adding the standard D libraries to the inputs.