Skip to content

Document Zig's built-in linker options #9407

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

Closed
wants to merge 1 commit into from

Conversation

jepotter1-archive
Copy link

This PR adds documentation for the ld.lld, lld-link, and wasm-ld options, which are currently exposed but not documented.

Note that I haven't tested this locally but it should work fine regardless since it only adds a few lines to the help string.

@g-w1
Copy link
Contributor

g-w1 commented Jul 17, 2021

Why not just use zig ld? I think these are only supposed to be used internally.

@jepotter1-archive
Copy link
Author

Why not just use zig ld? I think these are only supposed to be used internally.

@g-w1 error: unknown command: ld

This is on Zig 0.8.0.

@g-w1
Copy link
Contributor

g-w1 commented Jul 17, 2021

Ah, sorry, I meant, build-exe or build-lib, or build-obj. You can just pass the things you would like to link to args as to those programs.

@jepotter1-archive
Copy link
Author

Ah, sorry, I meant, build-exe or build-lib, or build-obj. You can just pass the things you would like to link to args as to those programs.

Is build-lib a drop-in LD though?

Like, can I set LD=zig build-lib?

@g-w1
Copy link
Contributor

g-w1 commented Jul 17, 2021

I do not think so, but also see #8755.

@jepotter1-archive
Copy link
Author

The use case here is that I'm making a Linux distribution and a lot of build scripts (e.g. Autotools, CMake) automatically use the system linker rather than Zig's linker. I can override this by setting LD to something... which I'm currently setting to zig ld.lld and it seems to work.

@jepotter1-archive
Copy link
Author

The problem is I had to do a lot of digging to find this information (including reading your IRC messages in the IRC log). I'm just submitting this patch so maybe the next person who is crazy enough to try to make a Linux distro based on Zig will have it slightly easier 😅

@g-w1
Copy link
Contributor

g-w1 commented Jul 17, 2021

I think this is a workaround, it might not be that hard to just implement #8755 depending on the target os (may be a bit harder to hook up the self-hosted linker backends, but for linux, it should just be forwarding the args to argv[0] ld.lld.)
(ps. linux distro based on zig is pretty cool)

@alexrp
Copy link
Member

alexrp commented Jul 18, 2021

I think it's going to be a long while still until zig ld can replace LLD on all target platforms. Wouldn't it make sense to document these until then? The command line interface isn't set in stone until 1.x anyway.

@g-w1
Copy link
Contributor

g-w1 commented Jul 18, 2021

Zig ld != self-hosted linker. You can still shell out to ld.lld in zig ld (as I said).

@alexrp
Copy link
Member

alexrp commented Jul 18, 2021

Oh, sorry, I misunderstood your earlier comments.

Are we sure that a single zig ld interface covers all command line options people might want to use? ld.lld and lld-link have radically different CLIs after all.

@g-w1
Copy link
Contributor

g-w1 commented Jul 18, 2021

From the issue:

some projects may want to use Zig as a drop-in replacement for other linkers.

@andrewrk
Copy link
Member

These are internal, intentionally not part of the publicly documented CLI. Please see #8755

@andrewrk andrewrk closed this Jul 23, 2021
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.

4 participants