diff options
| author | Isaac Freund <ifreund@ifreund.xyz> | 2021-06-21 22:45:43 +0200 |
|---|---|---|
| committer | Isaac Freund <ifreund@ifreund.xyz> | 2021-06-25 19:13:43 +0200 |
| commit | 260c5aed86d662d2e2bd03c06d123bef9455053d (patch) | |
| tree | 9bbf9bcbce9447ecacb5e92b969d0565fb4cce53 /src/link/Elf.zig | |
| parent | 411f9c60b1cb30aec8706ffac75992ac8cc59cba (diff) | |
| download | zig-260c5aed86d662d2e2bd03c06d123bef9455053d.tar.gz zig-260c5aed86d662d2e2bd03c06d123bef9455053d.zip | |
stage2: add --sysroot link option
This feature is necessary for cross-compiling code that dynamically
links system libraries, at least with the current feature set of lld.
Diffstat (limited to 'src/link/Elf.zig')
| -rw-r--r-- | src/link/Elf.zig | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 6f839c7694..722077b8b8 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1354,6 +1354,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { man.hash.add(allow_shlib_undefined); man.hash.add(self.base.options.bind_global_refs_locally); man.hash.add(self.base.options.tsan); + man.hash.addOptionalBytes(self.base.options.sysroot); // We don't actually care whether it's a cache hit or miss; we just need the digest and the lock. _ = try man.hit(); @@ -1423,6 +1424,10 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { try argv.append("-error-limit=0"); + if (self.base.options.sysroot) |sysroot| { + try argv.append(try std.fmt.allocPrint(arena, "--sysroot={s}", .{sysroot})); + } + if (self.base.options.lto) { switch (self.base.options.optimize_mode) { .Debug => {}, |
