aboutsummaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2020-03-17 23:03:45 -0400
committerAndrew Kelley <andrew@ziglang.org>2020-03-17 23:03:45 -0400
commitdbde5df568597c63e28bb1244d695156afbad5d0 (patch)
tree4046729881ce284aaf4369e03d30bce7fa435911 /build.zig
parent7251eb1681d269ef5672193a608b580e371981fb (diff)
downloadzig-dbde5df568597c63e28bb1244d695156afbad5d0.tar.gz
zig-dbde5df568597c63e28bb1244d695156afbad5d0.zip
clean up some self-hosted bitrot + don't assume libstdc++
closes #4682 The self-hosted compiler is still bit rotted and still not compiling successfully yet. I have a more serious rework of the code in a different branch.
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig14
1 files changed, 9 insertions, 5 deletions
diff --git a/build.zig b/build.zig
index 7de4f50702..6a41e6ef64 100644
--- a/build.zig
+++ b/build.zig
@@ -298,10 +298,14 @@ fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {
dependOnLib(b, exe, ctx.llvm);
if (exe.target.getOsTag() == .linux) {
- try addCxxKnownPath(b, ctx, exe, "libstdc++.a",
- \\Unable to determine path to libstdc++.a
- \\On Fedora, install libstdc++-static and try again.
- );
+ // First we try to static link against gcc libstdc++. If that doesn't work,
+ // we fall back to -lc++ and cross our fingers.
+ addCxxKnownPath(b, ctx, exe, "libstdc++.a", "") catch |err| switch (err) {
+ error.RequiredLibraryNotFound => {
+ exe.linkSystemLibrary("c++");
+ },
+ else => |e| return e,
+ };
exe.linkSystemLibrary("pthread");
} else if (exe.target.isFreeBSD()) {
@@ -320,7 +324,7 @@ fn configureStage2(b: *Builder, exe: var, ctx: Context) !void {
// System compiler, not gcc.
exe.linkSystemLibrary("c++");
},
- else => return err,
+ else => |e| return e,
}
}