Skip to content

feat: support linking using cc_common.link#522

Merged
aherrmann merged 10 commits intoaherrmann:mainfrom
cerisier:cerisier/cc-common-link
Sep 22, 2025
Merged

feat: support linking using cc_common.link#522
aherrmann merged 10 commits intoaherrmann:mainfrom
cerisier:cerisier/cc-common-link

Conversation

@cerisier
Copy link
Contributor

@cerisier cerisier commented Sep 18, 2025

This is a first reviewable PR addressing #519, part of #480

  • Adds a use_cc_common_link bool flag, matching similar naming from other rulesets.
  • Split cdeps between copts and linker_inputs.
  • When use_cc_common_link=True, build a static-lib first and link the output using cc_common.link.
  • Used a private API of cc_common.link, the main_output attribute for 2 reasons:
    1. Be able to predict the output for location expansion
    2. Support a shared_lib_name attribute just like cc_shared_library does.
  • For zig_test, I preferred a single forward compatible solution with zig 0.14.0 (that lacks -femit=test-obj`)
    • Rather than support 2 behaviors for both =0.14.0 and >0.14.0.
  • Added a test following mode or target.
  • Added a test that checks for mnemonics.
  • Added a e2e test.

Happy to discuss with you which tests should be added.

@cerisier cerisier force-pushed the cerisier/cc-common-link branch 3 times, most recently from a38a8ec to 37c0d55 Compare September 19, 2025 11:59
@cerisier cerisier force-pushed the cerisier/cc-common-link branch from 37c0d55 to e781cba Compare September 19, 2025 12:00
I think for now it is fine, however, one could imagine using a
cc toolchain that does not use libc
@cerisier cerisier force-pushed the cerisier/cc-common-link branch from 127d933 to c376e2f Compare September 19, 2025 13:52
Copy link
Owner

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good, thank you!
Only some relatively small comments.

@cerisier cerisier force-pushed the cerisier/cc-common-link branch from e2806f1 to d492311 Compare September 22, 2025 09:43
Copy link
Owner

@aherrmann aherrmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@aherrmann aherrmann merged commit 7f36185 into aherrmann:main Sep 22, 2025
17 checks passed
@aherrmann
Copy link
Owner

@cerisier CI on main started failing after this PR, see here for example. Any idea what might be causing this?

@cerisier
Copy link
Contributor Author

Will have a look today. It's possible that two non conflicting PRs were green and merged but incompatible while combined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants