Skip to content

zig: expose linker options and include '-z notext' #10056

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

Merged
merged 1 commit into from
Oct 29, 2021

Conversation

lithdew
Copy link
Contributor

@lithdew lithdew commented Oct 29, 2021

Add an option to allow the '-z notext' option to be passed to the linker via. the compiler frontend, which is a flag that tells the linker that relocations in read-only sections are permitted. Certain targets such as Solana BPF rely on this flag.

Expose all linker options i.e. '-z nodelete', '-z now', '-z relro' in the compiler frontend. Usage documentation has been updated accordingly.

Expose the '-z notext' flag in the standard library build runner.

Add an option to allow the '-z notext' option to be passed to the linker
via. the compiler frontend, which is a flag that tells the linker that
relocations in read-only sections are permitted. Certain targets such as
Solana BPF rely on this flag.

Expose all linker options i.e. '-z nodelete', '-z now', '-z relro' in
the compiler frontend. Usage documentation has been updated accordingly.

Expose the '-z notext' flag in the standard library build runner.
@@ -401,6 +401,14 @@ const usage_build_generic =
\\ -fno-allow-shlib-undefined Disallows undefined symbols in shared libraries
\\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker
\\ --emit-relocs Enable output of relocation sections for post build tools
\\ -z [arg] Append linker arguments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, -z <arg> seems specific to ELF linkers; would it make more sense to expose each flag of interest separately with -fnotext or something similar? Also, we should definitely point out these are ELF-specific. @andrewrk I'd appreciate your look at this too!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-z specifies an extension flag. wasm-ld supports them as well and we actually already make use of it to set the stack size for executables. So if we go with this, perhaps those should be supported too.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\\ -z [arg] Append linker arguments
\\ -z [arg] Set linker extension flags

@@ -401,6 +401,14 @@ const usage_build_generic =
\\ -fno-allow-shlib-undefined Disallows undefined symbols in shared libraries
\\ --eh-frame-hdr Enable C++ exception handling by passing --eh-frame-hdr to linker
\\ --emit-relocs Enable output of relocation sections for post build tools
\\ -z [arg] Append linker arguments
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
\\ -z [arg] Append linker arguments
\\ -z [arg] Set linker extension flags

} else if (mem.eql(u8, arg, "-z")) {
i += 1;
if (i >= args.len) {
fatal("expected linker arg after '{s}'", .{arg});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fatal("expected linker arg after '{s}'", .{arg});
fatal("expected linker extension flag after '{s}'", .{arg});

@andrewrk
Copy link
Member

Damn I was hoping github would let me make these changes before merging

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