Merge pull request #17155 from winterqt/ignore-nix-ldflags-linkage-directives

std.zig.system.NativePaths: ignore linkage directives in `NIX_LDFLAGS`
This commit is contained in:
Andrew Kelley 2024-01-24 00:01:23 -08:00 committed by GitHub
commit 92211135f1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -56,10 +56,17 @@ pub fn detect(arena: Allocator, native_target: std.Target) !NativePaths {
break;
};
try self.addRPath(rpath);
} else if (word.len > 2 and word[0] == '-' and word[1] == 'L') {
} else if (mem.eql(u8, word, "-L") or mem.eql(u8, word, "-l")) {
_ = it.next() orelse {
try self.addWarning("Expected argument after -L or -l in NIX_LDFLAGS");
break;
};
} else if (mem.startsWith(u8, word, "-L")) {
const lib_path = word[2..];
try self.addLibDir(lib_path);
try self.addRPath(lib_path);
} else if (mem.startsWith(u8, word, "-l")) {
// Ignore this argument.
} else {
try self.addWarningFmt("Unrecognized C flag from NIX_LDFLAGS: {s}", .{word});
break;