aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCody Tapscott <topolarity@tapscott.me>2022-07-28 22:16:59 -0700
committerCody Tapscott <cody+topolarity@tapscott.me>2022-07-29 09:44:45 -0700
commit58540f968a2ae53b4b1ff5a917fdb404088a222a (patch)
tree12787c37ee965e2bbed7ea51fec0f747bdf42962 /src
parentf1feb1369b128fb515a369b1144574b4c1b53b6e (diff)
downloadzig-58540f968a2ae53b4b1ff5a917fdb404088a222a.tar.gz
zig-58540f968a2ae53b4b1ff5a917fdb404088a222a.zip
ELF: Scan for dylibs-as-objects when adding rpaths
Shared libraries can be provided on the command line as if they were objects, as a path to the ".so" file. The "each-lib-rpath" functionality was ignoring these shared libraries accidentally, causing missing rpaths in the output executable.
Diffstat (limited to 'src')
-rw-r--r--src/link/Elf.zig9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index 3e9b1ab3ed..917e4c18d1 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -1592,6 +1592,15 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
}
}
}
+ for (self.base.options.objects) |obj| {
+ if (Compilation.classifyFileExt(obj.path) == .shared_library) {
+ const lib_dir_path = std.fs.path.dirname(obj.path).?;
+ if ((try rpath_table.fetchPut(lib_dir_path, {})) == null) {
+ try argv.append("-rpath");
+ try argv.append(lib_dir_path);
+ }
+ }
+ }
}
for (self.base.options.lib_dirs) |lib_dir| {