From 28c05b0a53e451cbe06d321f4e2f92cf3b1a7be4 Mon Sep 17 00:00:00 2001 From: Cody Tapscott Date: Mon, 25 Apr 2022 17:49:56 -0700 Subject: [PATCH] compiler_rt: Bypass `fmodx` impl. on stage2 This function is codegen'd incorrectly in stage2, since it fails to generate the correct soft-float operations. This will be fixed once issue #11161 is implemented --- lib/std/special/compiler_rt.zig | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/std/special/compiler_rt.zig b/lib/std/special/compiler_rt.zig index 6a44d859c9..93e0ffbe1a 100644 --- a/lib/std/special/compiler_rt.zig +++ b/lib/std/special/compiler_rt.zig @@ -731,8 +731,13 @@ comptime { @export(fmodx, .{ .name = "fmodl", .linkage = linkage }); } else if (long_double_is_f128) { @export(fmodq, .{ .name = "fmodl", .linkage = linkage }); + } else { + @export(fmodl, .{ .name = "fmodl", .linkage = linkage }); + } + if (long_double_is_f80 or builtin.zig_backend == .stage1) { + // TODO: https://github.com/ziglang/zig/issues/11161 + @export(fmodx, .{ .name = "fmodx", .linkage = linkage }); } - @export(fmodx, .{ .name = "fmodx", .linkage = linkage }); @export(fmodq, .{ .name = "fmodq", .linkage = linkage }); @export(floorf, .{ .name = "floorf", .linkage = linkage }); @@ -889,6 +894,12 @@ fn ceill(x: c_longdouble) callconv(.C) c_longdouble { const fmodq = @import("compiler_rt/fmodq.zig").fmodq; const fmodx = @import("compiler_rt/fmodx.zig").fmodx; +fn fmodl(x: c_longdouble, y: c_longdouble) callconv(.C) c_longdouble { + if (!long_double_is_f128) { + @panic("TODO implement this"); + } + return @floatCast(c_longdouble, fmodq(x, y)); +} // Avoid dragging in the runtime safety mechanisms into this .o file, // unless we're trying to test this file.