Skip to content

feat: reorder the target parameter in zig wrapper#223

Merged
linzhp merged 3 commits intouber:mainfrom
liningpan:cc-patch
Jun 30, 2025
Merged

feat: reorder the target parameter in zig wrapper#223
linzhp merged 3 commits intouber:mainfrom
liningpan:cc-patch

Conversation

@liningpan
Copy link
Copy Markdown
Contributor

@liningpan liningpan commented Jun 8, 2025

Closes #222

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jun 8, 2025

CLA assistant check
All committers have signed the CLA.

@cameron-martin
Copy link
Copy Markdown

This is a good solution to the issue, thanks. However looks like you'll need to fix the tests and sign the CLA.

@liningpan
Copy link
Copy Markdown
Contributor Author

CI looks like a flaky failure when downloading protobuf. Could you please rerun it?

@TroyKomodo
Copy link
Copy Markdown

bump on this pr @cameron-martin

@cameron-martin
Copy link
Copy Markdown

bump on this pr @cameron-martin

I don't have any powers in this repo, I'm just somebody who wants the issue fixed too.

@liningpan
Copy link
Copy Markdown
Contributor Author

liningpan commented Jun 25, 2025

@linzhp I see you have active commit in this repo recently. Could you please help review the PR?

@liningpan
Copy link
Copy Markdown
Contributor Author

@TroyKomodo If you need a quick fix, it is possible to patch the zig wrapper using git override. I provided my patch in the original issue in rules_rust, see my comment bazelbuild/rules_rust#2529 (comment)

@linzhp
Copy link
Copy Markdown
Contributor

linzhp commented Jun 26, 2025

I can take a look later this week

@TroyKomodo
Copy link
Copy Markdown

@TroyKomodo If you need a quick fix, it is possible to patch the zig wrapper using git override. I provided my patch in the original issue in rules_rust, see my comment bazelbuild/rules_rust#2529 (comment)

I am, thanks!

Comment thread toolchain/zig-wrapper.zig
// the target specified by other tools calling the wrapper.
// Some tools might pass LLVM target triple, which are rejected by zig.
// https://github.com/uber/hermetic_cc_toolchain/issues/222
if (run_mode == RunMode.cc) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
if (run_mode == RunMode.cc) {
if (run_mode == .cc) {

shouldn't it be like this? When I test this internally at uber, cursor bot commented:

The patch incorrectly handles the RunMode.cc variant of a Zig tagged union. It uses an invalid comparison if (run_mode == RunMode.cc) and an incorrect direct access run_mode.cc to retrieve its payload, which is not how tagged union variants with data are accessed in Zig.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't know much about zig. Based on my understanding of zig, .cc is equivalent to RunMode.cc, where the enum type is inferred (https://ziglang.org/documentation/master/#toc-Enum-Literals). It does seem like not specifying the type when it can be inferred is idiomatic in zig.

@linzhp linzhp merged commit e906f27 into uber:main Jun 30, 2025
3 of 6 checks passed
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.

Zig c++ wrapper parameter order

5 participants