zig/test/link
Isaac Freund 819716b59f
link: fix ambiguous names in linker scripts
Currently zig fails to build while linking the system LLVM/C++ libraries
on my Chimera Linux system due to the fact that libc++.so is a linker
script with the following contents:

INPUT(libc++.so.1 -lc++abi -lunwind)

Prior to this commit, zig would try to convert "ambiguous names" in
linker scripts such as libc++.so.1 in this example into -lfoo style
flags. This fails in this case due to the so version number as zig
checks for exactly the .so suffix.

Furthermore, I do not think that this conversion is semantically correct
since converting libfoo.so to -lfoo could theoretically end up resulting
in libfoo.a getting linked which seems wrong when a different file is
specified in the linker script.

With this patch, this attempted conversion is removed. Instead, zig
always first checks if the exact file/path in the linker script exists
relative to the current working directory.

If the file is classified as a library (including versioned shared
objects such as libfoo.so.1), zig then falls back to checking if
the exact file/path in the linker script exists relative to each
directory in the library search path, selecting the first match or
erroring out if none is found.

This behavior fixes the regression that prevents building zig while
linking the system LLVM/C++ libraries on Chimera Linux.
2025-02-10 23:19:48 +01:00
..
bss test-link: migrate from deprecated std.Build APIs 2024-12-18 01:49:10 +05:00
common_symbols std.Build: add addLibrary function (#22554) 2025-01-22 02:29:21 +00:00
common_symbols_alignment std.Build: add addLibrary function (#22554) 2025-01-22 02:29:21 +00:00
glibc_compat test-link: migrate from deprecated std.Build APIs 2024-12-18 01:49:10 +05:00
interdependent_static_c_libs std.Build: add addLibrary function (#22554) 2025-01-22 02:29:21 +00:00
static_libs_from_object_files std.Build: add addLibrary function (#22554) 2025-01-22 02:29:21 +00:00
wasm test/link/wasm/shared-memory: update to better linker behavior 2025-01-15 19:44:20 -08:00
build.zig std: update std.builtin.Type fields to follow naming conventions 2024-08-28 08:39:59 +01:00
build.zig.zon test/link/wasm/segment: delete bad test 2025-01-15 15:11:37 -08:00
elf.zig link: fix ambiguous names in linker scripts 2025-02-10 23:19:48 +01:00
link.zig std.Build: add addLibrary function (#22554) 2025-01-22 02:29:21 +00:00
macho.zig compiler: disallow callconv etc from depending on function parameters 2024-12-18 23:06:35 +00:00