authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-23 18:01:59-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-23 18:01:59-07:00
logf37513aa68ab128961ef797f83da1a0f9d9673f1
treed7b02e226ebb31c99e29cccc1496caf210594ba0
parent6f3ee587ba5ad82178e9fe8a8d788729a3e18d6b

NativePaths: support -L and -l arguments in NIX_LDFLAGS

A slightly more robust parsing of these flags in case of a separate argument appearing after "-L" in the flags.

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

lib/std/zig/system/NativePaths.zig+8-3
......@@ -56,12 +56,17 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths {
5656 break;
5757 };
5858 try self.addRPath(rpath);
59 } else if (word.len > 2 and word[0] == '-' and word[1] == 'L') {
59 } else if (mem.eql(u8, word, "-L") or mem.eql(u8, word, "-l")) {
60 _ = it.next() orelse {
61 try self.addWarning("Expected argument after -L or -l in NIX_LDFLAGS");
62 break;
63 };
64 } else if (mem.startsWith(u8, word, "-L")) {
6065 const lib_path = word[2..];
6166 try self.addLibDir(lib_path);
6267 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.
68 } else if (mem.startsWith(u8, word, "-l")) {
69 // Ignore this argument.
6570 } else {
6671 try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
6772 break;