Linker: -z<arg> should be equivalent to -z <arg> (#14680)

lld accepts both syntaxes, but we were rejecting (and, before
3f7e9ff597a3514bb1c4f1900027c40682ac9f13, ignoring) the former.

In particular, "cargo-zigbuild" was broken since Rust
unconditionally adds "-znoexecstack" (not "-z noexecstack")
on non-Windows platforms.

Co-authored-by: Andrew Kelley <andrew@ziglang.org>
This commit is contained in:
Frank Denis 2023-02-20 17:15:21 +01:00 committed by GitHub
parent 99c11cc8cf
commit 5a7d80a5e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1955,12 +1955,15 @@ fn buildOutputType(
linker_compress_debug_sections = std.meta.stringToEnum(link.CompressDebugSections, arg1) orelse {
fatal("expected [none|zlib] after --compress-debug-sections, found '{s}'", .{arg1});
};
} else if (mem.eql(u8, arg, "-z")) {
i += 1;
if (i >= linker_args.items.len) {
fatal("expected linker extension flag after '{s}'", .{arg});
} else if (mem.startsWith(u8, arg, "-z")) {
var z_arg = arg[2..];
if (z_arg.len == 0) {
i += 1;
if (i >= linker_args.items.len) {
fatal("expected linker extension flag after '{s}'", .{arg});
}
z_arg = linker_args.items[i];
}
const z_arg = linker_args.items[i];
if (mem.eql(u8, z_arg, "nodelete")) {
linker_z_nodelete = true;
} else if (mem.eql(u8, z_arg, "notext")) {