| ... | @@ -565,13 +565,17 @@ fn addCmakeCfgOptionsToExe( | ... | @@ -565,13 +565,17 @@ fn addCmakeCfgOptionsToExe( |
| 565 | exe.linkLibCpp(); | 565 | exe.linkLibCpp(); |
| 566 | } else { | 566 | } else { |
| 567 | const need_cpp_includes = true; | 567 | const need_cpp_includes = true; |
| | 568 | const lib_suffix = switch (cfg.llvm_linkage) { |
| | 569 | .static => exe.target.staticLibSuffix()[1..], |
| | 570 | .dynamic => exe.target.dynamicLibSuffix()[1..], |
| | 571 | }; |
| 568 | | 572 | |
| 569 | // System -lc++ must be used because in this code path we are attempting to link | 573 | // System -lc++ must be used because in this code path we are attempting to link |
| 570 | // against system-provided LLVM, Clang, LLD. | 574 | // against system-provided LLVM, Clang, LLD. |
| 571 | if (exe.target.getOsTag() == .linux) { | 575 | if (exe.target.getOsTag() == .linux) { |
| 572 | // First we try to static link against gcc libstdc++. If that doesn't work, | 576 | // First we try to link against gcc libstdc++. If that doesn't work, we fall |
| 573 | // we fall back to -lc++ and cross our fingers. | 577 | // back to -lc++ and cross our fingers. |
| 574 | addCxxKnownPath(b, cfg, exe, "libstdc++.a", "", need_cpp_includes) catch |err| switch (err) { | 578 | addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), "", need_cpp_includes) catch |err| switch (err) { |
| 575 | error.RequiredLibraryNotFound => { | 579 | error.RequiredLibraryNotFound => { |
| 576 | exe.linkSystemLibrary("c++"); | 580 | exe.linkSystemLibrary("c++"); |
| 577 | }, | 581 | }, |
| ... | @@ -579,11 +583,11 @@ fn addCmakeCfgOptionsToExe( | ... | @@ -579,11 +583,11 @@ fn addCmakeCfgOptionsToExe( |
| 579 | }; | 583 | }; |
| 580 | exe.linkSystemLibrary("unwind"); | 584 | exe.linkSystemLibrary("unwind"); |
| 581 | } else if (exe.target.isFreeBSD()) { | 585 | } else if (exe.target.isFreeBSD()) { |
| 582 | try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); | 586 | try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes); |
| 583 | exe.linkSystemLibrary("pthread"); | 587 | exe.linkSystemLibrary("pthread"); |
| 584 | } else if (exe.target.getOsTag() == .openbsd) { | 588 | } else if (exe.target.getOsTag() == .openbsd) { |
| 585 | try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes); | 589 | try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes); |
| 586 | try addCxxKnownPath(b, cfg, exe, "libc++abi.a", null, need_cpp_includes); | 590 | try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes); |
| 587 | } else if (exe.target.isDarwin()) { | 591 | } else if (exe.target.isDarwin()) { |
| 588 | exe.linkSystemLibrary("c++"); | 592 | exe.linkSystemLibrary("c++"); |
| 589 | } | 593 | } |