Skip to content

Commit 4f9ed16

Browse files
committed
Dynamically link libc++, if integrating with system LLVM
This ensures that the zigcpp clang driver and LLVM are using the same copy of libc++. See prior commit for more details.
1 parent cecd96b commit 4f9ed16

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

build.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -553,21 +553,21 @@ fn addCmakeCfgOptionsToExe(
553553
// System -lc++ must be used because in this code path we are attempting to link
554554
// against system-provided LLVM, Clang, LLD.
555555
if (exe.target.getOsTag() == .linux) {
556-
// First we try to static link against gcc libstdc++. If that doesn't work,
556+
// First we try to dynamically link against gcc libstdc++. If that doesn't work,
557557
// we fall back to -lc++ and cross our fingers.
558-
addCxxKnownPath(b, cfg, exe, "libstdc++.a", "", need_cpp_includes) catch |err| switch (err) {
558+
addCxxKnownPath(b, cfg, exe, "libstdc++.so", "", need_cpp_includes) catch |err| switch (err) {
559559
error.RequiredLibraryNotFound => {
560560
exe.linkSystemLibrary("c++");
561561
},
562562
else => |e| return e,
563563
};
564564
exe.linkSystemLibrary("unwind");
565565
} else if (exe.target.isFreeBSD()) {
566-
try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes);
566+
try addCxxKnownPath(b, cfg, exe, "libc++.so", null, need_cpp_includes);
567567
exe.linkSystemLibrary("pthread");
568568
} else if (exe.target.getOsTag() == .openbsd) {
569-
try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes);
570-
try addCxxKnownPath(b, cfg, exe, "libc++abi.a", null, need_cpp_includes);
569+
try addCxxKnownPath(b, cfg, exe, "libc++.so", null, need_cpp_includes);
570+
try addCxxKnownPath(b, cfg, exe, "libc++abi.so", null, need_cpp_includes);
571571
} else if (exe.target.isDarwin()) {
572572
exe.linkSystemLibrary("c++");
573573
}

0 commit comments

Comments
 (0)