authorgravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-01-02 19:18:33-05:00
committergravatar for michael.dusan@gmail.comMichael Dusan <michael.dusan@gmail.com> 2023-01-02 19:18:33-05:00
logef08894d377d294c76ab24e941501470eb04b7ac
treed49147e0e8c44157c8a3d1da8ae3a4c87577e07a
parent46c3b091658587fcfddc8faf91da3505db088b6a
signature Commit is signed but in an unrecognized format.

build stage3: add more BSD support

- add netbsd - add dragonfly - fixup freebsd

1 files changed, 32 insertions(+), 18 deletions(-)

build.zig+32-18
......@@ -560,24 +560,38 @@ fn addCmakeCfgOptionsToExe(
560560
561561 // System -lc++ must be used because in this code path we are attempting to link
562562 // against system-provided LLVM, Clang, LLD.
563 if (exe.target.getOsTag() == .linux) {
564 // First we try to link against gcc libstdc++. If that doesn't work, we fall
565 // back to -lc++ and cross our fingers.
566 addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), "", need_cpp_includes) catch |err| switch (err) {
567 error.RequiredLibraryNotFound => {
568 exe.linkSystemLibrary("c++");
569 },
570 else => |e| return e,
571 };
572 exe.linkSystemLibrary("unwind");
573 } else if (exe.target.isFreeBSD()) {
574 try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
575 exe.linkSystemLibrary("pthread");
576 } else if (exe.target.getOsTag() == .openbsd) {
577 try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
578 try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes);
579 } else if (exe.target.isDarwin()) {
580 exe.linkSystemLibrary("c++");
563 switch (exe.target.getOsTag()) {
564 .linux => {
565 // First we try to link against gcc libstdc++. If that doesn't work, we fall
566 // back to -lc++ and cross our fingers.
567 addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), "", need_cpp_includes) catch |err| switch (err) {
568 error.RequiredLibraryNotFound => {
569 exe.linkSystemLibrary("c++");
570 },
571 else => |e| return e,
572 };
573 exe.linkSystemLibrary("unwind");
574 },
575 .ios, .macos, .watchos, .tvos => {
576 exe.linkSystemLibrary("c++");
577 },
578 .freebsd => {
579 try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
580 try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
581 },
582 .openbsd => {
583 try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
584 try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes);
585 },
586 .netbsd => {
587 try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
588 try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
589 },
590 .dragonfly => {
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 else => {},
581595 }
582596 }
583597