diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-01-26 14:59:15 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-01-26 15:01:59 -0700 |
| commit | 40c9ce2caf8f024a249b3524813eb495cf1341b3 (patch) | |
| tree | 84dd4cfca306b33956746650155dd14d4e4fafac /src/link | |
| parent | 35503b3d3fe1bfce19f1ea3e78a75ce87b0ed646 (diff) | |
| download | zig-40c9ce2caf8f024a249b3524813eb495cf1341b3.tar.gz zig-40c9ce2caf8f024a249b3524813eb495cf1341b3.zip | |
zig cc: add --hash-style linker parameter
This is only relevant for ELF files.
I also fixed a bug where passing a zig source file to `zig cc` would
incorrectly punt to clang because it thought there were no positional
arguments.
Diffstat (limited to 'src/link')
| -rw-r--r-- | src/link/Coff.zig | 2 | ||||
| -rw-r--r-- | src/link/Elf.zig | 9 | ||||
| -rw-r--r-- | src/link/MachO.zig | 2 | ||||
| -rw-r--r-- | src/link/Wasm.zig | 2 |
4 files changed, 11 insertions, 4 deletions
diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 20a76f49a2..152e078b66 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -941,7 +941,7 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { man = comp.cache_parent.obtain(); self.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 1); + comptime assert(Compilation.link_hash_implementation_version == 2); for (self.base.options.objects) |obj| { _ = try man.addFile(obj.path, null); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 15fff6db79..8a9d98189a 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1413,7 +1413,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { // We are about to obtain this lock, so here we give other processes a chance first. self.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 1); + comptime assert(Compilation.link_hash_implementation_version == 2); try man.addOptionalFile(self.base.options.linker_script); try man.addOptionalFile(self.base.options.version_script); @@ -1447,6 +1447,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { man.hash.add(self.base.options.z_noexecstack); man.hash.add(self.base.options.z_now); man.hash.add(self.base.options.z_relro); + man.hash.add(self.base.options.hash_style); // strip does not need to go into the linker hash because it is part of the hash namespace if (self.base.options.link_libc) { man.hash.add(self.base.options.libc_installation != null); @@ -1558,6 +1559,12 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { try argv.append(entry); } + switch (self.base.options.hash_style) { + .gnu => try argv.append("--hash-style=gnu"), + .sysv => try argv.append("--hash-style=sysv"), + .both => {}, // this is the default + } + if (self.base.options.output_mode == .Exe) { try argv.append("-z"); try argv.append(try std.fmt.allocPrint(arena, "stack-size={d}", .{stack_size})); diff --git a/src/link/MachO.zig b/src/link/MachO.zig index cd1d197010..a9950fcc8d 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -497,7 +497,7 @@ pub fn flushModule(self: *MachO, comp: *Compilation) !void { // We are about to obtain this lock, so here we give other processes a chance first. self.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 1); + comptime assert(Compilation.link_hash_implementation_version == 2); for (self.base.options.objects) |obj| { _ = try man.addFile(obj.path, null); diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index 9a9c6c464c..7d01ef4083 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -1203,7 +1203,7 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { // We are about to obtain this lock, so here we give other processes a chance first. self.base.releaseLock(); - comptime assert(Compilation.link_hash_implementation_version == 1); + comptime assert(Compilation.link_hash_implementation_version == 2); for (self.base.options.objects) |obj| { _ = try man.addFile(obj.path, null); |
