authorgravatar for winter@winter.cafeWinter <winter@winter.cafe> 2023-09-14 19:16:34-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-23 17:49:25-07:00
log6f3ee587ba5ad82178e9fe8a8d788729a3e18d6b
treed590cf947467f44072bb90219e77429ae6bf80a2
parent993a83081a975464d1201597cf6f4cb7f6735284

std.zig.system.NativePaths: ignore linkage directives in `NIX_LDFLAGS`

`NIX_LDFLAGS` typically contains just `-rpath` and `-L`, which we already handle. However, at least one setup hook in Nixpkgs [0] adds a linkage directive to it. To prevent library paths from being missed (as I've observed myself with `NIX_LDFLAGS` being `-liconv ...`, making it so that *all* paths are missed), let's just skip over them. [0]: https://github.com/NixOS/nixpkgs/blob/08f615eb1b3c5cf7481996f29c6092c7c891b15b/pkgs/development/libraries/libiconv/setup-hook.sh

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

lib/std/zig/system/NativePaths.zig+2
...@@ -60,6 +60,8 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths {...@@ -60,6 +60,8 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths {
60 const lib_path = word[2..];60 const lib_path = word[2..];
61 try self.addLibDir(lib_path);61 try self.addLibDir(lib_path);
62 try self.addRPath(lib_path);62 try self.addRPath(lib_path);
63 } else if (word.len > 2 and word[0] == '-' and word[1] == 'l') {
64 // There could still be paths after this.
63 } else {65 } else {
64 try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});66 try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
65 break;67 break;