Repository navigation
Conversation
Selecting cc_common.link previously forced Zig into libc mode even for freestanding targets. Use the existing libc and libc++ dependencies to configure Zig compilation while preserving their CcInfo for the final link. Declare libc on bundled hosted tools and exercise both hosted and freestanding links.
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
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.
use_cc_common_linkselects the final linker for Zig binaries, tests, and shared libraries. Zig also needs to know during compilation whether the target uses libc or libc++.Before
-lcand-lc++from the helper dependencies reached Zig as ordinary linker flags in the combined compile and link invocation.-lc. That happened to give hosted binaries the C ABImainthey needed, but it also forced libc mode on freestanding targets and left Zig compilation unaware of an explicit:libc++dependency.A hosted binary with a
:libcdependency therefore compiled with-lcin either mode, but only the combined Zig invocation got that flag from the dependency itself.After
:libcand:libc++have the same meaning with either linker. Rules_zig recognizes the helper labels inCcInfoso that an explicit runtime dependency configures Zig compilation and carries the corresponding flags to the final link.Hosted targets that relied on the blanket
-lcnow need to declare libc explicitly. Freestanding targets can usecc_common.linkwith their own entry point and linker options.