diff --git a/build.zig b/build.zig index 7de4f5070..6a41e6ef6 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, } }