Skip to content

feat: implement test-obj for use_cc_common_link in zig 0.16#647

Open
cerisier wants to merge 2 commits intoaherrmann:mainfrom
cerisier:test-obj
Open

feat: implement test-obj for use_cc_common_link in zig 0.16#647
cerisier wants to merge 2 commits intoaherrmann:mainfrom
cerisier:test-obj

Conversation

@cerisier
Copy link
Copy Markdown
Contributor

@cerisier cerisier commented May 7, 2026

As of zig-0.16, it is now possible to use test-obj to produce a machine code object for the test.

It is also important to support that because there are setups where producing a .bc and handing it over the zig doesn't work.

For instance, when bootstrapping zig, and using a dedicated cc toolchain, one might want to save build cycles and not build zig with clang support at all. In which case, zig cc doesn't work.

It is a niche usecase but important when supporting the new chip story.
This is already the right way to do this in zig 0.16 anyway.

Additionally, there is a bug in zig test-obj when passing -lc or -fcompiler-rt because LLVM does allow __stack_chk_fail to be an alias. We circumvent this by passing -fno-stack-protector when test-obj will be used.

def _object_extension(os):
return ".obj" if os == "windows" else ".o"

def _supports_test_obj(zig_version):
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.

Can this be replaced by semver ?

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.

1 participant