mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
stage3 bsd: support dynamic libstdc++/libc++
Currently llvm-linkage mode (static vs dynamic) decides linkage mode for system libstdc++/libc++ . A previous commit only tested static mode for *BSD and netbsd was reported to not work in dynamic mode. We now special-case freebsd, openbsd, netbsd and dragonfly for dynamic linking too.
This commit is contained in:
parent
6bb82dad43
commit
da96e7efcc
31
build.zig
31
build.zig
@ -589,14 +589,11 @@ fn addCmakeCfgOptionsToExe(
|
|||||||
if (use_zig_libcxx) {
|
if (use_zig_libcxx) {
|
||||||
exe.linkLibCpp();
|
exe.linkLibCpp();
|
||||||
} else {
|
} else {
|
||||||
const need_cpp_includes = true;
|
|
||||||
const lib_suffix = switch (cfg.llvm_linkage) {
|
|
||||||
.static => exe.target.staticLibSuffix()[1..],
|
|
||||||
.dynamic => exe.target.dynamicLibSuffix()[1..],
|
|
||||||
};
|
|
||||||
|
|
||||||
// System -lc++ must be used because in this code path we are attempting to link
|
// System -lc++ must be used because in this code path we are attempting to link
|
||||||
// against system-provided LLVM, Clang, LLD.
|
// against system-provided LLVM, Clang, LLD.
|
||||||
|
const need_cpp_includes = true;
|
||||||
|
const static = cfg.llvm_linkage == .static;
|
||||||
|
const lib_suffix = if (static) exe.target.staticLibSuffix()[1..] else exe.target.dynamicLibSuffix()[1..];
|
||||||
switch (exe.target.getOsTag()) {
|
switch (exe.target.getOsTag()) {
|
||||||
.linux => {
|
.linux => {
|
||||||
// First we try to link against gcc libstdc++. If that doesn't work, we fall
|
// First we try to link against gcc libstdc++. If that doesn't work, we fall
|
||||||
@ -613,20 +610,24 @@ fn addCmakeCfgOptionsToExe(
|
|||||||
exe.linkSystemLibrary("c++");
|
exe.linkSystemLibrary("c++");
|
||||||
},
|
},
|
||||||
.freebsd => {
|
.freebsd => {
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
if (static) {
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
|
} else {
|
||||||
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
.openbsd => {
|
.openbsd => {
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes);
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libc++abi.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
},
|
},
|
||||||
.netbsd => {
|
.netbsd, .dragonfly => {
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
if (static) {
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
},
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
.dragonfly => {
|
} else {
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
try addCxxKnownPath(b, cfg, exe, b.fmt("libstdc++.{s}", .{lib_suffix}), null, need_cpp_includes);
|
||||||
try addCxxKnownPath(b, cfg, exe, b.fmt("libgcc_eh.{s}", .{lib_suffix}), null, need_cpp_includes);
|
}
|
||||||
},
|
},
|
||||||
else => {},
|
else => {},
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user