authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-08-09 22:27:35-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-29 14:28:32-07:00
log6ef836bfffd90abec9768a69ecdf727745979167
tree23c53911e723e9ab2d0ce25e2398ad312dd70abb
parent9f88b3ae891956e6f887f579ad4b32e83cb06ee2

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

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

build.zig+10-8
...@@ -630,14 +630,16 @@ fn addCmakeCfgOptionsToExe(...@@ -630,14 +630,16 @@ fn addCmakeCfgOptionsToExe(
630 const lib_suffix = if (static) exe.target.staticLibSuffix()[1..] else exe.target.dynamicLibSuffix()[1..];630 const lib_suffix = if (static) exe.target.staticLibSuffix()[1..] else exe.target.dynamicLibSuffix()[1..];
631 switch (exe.target.getOsTag()) {631 switch (exe.target.getOsTag()) {
632 .linux => {632 .linux => {
633 // First we try to link against gcc libstdc++. If that doesn't work, we fall633 // First we try to link against system libstdc++ or libc++.
634 // back to -lc++ and cross our fingers.634 // If that doesn't work, we fall to -lc++ and cross our fingers.
635 addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), "", need_cpp_includes) catch |err| switch (err) {635 const found = for ([_][]const u8{ "stdc++", "c++" }) |name| {
636 error.RequiredLibraryNotFound => {636 addCxxKnownPath(b, cfg, exe, b.fmt("lib{s}.{s}", .{ name, lib_suffix }), "", need_cpp_includes) catch |err| switch (err) {
637 exe.linkLibCpp();637 error.RequiredLibraryNotFound => continue,
638 },638 else => |e| return e,
639 else => |e| return e,639 };
640 };640 break true;
641 } else false;
642 if (!found) exe.linkLibCpp();
641 exe.linkSystemLibrary("unwind");643 exe.linkSystemLibrary("unwind");
642 },644 },
643 .ios, .macos, .watchos, .tvos => {645 .ios, .macos, .watchos, .tvos => {