zig icon indicating copy to clipboard operation
zig copied to clipboard

fix: make `zig cc` pass `-l`/`-L` like Clang/GCC for ELF

Open a-khabarov opened this issue 1 year ago • 12 comments

This PR is my attempt to fix #19699 by making the way zig cc passes -l/-L flags for ELF linking consistent with Clang and GCC. I've added a test case that mimics the example in the issue description. Without the changes this PR makes to src, the new test case fails as expected with

========= expected to find: ==========================
NEEDED libfoo.so
========= but parsed file does not contain it: =======
dynamic section
RUNPATH foo
NEEDED foo/libfoo.so
NEEDED libc.so.6

I am not sure if test/tests.zig is the best place for it - I couldn't find a good way to test this in test/link/elf.zig or test/standalone.

a-khabarov avatar Apr 30 '24 15:04 a-khabarov

@motiejus @kubkon This PR builds on the functionality implemented in https://github.com/ziglang/zig/issues/15743 and should also fix cc_test not working correctly when using hermetic_cc_toolchain as mentioned in https://github.com/ziglang/zig/issues/15743#issuecomment-2064878213.

a-khabarov avatar May 01 '24 18:05 a-khabarov