Skip to content
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

Linking with ld/gold/rust-lld: unknown -z value: ,relro,-z,now #52634

Closed
alecmocatta opened this issue Jul 22, 2018 · 2 comments · Fixed by #52654
Closed

Linking with ld/gold/rust-lld: unknown -z value: ,relro,-z,now #52634

alecmocatta opened this issue Jul 22, 2018 · 2 comments · Fixed by #52654

Comments

@alecmocatta
Copy link
Contributor

Compiling with an gcc/ld-like -C linker other than gcc/clang results in the -z,relro,-z,now argument not being recognised.

It seems gcc and clang accept the argument -Wl,-z,relro,-z,now where other ld-like linkers expect -z relro -z now.

working:

"-C linker=gcc"
"-C linker=clang"

not working:

"-C linker=ld -Z linker-flavor=ld"
ld: warning: -z ,relro,-z,now ignored.

"-C linker=gold -Z linker-flavor=ld"
gold: ,relro,-z,now: unknown -z option

"-C linker=rust-lld -Z linker-flavor=ld.lld"
rust-lld: error: unknown -z value: ,relro,-z,now
@alexcrichton
Copy link
Member

Thanks for the report! I believe the bug is here where we actually need to use multiple invocations of linker_arg for each argument rather than packing them all in one. If you're curious, want to test out a patch doing that locally and see if it works for you?

@alecmocatta
Copy link
Contributor Author

I suspected the same. Will PR shortly.

bors added a commit that referenced this issue Jul 25, 2018
Format linker args in a way that works for gcc and ld

Pass multiple linker arguments rather than concatenate with commas (fixes #52634).

`-l library` -> `-llibrary` to work with apple's ld.

To build with apple's ld I'm currently also passing `-C link-args="-arch x86_64 -macosx_version_min 10.13.0"`. I'll try and understand the latter flag better before PRing that.

This PR currently works for me. Hopefully CI will pick up any grievous ramifications in other toolchains?

Thanks to @alexcrichton for the pointer to the relevant code!
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 26, 2018
Format linker args in a way that works for gcc and ld

Pass multiple linker arguments rather than concatenate with commas (fixes rust-lang#52634).

`-l library` -> `-llibrary` to work with apple's ld.

To build with apple's ld I'm currently also passing `-C link-args="-arch x86_64 -macosx_version_min 10.13.0"`. I'll try and understand the latter flag better before PRing that.

This PR currently works for me. Hopefully CI will pick up any grievous ramifications in other toolchains?

Thanks to @alexcrichton for the pointer to the relevant code!
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 a pull request may close this issue.

2 participants