From a424c3a1b01e6a0e01855fb51c52cf29d2437082 Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Sun, 24 Aug 2025 16:24:04 +0300 Subject: [PATCH 1/2] importc: Support math.h on glibc aarch64 Signed-off-by: Andrei Horodniceanu --- druntime/src/__importc_builtins.di | 7 +++++++ druntime/src/importc.h | 8 ++++++++ 2 files changed, 15 insertions(+) diff --git a/druntime/src/__importc_builtins.di b/druntime/src/__importc_builtins.di index 9493962e4689..e1ba54300878 100644 --- a/druntime/src/__importc_builtins.di +++ b/druntime/src/__importc_builtins.di @@ -111,3 +111,10 @@ version (DigitalMars) ulong a, b; } } + +version (CRuntime_Glibc) version (AArch64) +{ + // math.h needs these + alias __Float32x4_t = __vector(float[4]); + alias __Float64x2_t = __vector(double[2]); +} diff --git a/druntime/src/importc.h b/druntime/src/importc.h index 1597a013a73e..f37ac681658e 100644 --- a/druntime/src/importc.h +++ b/druntime/src/importc.h @@ -186,8 +186,16 @@ typedef unsigned long long __uint64_t; #define _Float128 long double #define __float128 long double #endif + +#ifdef __aarch64__ +// glibc's math.h needs these types to be defined +typedef struct {} __SVBool_t; +typedef struct {} __SVFloat32_t; +typedef struct {} __SVFloat64_t; #endif +#endif // __linux__ + #if __APPLE__ #undef __SIZEOF_INT128__ #endif From df078f895bc9d52d655e2f9cb5afca5c8dde05fc Mon Sep 17 00:00:00 2001 From: Andrei Horodniceanu Date: Sun, 24 Aug 2025 16:24:59 +0300 Subject: [PATCH 2/2] compiler/test/compilable/stdcheaders: Reenable math.h on linux aarch64 Signed-off-by: Andrei Horodniceanu --- compiler/test/compilable/stdcheaders.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/compiler/test/compilable/stdcheaders.c b/compiler/test/compilable/stdcheaders.c index 2509fd79d8be..7f0fd7370d68 100644 --- a/compiler/test/compilable/stdcheaders.c +++ b/compiler/test/compilable/stdcheaders.c @@ -19,12 +19,10 @@ #include #include -#if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/bits/math-vector.h(162): Error: undefined identifier `__Float32x4_t` #include #ifndef _MSC_VER // C:\Program Files (x86)\Windows Kits\10\include\10.0.26100.0\ucrt\corecrt_math.h(93): Error: reinterpretation through overlapped field `f` is not allowed in CTFE float x = NAN; #endif -#endif #ifndef _MSC_VER // setjmp.h(51): Error: missing tag `identifier` after `struct #include @@ -64,11 +62,9 @@ float x = NAN; // Apple: /Applications/Xcode-14.2.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/tgmath.h(39): Error: named parameter required before `...` // OpenBSD: /usr/lib/clang/13.0.0/include/tgmath.h(34): Error: named parameter required before `...` // Linux: /tmp/clang/lib/clang/15.0.3/include/tgmath.h(34): Error: named parameter required before `...` -#if !(defined(__linux__) && defined(__aarch64__)) // /usr/include/bits/math-vector.h(162): Error: undefined identifier `__Float32x4_t` #include #endif #endif -#endif #ifndef __linux__ #ifndef __APPLE__