Skip to content

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Jun 24, 2021

These are some -z linker options that are fairly common in C/C++ projects in the wild.

As far as I can tell, this argument parsing code is just used for zig cc/zig c++. Do we want some way to surface these to build-exe/build-lib? noexecstack/relro are common for security, and now has real world usefulness (I once had to use it to due to a really nasty signal handler vs lazy dynamic linking issue - long story...).

@LemonBoy
Copy link
Contributor

Do we want some way to surface these to build-exe/build-lib?

Yep, see #6977.

@alexrp
Copy link
Member Author

alexrp commented Jun 25, 2021

Ok, I can look into adding -z support for the Zig commands in a later PR.

@N00byEdge
Copy link
Contributor

N00byEdge commented Jul 10, 2021

There is also -z max-page-size=0x1000 to set the section alignment, very useful for bare metal development. It would be nice to be able to pass arbitrary string arguments with -z for this kind of a thing, in case you're going to add general -z support

@sreehax
Copy link
Contributor

sreehax commented Jul 11, 2021

Just confirming that it general -z support would also be very good for my use case since I could also really use the max-page-size option. It would also be nice to support it in a LibExeObjStep in the final product, but this seems fairly trivial to me since that would just append to zig_args.

@alexrp
Copy link
Member Author

alexrp commented Jul 11, 2021

That might be interesting to look at in a later PR, but it would probably need some consideration since it kind of partly exposes the underlying linker's command line interface directly as part of zig cc's interface, which may or may not be desirable.

E.g. zig cc itself is always ~equivalent to clang, never clang-cl. That provides a nice and consistent CLI for users regardless of the target platform. That would no longer be the case if -z options were just blindly passed through to the linker, which can be ld.lld, lld-link, etc and therefore produce a warning/error if it doesn't recognize a particular option.

@Vexu Vexu merged commit eb5e4ac into ziglang:master Sep 4, 2021
@alexrp alexrp deleted the linker-z-options branch September 18, 2021 14:27
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.

5 participants