-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make zig cc
pass -l
/-L
like Clang/GCC for ELF
#19818
base: master
Are you sure you want to change the base?
fix: make zig cc
pass -l
/-L
like Clang/GCC for ELF
#19818
Conversation
@motiejus @kubkon This PR builds on the functionality implemented in #15743 and should also fix |
test/tests.zig
Outdated
@@ -769,6 +769,54 @@ pub fn addCliTests(b: *std.Build) *Step { | |||
step.dependOn(&cleanup.step); | |||
} | |||
|
|||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This set of tests belongs in linker tests in test/link/elf.zig
. I also don't understand why can't it be orchestrated using the build system? Why do you need to invoke zig exe via addSystemCommand
? exe.linkSystemLibrary("foo")
emits as -lfoo
fwiw. Did you actually have a look at test/link/elf.zig
? We do have a substantial amount of tests that rely on emitting and linking against system libs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've moved the testing to test/link/elf.zig
. The new commits add a few bits of extra functionality that are needed to reproduce the problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kubkon I think I've addressed your comments on this PR, any thoughts?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5f810f0
to
1860048
Compare
9107b5a
to
8d5fc36
Compare
b4dcd83
to
094faf4
Compare
094faf4
to
b3cfcab
Compare
b3cfcab
to
f211d2d
Compare
I am in the process of rebasing this on current mainline |
f211d2d
to
46752f5
Compare
zig cc
pass -l/-L
like Clang/GCC for ELFzig cc
pass -l
/-L
like Clang/GCC for ELF
46752f5
to
2af0d55
Compare
I've rebased this PR. The fix itself is in The new test is in The rest of the changes are new functionality needed for the test:
|
2af0d55
to
b8f46fa
Compare
I made some changes to avoid reconstructing the library name and directory in |
This commit adds `addLibraryPathSpecial` for `Build.Module` and `Build.Step.Compile`. Like `addLibraryPath` but for `[]const u8`. `addRPathSpecial` is also added for `Build.Step.Compile` for completeness. This is needed to implement the new test in ziglang#19818.
This commit adds the `soname` option for `Build.Module` and `OverlayOptions`. This controls whether `-fsoname` or `-fno-soname` is passed to the linker. This is needed to implement the new test in ziglang#19818
We need this to implement the new test in ziglang#19818 This commits adds: * `setCwd` for `Build.Step.Compile`. Allows setting current directory for compile steps. * `opt_cwd` for `evalZigProcess` in `Build.Step`. Allows running `evalZigProcess` in a specific directory. Needed for setting current directory for compile steps. `--zig-lib-dir` is now appended differently in `Build.Step.Compile`. This is needed for compatibility with `setCwd`.
b8f46fa
to
077f287
Compare
This commit adds the `omit_soname` option for `Build.Module` and `OverlayOptions`. This controls whether `-fsoname` or `-fno-soname` is passed to the linker. This is needed to implement the new test in ziglang#19818
We need this to implement the new test in ziglang#19818 This commits adds: * `setCwd` for `Build.Step.Compile`. Allows setting current directory for compile steps. * `opt_cwd` for `evalZigProcess` in `Build.Step`. Allows running `evalZigProcess` in a specific directory. Needed for setting current directory for compile steps. `--zig-lib-dir` is now appended differently in `Build.Step.Compile`. This is needed for compatibility with `setCwd`.
077f287
to
ac69db5
Compare
This commit adds the `soname` option for `Build.Module` and `OverlayOptions`. This controls whether `-fsoname` or `-fno-soname` is passed to the linker. This is needed to implement the new test in ziglang#19818
ac69db5
to
0a646aa
Compare
This commit adds the `soname` option for `Build.Module` and `OverlayOptions`. This controls whether `-fsoname` or `-fno-soname` is passed to the linker. This is needed to implement the new test in ziglang#19818
This test follows the example from ziglang#19699.
0a646aa
to
b0c5bbb
Compare
I've removed everything related to |
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 withI am not sure if
test/tests.zig
is the best place for it - I couldn't find a good way to test this intest/link/elf.zig
ortest/standalone
.