@@ -573,25 +573,29 @@ fn addCmakeCfgOptionsToExe(
573573 exe .linkLibCpp ();
574574 } else {
575575 const need_cpp_includes = true ;
576+ const lib_suffix = switch (cfg .llvm_linkage ) {
577+ .static = > exe .target .staticLibSuffix ()[1.. ],
578+ .dynamic = > exe .target .dynamicLibSuffix ()[1.. ],
579+ };
576580
577581 // System -lc++ must be used because in this code path we are attempting to link
578582 // against system-provided LLVM, Clang, LLD.
579583 if (exe .target .getOsTag () == .linux ) {
580- // First we try to static link against gcc libstdc++. If that doesn't work,
581- // we fall back to -lc++ and cross our fingers.
582- addCxxKnownPath (b , cfg , exe , "libstdc++.a" , "" , need_cpp_includes ) catch | err | switch (err ) {
584+ // First we try to link against gcc libstdc++. If that doesn't work, we fall
585+ // back to -lc++ and cross our fingers.
586+ addCxxKnownPath (b , cfg , exe , b . fmt ( "libstdc++.{s}" , .{ lib_suffix }) , "" , need_cpp_includes ) catch | err | switch (err ) {
583587 error .RequiredLibraryNotFound = > {
584588 exe .linkSystemLibrary ("c++" );
585589 },
586590 else = > | e | return e ,
587591 };
588592 exe .linkSystemLibrary ("unwind" );
589593 } else if (exe .target .isFreeBSD ()) {
590- try addCxxKnownPath (b , cfg , exe , "libc++.a" , null , need_cpp_includes );
594+ try addCxxKnownPath (b , cfg , exe , b . fmt ( "libc++.{s}" , .{ lib_suffix }) , null , need_cpp_includes );
591595 exe .linkSystemLibrary ("pthread" );
592596 } else if (exe .target .getOsTag () == .openbsd ) {
593- try addCxxKnownPath (b , cfg , exe , "libc++.a" , null , need_cpp_includes );
594- try addCxxKnownPath (b , cfg , exe , "libc++abi.a" , null , need_cpp_includes );
597+ try addCxxKnownPath (b , cfg , exe , b . fmt ( "libc++.{s}" , .{ lib_suffix }) , null , need_cpp_includes );
598+ try addCxxKnownPath (b , cfg , exe , b . fmt ( "libc++abi.{s}" , .{ lib_suffix }) , null , need_cpp_includes );
595599 } else if (exe .target .isDarwin ()) {
596600 exe .linkSystemLibrary ("c++" );
597601 }
0 commit comments