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> 2023-08-10 13:22:09-07:00
log901457d173467c71b681a8c69f4b77c94d516da7
treed9709fc9f07a9683b8138215dec066e59df279ba
parentb820d5df79e714b3a3ad3c09480abdafff058de8

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 => {