| ... | ... | @@ -632,16 +632,14 @@ fn addCmakeCfgOptionsToExe( |
| 632 | 632 | const lib_suffix = if (static) exe.target.staticLibSuffix()[1..] else exe.target.dynamicLibSuffix()[1..]; |
| 633 | 633 | switch (exe.target.getOsTag()) { |
| 634 | 634 | .linux => { |
| 635 | | // First we try to link against system libstdc++ or libc++. |
| 636 | | // If that doesn't work, we fall to -lc++ and cross our fingers. |
| 637 | | const found = for ([_][]const u8{ "stdc++", "c++" }) |name| { |
| 638 | | addCxxKnownPath(b, cfg, exe, b.fmt("lib{s}.{s}", .{ name, lib_suffix }), "", need_cpp_includes) catch |err| switch (err) { |
| 639 | | error.RequiredLibraryNotFound => continue, |
| 640 | | else => |e| return e, |
| 641 | | }; |
| 642 | | break true; |
| 643 | | } else false; |
| 644 | | if (!found) exe.linkLibCpp(); |
| 635 | // First we try to link against the detected libcxx name. If that doesn't work, we fall |
| 636 | // back to -lc++ and cross our fingers. |
| 637 | addCxxKnownPath(b, cfg, exe, b.fmt("lib{s}.{s}", .{ cfg.system_libcxx, lib_suffix }), "", need_cpp_includes) catch |err| switch (err) { |
| 638 | error.RequiredLibraryNotFound => { |
| 639 | exe.linkLibCpp(); |
| 640 | }, |
| 641 | else => |e| return e, |
| 642 | }; |
| 645 | 643 | exe.linkSystemLibrary("unwind"); |
| 646 | 644 | }, |
| 647 | 645 | .ios, .macos, .watchos, .tvos => { |
| ... | ... | @@ -775,6 +773,7 @@ const CMakeConfig = struct { |
| 775 | 773 | llvm_include_dir: []const u8, |
| 776 | 774 | llvm_libraries: []const u8, |
| 777 | 775 | dia_guids_lib: []const u8, |
| 776 | system_libcxx: []const u8, |
| 778 | 777 | }; |
| 779 | 778 | |
| 780 | 779 | const max_config_h_bytes = 1 * 1024 * 1024; |
| ... | ... | @@ -840,6 +839,7 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig { |
| 840 | 839 | .llvm_include_dir = undefined, |
| 841 | 840 | .llvm_libraries = undefined, |
| 842 | 841 | .dia_guids_lib = undefined, |
| 842 | .system_libcxx = undefined, |
| 843 | 843 | }; |
| 844 | 844 | |
| 845 | 845 | const mappings = [_]struct { prefix: []const u8, field: []const u8 }{ |
| ... | ... | @@ -891,6 +891,10 @@ fn parseConfigH(b: *std.Build, config_h_text: []const u8) ?CMakeConfig { |
| 891 | 891 | .prefix = "#define ZIG_LLVM_LIB_PATH ", |
| 892 | 892 | .field = "llvm_lib_dir", |
| 893 | 893 | }, |
| 894 | .{ |
| 895 | .prefix = "#define ZIG_SYSTEM_LIBCXX", |
| 896 | .field = "system_libcxx", |
| 897 | }, |
| 894 | 898 | // .prefix = ZIG_LLVM_LINK_MODE parsed manually below |
| 895 | 899 | }; |
| 896 | 900 | |