@@ -556,14 +556,11 @@ fn addCmakeCfgOptionsToExe(
556
556
if (use_zig_libcxx ) {
557
557
exe .linkLibCpp ();
558
558
} else {
559
- const need_cpp_includes = true ;
560
- const lib_suffix = switch (cfg .llvm_linkage ) {
561
- .static = > exe .target .staticLibSuffix ()[1.. ],
562
- .dynamic = > exe .target .dynamicLibSuffix ()[1.. ],
563
- };
564
-
565
559
// System -lc++ must be used because in this code path we are attempting to link
566
560
// against system-provided LLVM, Clang, LLD.
561
+ const need_cpp_includes = true ;
562
+ const static = cfg .llvm_linkage == .static ;
563
+ const lib_suffix = if (static ) exe .target .staticLibSuffix ()[1.. ] else exe .target .dynamicLibSuffix ()[1.. ];
567
564
switch (exe .target .getOsTag ()) {
568
565
.linux = > {
569
566
// First we try to link against gcc libstdc++. If that doesn't work, we fall
@@ -580,20 +577,24 @@ fn addCmakeCfgOptionsToExe(
580
577
exe .linkSystemLibrary ("c++" );
581
578
},
582
579
.freebsd = > {
583
- try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
584
- try addCxxKnownPath (b , cfg , exe , b .fmt ("libgcc_eh.{s}" , .{lib_suffix }), null , need_cpp_includes );
580
+ if (static ) {
581
+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
582
+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libgcc_eh.{s}" , .{lib_suffix }), null , need_cpp_includes );
583
+ } else {
584
+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
585
+ }
585
586
},
586
587
.openbsd = > {
587
588
try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
588
589
try addCxxKnownPath (b , cfg , exe , b .fmt ("libc++abi.{s}" , .{lib_suffix }), null , need_cpp_includes );
589
590
},
590
- .netbsd = > {
591
- try addCxxKnownPath ( b , cfg , exe , b . fmt ( "libstdc++.{s}" , .{ lib_suffix }), null , need_cpp_includes );
592
- try addCxxKnownPath (b , cfg , exe , b .fmt ("libgcc_eh .{s}" , .{lib_suffix }), null , need_cpp_includes );
593
- },
594
- .dragonfly = > {
595
- try addCxxKnownPath (b , cfg , exe , b .fmt ("libstdc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
596
- try addCxxKnownPath ( b , cfg , exe , b . fmt ( "libgcc_eh.{s}" , .{ lib_suffix }), null , need_cpp_includes );
591
+ .netbsd , .dragonfly = > {
592
+ if ( static ) {
593
+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libstdc++ .{s}" , .{lib_suffix }), null , need_cpp_includes );
594
+ try addCxxKnownPath ( b , cfg , exe , b . fmt ( "libgcc_eh.{s}" , .{ lib_suffix }), null , need_cpp_includes );
595
+ } else {
596
+ try addCxxKnownPath (b , cfg , exe , b .fmt ("libstdc++.{s}" , .{lib_suffix }), null , need_cpp_includes );
597
+ }
597
598
},
598
599
else = > {},
599
600
}
0 commit comments