| ... | @@ -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 fall | 633 | // 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 => { |