authorgravatar for rganesan@gmail.comGanesan Rajagopal <rganesan@gmail.com> 2022-12-05 16:17:19+05:30
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2023-03-19 17:42:27+01:00
log30aeb41a19d3ac15c89190cd546cbe7c05c60ac8
tree541225ae59e2494310f2da5739498e6c49517179
parent2fce991d2ab1dfc6d591b560607ef0edecc7db19

Fix linker segfault adding rpath to sharedlib

If the shared library is a relative path, dirname will return null causing a segfault. In the case I debugged, the current directory was already in RPATH so just ignoring this case seems a reasonable fix. After this fix "make" and "make test" pass for mimalloc. Closes #13766

1 files changed, 1 insertions(+), 1 deletions(-)

src/link/Elf.zig+1-1
......@@ -1636,7 +1636,7 @@ fn linkWithLLD(self: *Elf, comp: *Compilation, prog_node: *std.Progress.Node) !v
16361636 }
16371637 for (self.base.options.objects) |obj| {
16381638 if (Compilation.classifyFileExt(obj.path) == .shared_library) {
1639 const lib_dir_path = std.fs.path.dirname(obj.path).?;
1639 const lib_dir_path = std.fs.path.dirname(obj.path) orelse continue;
16401640 if ((try rpath_table.fetchPut(lib_dir_path, {})) == null) {
16411641 try argv.append("-rpath");
16421642 try argv.append(lib_dir_path);