@@ -593,24 +593,38 @@ fn addCmakeCfgOptionsToExe(
593593
594594 // System -lc++ must be used because in this code path we are attempting to link
595595 // against system-provided LLVM, Clang, LLD.
596- if (exe .target .getOsTag () == .linux ) {
597- // First we try to link against gcc libstdc++. If that doesn't work, we fall
598- // back to -lc++ and cross our fingers.
599- addCxxKnownPath (b , cfg , exe , b .fmt ("libstdc++.{s}" , .{lib_suffix }), "" , need_cpp_includes ) catch | err | switch (err ) {
600- error .RequiredLibraryNotFound = > {
601- exe .linkSystemLibrary ("c++" );
602- },
603- else = > | e | return e ,
604- };
605- exe .linkSystemLibrary ("unwind" );
606- } else if (exe .target .isFreeBSD ()) {
607- try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
608- exe .linkSystemLibrary ("pthread" );
609- } else if (exe .target .getOsTag () == .openbsd ) {
610- try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
611- try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++abi.{s}" , .{lib_suffix }), null , need_cpp_includes );
612- } else if (exe .target .isDarwin ()) {
613- exe .linkSystemLibrary ("c++" );
596+ switch (exe .target .getOsTag ()) {
597+ .linux = > {
598+ // First we try to link against gcc libstdc++. If that doesn't work, we fall
599+ // back to -lc++ and cross our fingers.
600+ addCxxKnownPath (b , cfg , exe , b .fmt ("libstdc++.{s}" , .{lib_suffix }), "" , need_cpp_includes ) catch | err | switch (err ) {
601+ error .RequiredLibraryNotFound = > {
602+ exe .linkSystemLibrary ("c++" );
603+ },
604+ else = > | e | return e ,
605+ };
606+ exe .linkSystemLibrary ("unwind" );
607+ },
608+ .ios , .macos , .watchos , .tvos = > {
609+ exe .linkSystemLibrary ("c++" );
610+ },
611+ .freebsd = > {
612+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
613+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libgcc_eh.{s}" , .{lib_suffix }), null , need_cpp_includes );
614+ },
615+ .openbsd = > {
616+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
617+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++abi.{s}" , .{lib_suffix }), null , need_cpp_includes );
618+ },
619+ .netbsd = > {
620+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libstdc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
621+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libgcc_eh.{s}" , .{lib_suffix }), null , need_cpp_includes );
622+ },
623+ .dragonfly = > {
624+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libstdc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
625+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libgcc_eh.{s}" , .{lib_suffix }), null , need_cpp_includes );
626+ },
627+ else = > {},
614628 }
615629 }
616630
0 commit comments