mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
linux: search for system libc++
When linking system llvm/clang/lld, add system libc++ to the searchlist. This is needed for certain distros (eg. chimera linux). closes #16754
This commit is contained in:
parent
9f88b3ae89
commit
6ef836bfff
1 changed files with 10 additions and 8 deletions
18
build.zig
18
build.zig
|
|
@ -630,14 +630,16 @@ fn addCmakeCfgOptionsToExe(
|
||||||
const lib_suffix = if (static) exe.target.staticLibSuffix()[1..] else exe.target.dynamicLibSuffix()[1..];
|
const lib_suffix = if (static) exe.target.staticLibSuffix()[1..] else exe.target.dynamicLibSuffix()[1..];
|
||||||
switch (exe.target.getOsTag()) {
|
switch (exe.target.getOsTag()) {
|
||||||
.linux => {
|
.linux => {
|
||||||
// First we try to link against gcc libstdc++. If that doesn't work, we fall
|
// First we try to link against system libstdc++ or libc++.
|
||||||
// back to -lc++ and cross our fingers.
|
// If that doesn't work, we fall to -lc++ and cross our fingers.
|
||||||
addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), "", need_cpp_includes) catch |err| switch (err) {
|
const found = for ([_][]const u8{ "stdc++", "c++" }) |name| {
|
||||||
error.RequiredLibraryNotFound => {
|
addCxxKnownPath(b, cfg, exe, b.fmt("lib{s}.{s}", .{ name, lib_suffix }), "", need_cpp_includes) catch |err| switch (err) {
|
||||||
exe.linkLibCpp();
|
error.RequiredLibraryNotFound => continue,
|
||||||
},
|
else => |e| return e,
|
||||||
else => |e| return e,
|
};
|
||||||
};
|
break true;
|
||||||
|
} else false;
|
||||||
|
if (!found) exe.linkLibCpp();
|
||||||
exe.linkSystemLibrary("unwind");
|
exe.linkSystemLibrary("unwind");
|
||||||
},
|
},
|
||||||
.ios, .macos, .watchos, .tvos => {
|
.ios, .macos, .watchos, .tvos => {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue