authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-10-18 17:48:15-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-10-20 15:45:44-04:00
logd85c0ba08048d3e729d535a6df7d095fb72c6677
treed8da7ea8c644103e397432518d3bf5d3e4599681
parentc8bb44618a9c3c7bfff4a9f672a451fdeda1bb02

compiler_rt: support targets where `c_longdouble` is not a valid type


19 files changed, 33 insertions(+), 21 deletions(-)

lib/compiler_rt.zig+8
......@@ -399,6 +399,14 @@ fn complexAbi(comptime Float: type, comptime float: type) type {
399399 };
400400}
401401
402pub const have_c_longdouble = if (builtin.target.cTypeBitSize(.longdouble)) |bits| switch (bits) {
403 else => true,
404 80 => switch (std.zig.target.compilerRtFloatAbi(&builtin.target, bits)) {
405 .soft => false,
406 .hard => true,
407 },
408} else false;
409
402410pub fn Complex(comptime Float: type) type {
403411 return struct { real: Float, imag: Float };
404412}
lib/compiler_rt/cos.zig+4-2
......@@ -25,8 +25,10 @@ comptime {
2525 symbol(&cos, "cos");
2626 symbol(&__cosx, "__cosx");
2727 symbol(&cosq, "cosf128");
28 symbol(&cosl, "cosl");
29 symbol(&cosl, "__cosl"); // required by musl
28 if (compiler_rt.have_c_longdouble) {
29 symbol(&cosl, "cosl");
30 symbol(&cosl, "__cosl"); // required by musl
31 }
3032}
3133
3234fn __cosh(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/exp.zig+1-1
......@@ -22,7 +22,7 @@ comptime {
2222 symbol(&exp, "exp");
2323 symbol(&__expx, "__expx");
2424 symbol(&expq, "expf128");
25 symbol(&expl, "expl");
25 if (compiler_rt.have_c_longdouble) symbol(&expl, "expl");
2626}
2727
2828fn __exph(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/exp2.zig+1-1
......@@ -20,7 +20,7 @@ comptime {
2020 symbol(&exp2, "exp2");
2121 symbol(&__exp2x, "__exp2x");
2222 symbol(&exp2q, "exp2f128");
23 symbol(&exp2l, "exp2l");
23 if (compiler_rt.have_c_longdouble) symbol(&exp2l, "exp2l");
2424}
2525
2626fn __exp2h(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/fabs.zig+1-1
......@@ -10,7 +10,7 @@ comptime {
1010 symbol(&fabs, "fabs");
1111 symbol(&__fabsx, "__fabsx");
1212 symbol(&fabsq, "fabsf128");
13 symbol(&fabsl, "fabsl");
13 if (compiler_rt.have_c_longdouble) symbol(&fabsl, "fabsl");
1414}
1515
1616fn __fabsh(a: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/floor_ceil.zig+2-2
......@@ -24,7 +24,7 @@ comptime {
2424 symbol(&floor, "floor");
2525 symbol(&__floorx, "__floorx");
2626 symbol(&floorq, "floorf128");
27 symbol(&floorl, "floorl");
27 if (compiler_rt.have_c_longdouble) symbol(&floorl, "floorl");
2828
2929 // ceil
3030 symbol(&__ceilh, "__ceilh");
......@@ -32,7 +32,7 @@ comptime {
3232 symbol(&ceil, "ceil");
3333 symbol(&__ceilx, "__ceilx");
3434 symbol(&ceilq, "ceilf128");
35 symbol(&ceill, "ceill");
35 if (compiler_rt.have_c_longdouble) symbol(&ceill, "ceill");
3636}
3737
3838fn __floorh(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/fma.zig+1-1
......@@ -18,7 +18,7 @@ comptime {
1818 symbol(&fma, "fma");
1919 symbol(&__fmax, "__fmax");
2020 symbol(&fmaq, "fmaf128");
21 symbol(&fmal, "fmal");
21 if (compiler_rt.have_c_longdouble) symbol(&fmal, "fmal");
2222}
2323
2424fn __fmah(x: compiler_rt.f16.Abi, y: compiler_rt.f16.Abi, z: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/fmax.zig+1-1
......@@ -11,7 +11,7 @@ comptime {
1111 symbol(&fmax, "fmax");
1212 symbol(&__fmaxx, "__fmaxx");
1313 symbol(&fmaxq, "fmaxf128");
14 symbol(&fmaxl, "fmaxl");
14 if (compiler_rt.have_c_longdouble) symbol(&fmaxl, "fmaxl");
1515}
1616
1717fn __fmaxh(x: compiler_rt.f16.Abi, y: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/fmin.zig+1-1
......@@ -11,7 +11,7 @@ comptime {
1111 symbol(&fmin, "fmin");
1212 symbol(&__fminx, "__fminx");
1313 symbol(&fminq, "fminf128");
14 symbol(&fminl, "fminl");
14 if (compiler_rt.have_c_longdouble) symbol(&fminl, "fminl");
1515}
1616
1717fn __fminh(x: compiler_rt.f16.Abi, y: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/fmod.zig+1-1
......@@ -13,7 +13,7 @@ comptime {
1313 symbol(&fmod, "fmod");
1414 symbol(&__fmodx, "__fmodx");
1515 symbol(&fmodq, "fmodf128");
16 symbol(&fmodl, "fmodl");
16 if (compiler_rt.have_c_longdouble) symbol(&fmodl, "fmodl");
1717}
1818
1919fn __fmodh(a: compiler_rt.f16.Abi, b: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/log.zig+1-1
......@@ -19,7 +19,7 @@ comptime {
1919 symbol(&log, "log");
2020 symbol(&__logx, "__logx");
2121 symbol(&logq, "logf128");
22 symbol(&logl, "logl");
22 if (compiler_rt.have_c_longdouble) symbol(&logl, "logl");
2323}
2424
2525fn __logh(a: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/log10.zig+1-1
......@@ -19,7 +19,7 @@ comptime {
1919 symbol(&log10, "log10");
2020 symbol(&__log10x, "__log10x");
2121 symbol(&log10q, "log10f128");
22 symbol(&log10l, "log10l");
22 if (compiler_rt.have_c_longdouble) symbol(&log10l, "log10l");
2323}
2424
2525fn __log10h(a: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/log2.zig+1-1
......@@ -20,7 +20,7 @@ comptime {
2020 symbol(&log2, "log2");
2121 symbol(&__log2x, "__log2x");
2222 symbol(&log2q, "log2f128");
23 symbol(&log2l, "log2l");
23 if (compiler_rt.have_c_longdouble) symbol(&log2l, "log2l");
2424}
2525
2626fn __log2h(a: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/round.zig+1-1
......@@ -19,7 +19,7 @@ comptime {
1919 symbol(&round, "round");
2020 symbol(&__roundx, "__roundx");
2121 symbol(&roundq, "roundf128");
22 symbol(&roundl, "roundl");
22 if (compiler_rt.have_c_longdouble) symbol(&roundl, "roundl");
2323}
2424
2525fn __roundh(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/sin.zig+4-2
......@@ -25,8 +25,10 @@ comptime {
2525 symbol(&sin, "sin");
2626 symbol(&__sinx, "__sinx");
2727 symbol(&sinq, "sinf128");
28 symbol(&sinl, "sinl");
29 symbol(&sinl, "__sinl"); // required by musl
28 if (compiler_rt.have_c_longdouble) {
29 symbol(&sinl, "sinl");
30 symbol(&sinl, "__sinl"); // required by musl
31 }
3032}
3133
3234fn __sinh(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/sincos.zig+1-1
......@@ -19,7 +19,7 @@ comptime {
1919 symbol(&sincos, "sincos");
2020 symbol(&sincosx, "__sincosx");
2121 symbol(&sincosq, "sincosf128");
22 symbol(&sincosl, "sincosl");
22 if (compiler_rt.have_c_longdouble) symbol(&sincosl, "sincosl");
2323}
2424
2525fn sincosh(x: compiler_rt.f16.Abi, r_sin: *compiler_rt.f16.Abi, r_cos: *compiler_rt.f16.Abi) callconv(.c) void {
lib/compiler_rt/sqrt.zig+1-1
......@@ -23,7 +23,7 @@ comptime {
2323 } else if (compiler_rt.want_sparc32_abi) {
2424 symbol(&sqrtq, "_Q_sqrt");
2525 }
26 symbol(&sqrtl, "sqrtl");
26 if (compiler_rt.have_c_longdouble) symbol(&sqrtl, "sqrtl");
2727}
2828
2929fn __sqrth(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/tan.zig+1-1
......@@ -29,7 +29,7 @@ comptime {
2929 symbol(&tan, "tan");
3030 symbol(&__tanx, "__tanx");
3131 symbol(&tanq, "tanf128");
32 symbol(&tanl, "tanl");
32 if (compiler_rt.have_c_longdouble) symbol(&tanl, "tanl");
3333}
3434
3535fn __tanh(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {
lib/compiler_rt/trunc.zig+1-1
......@@ -18,7 +18,7 @@ comptime {
1818 symbol(&trunc, "trunc");
1919 symbol(&__truncx, "__truncx");
2020 symbol(&truncq, "truncf128");
21 symbol(&truncl, "truncl");
21 if (compiler_rt.have_c_longdouble) symbol(&truncl, "truncl");
2222}
2323
2424fn __trunch(x: compiler_rt.f16.Abi) callconv(.c) compiler_rt.f16.Abi {