Windows-on-ARM-Experiments / mingw-woarm64-build

Workflows and build scripts for Windows on Arm64 GNU cross-compiler for `aarch64-w64-mingw32` target.
GNU General Public License v2.0
31 stars 4 forks source link

Investigate if 'long doubles' should be 64bit #9

Open ZacWalk opened 1 year ago

ZacWalk commented 1 year ago

A long double on aarch64 Linux is 128bit while on Windows it is 64bits in VC and LLVM. Also, there is no support currently in mingw to format 128-bit doubles.

ZacWalk commented 1 year ago

There is a workaround (for 128bit doubles) to format using 80bit code in mingw. Maybe this is good enough for the prototype. Code is here.

ZacWalk commented 11 months ago

I think the basic approach should be to add the define TARGET_LONG_DOUBLE_64=1 in aarch64-coff.h. I tried this but the build failed with various problems, mostly in libfortran. Code below shows my experiment:

image

ZacWalk commented 11 months ago

I have been building up a 128 bit double test sample. This could be extended to also test long doubles are the correct size. https://github.com/ZacWalk/mingw-woarm64-build/blob/main/tests/test-math.c

Blackhex commented 11 months ago

Some resources that describes the problematics:

Blackhex commented 11 months ago

Issue

/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/./gcc/xgcc -B/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/./gcc/ -L/home/blackhex/cross/aarch64-w64-mingw32/lib -L/home/blackhex/cross/mingw/lib -isystem /home/blackhex/cross/aarch64-w64-mingw32/include -isystem /home/blackhex/cross/mingw/include -B/home/blackhex/cross/aarch64-w64-mingw32/bin/ -B/home/blackhex/cross/aarch64-w64-mingw32/lib/ -isystem /home/blackhex/cross/aarch64-w64-mingw32/include -isystem /home/blackhex/cross/aarch64-w64-mingw32/sys-include    -g -O2 -O2 -I../../../../code/gcc-master/libgcc/../winsup/w32api/include -g -O2 -DIN_GCC  -DCROSS_DIRECTORY_STRUCTURE  -W -Wall -Wno-narrowing -Wwrite-strings -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition  -isystem ./include   -g -DIN_LIBGCC2 -fbuilding-libgcc -fno-stack-protector -Dinhibit_libc  -I. -I. -I../.././gcc -I../../../../code/gcc-master/libgcc -I../../../../code/gcc-master/libgcc/. -I../../../../code/gcc-master/libgcc/../gcc -I../../../../code/gcc-master/libgcc/../include -I../../../../code/gcc-master/libgcc/config/libbid -DENABLE_DECIMAL_BID_FORMAT -DHAVE_CC_TLS -DUSE_EMUTLS -Wno-missing-prototypes -Wno-type-limits  -o addtf3.o -MT addtf3.o -MD -MP -MF addtf3.dep  -c ../../../../code/gcc-master/libgcc/soft-fp/addtf3.c 
In file included from ../../../../code/gcc-master/libgcc/soft-fp/addtf3.c:30:
../../../../code/gcc-master/libgcc/soft-fp/quad.h:69:1: error: unable to emulate ‘TF’
   69 | typedef float TFtype __attribute__ ((mode (TF)));
      | ^~~~~~~
make[2]: *** [../../../../code/gcc-master/libgcc/static-object.mk:17: addtf3.o] Error 1
make[2]: Leaving directory '/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/aarch64-w64-mingw32/libgcc'
make[1]: *** [Makefile:14972: all-target-libgcc] Error 2

Solution

--- a/gcc/config/aarch64/aarch64.cc
+++ b/gcc/config/aarch64/aarch64.cc
@@ -27152,10 +27152,12 @@ aarch64_scalar_mode_supported_p (scalar_mode mode)
 {
   if (DECIMAL_FLOAT_MODE_P (mode))
     return default_decimal_float_supported_p ();
-
-  return ((mode == HFmode || mode == BFmode)
-         ? true
-         : default_scalar_mode_supported_p (mode));
+  else if (mode == TFmode)
+    return true;
+  else if (mode == HFmode || mode == BFmode)
+    return true;
+  else
+    return default_scalar_mode_supported_p (mode);
 }

 /* Set the value of FLT_EVAL_METHOD.
Blackhex commented 11 months ago

Issue

libtool: compile:  /home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/./gcc/xgcc -B/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/./gcc/ -L/home/blackhex/cross/aarch64-w64-mingw32/lib -L/home/blackhex/cross/mingw/lib -isystem /home/blackhex/cross/aarch64-w64-mingw32/include -isystem /home/blackhex/cross/mingw/include -B/home/blackhex/cross/aarch64-w64-mingw32/bin/ -B/home/blackhex/cross/aarch64-w64-mingw32/lib/ -isystem /home/blackhex/cross/aarch64-w64-mingw32/include -isystem /home/blackhex/cross/aarch64-w64-mingw32/sys-include -DHAVE_CONFIG_H -I. -I../../../../code/gcc-master/libgfortran -iquote../../../../code/gcc-master/libgfortran/io -I../../../../code/gcc-master/libgfortran/../gcc -I../../../../code/gcc-master/libgfortran/../gcc/config -I../.././gcc -I../../../../code/gcc-master/libgfortran/../libgcc -I../libgcc -I../../../../code/gcc-master/libgfortran/../libbacktrace -I../libbacktrace -I../libbacktrace -std=gnu11 -Wall -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -Wextra -Wwrite-strings -Werror=implicit-function-declaration -Werror=vla -fcx-fortran-rules -ffunction-sections -fdata-sections -g -O2 -MT single.lo -MD -MP -MF .deps/single.Tpo -c ../../../../code/gcc-master/libgfortran/caf/single.c -o single.o
In file included from ./kinds.h:69,
                 from ../../../../code/gcc-master/libgfortran/libgfortran.h:263,
                 from ../../../../code/gcc-master/libgfortran/caf/libcaf.h:32,
                 from ../../../../code/gcc-master/libgfortran/caf/single.c:26:
../../../../code/gcc-master/libgfortran/kinds-override.h:29:3: error: #error "Where has _Float128 gone?"
   29 | # error "Where has _Float128 gone?"
      |   ^~~~~
make[3]: *** [Makefile:2974: single.lo] Error 1
make[3]: Leaving directory '/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/aarch64-w64-mingw32/libgfortran'
make[2]: *** [Makefile:1673: all] Error 2

Solution

Not sure if solution or just a workaround:

--- a/libgfortran/acinclude.m4
+++ b/libgfortran/acinclude.m4
@@ -289,18 +289,11 @@ AC_DEFUN([LIBGFOR_CHECK_FLOAT128], [
     {
       return x * __builtin_huge_valf128 ();
     }
-
-    __float128 baz (__float128 x)
-    {
-      return x * __builtin_huge_valf128 ();
-    }
   ],[
     foo (1.2F128);
     bar (1.2F128);
-    baz (1.2F128);
     foo (1.2Q);
     bar (1.2Q);
-    baz (1.2Q);
   ],[
     libgfor_cv_have_float128=yes
   ],[
Blackhex commented 11 months ago

Issue

configure:30136: checking whether we have a usable _Float128 type
configure:30221: /home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/./gcc/xgcc -B/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/gcc/./gcc/ -L/home/blackhex/cross/aarch64-w64-mingw32/lib -L/home/blackhex/cross/mingw/lib -isystem /home/blackhex/cross/aarch64-w64-mingw32/include -isystem /home/blackhex/cross/mingw/include -B/home/blackhex/cross/aarch64-w64-mingw32/bin/ -B/home/blackhex/cross/aarch64-w64-mingw32/lib/ -isystem /home/blackhex/cross/aarch64-w64-mingw32/include -isystem /home/blackhex/cross/aarch64-w64-mingw32/sys-include    -o conftest.exe -std=gnu11 -g -O2    conftest.c -lm  >&5
/home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o: in function `check_managed_app':
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:290:(.text+0x20): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__mingw_initltsdrot_force' defined in .rdata$.refptr.__mingw_initltsdrot_force[.refptr.__mingw_initltsdrot_force] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:295:(.text+0x28): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__ImageBase' defined in .rdata$.refptr.__ImageBase[.refptr.__ImageBase] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:291:(.text+0x30): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__mingw_initltsdyn_force' defined in .rdata$.refptr.__mingw_initltsdyn_force[.refptr.__mingw_initltsdyn_force] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:292:(.text+0x38): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__mingw_initltssuo_force' defined in .rdata$.refptr.__mingw_initltssuo_force[.refptr.__mingw_initltssuo_force] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o: in function `pre_c_init':
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:109:(.text+0xd4): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__mingw_app_type' defined in .rdata$.refptr.__mingw_app_type[.refptr.__mingw_app_type] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:110:(.text+0xe8): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__set_app_type' defined in .rdata$.refptr.__set_app_type[.refptr.__set_app_type] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:114:(.text+0xf8): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__p__fmode' defined in .rdata$.refptr.__p__fmode[.refptr.__p__fmode] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:114:(.text+0x108): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr._fmode' defined in .rdata$.refptr._fmode[.refptr._fmode] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:115:(.text+0x10c): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr.__p__commode' defined in .rdata$.refptr.__p__commode[.refptr.__p__commode] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:115:(.text+0x124): relocation truncated to fit: IMAGE_REL_ARM64_PAGEOFFSET_12L against symbol `.refptr._commode' defined in .rdata$.refptr._commode[.refptr._commode] section in /home/blackhex/cross/aarch64-w64-mingw32/lib/crt2.o
/home/blackhex/mingw-woarm64-build/build-aarch64-w64-mingw32/mingw/mingw-w64-crt/../../../code/mingw-w64-master/mingw-w64-crt/crt/crtexe.c:120:(.text+0x128): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status
configure:30221: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME "GNU Fortran Runtime Library"
| #define PACKAGE_TARNAME "libgfortran"
| #define PACKAGE_VERSION "0.3"
| #define PACKAGE_STRING "GNU Fortran Runtime Library 0.3"
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL "http://www.gnu.org/software/libgfortran/"
| #define STDC_HEADERS 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_STDLIB_H 1
| #define HAVE_STRING_H 1
| #define HAVE_MEMORY_H 1
| #define HAVE_STRINGS_H 1
| #define HAVE_INTTYPES_H 1
| #define HAVE_STDINT_H 1
| #define HAVE_UNISTD_H 1
| #define __EXTENSIONS__ 1
| #define _ALL_SOURCE 1
| #define _GNU_SOURCE 1
| #define _POSIX_PTHREAD_SEMANTICS 1
| #define _TANDEM_SOURCE 1
| #define LT_OBJDIR ".libs/"
| #define _FILE_OFFSET_BITS 64
| #define HAVE_INTPTR_T 1
| #define HAVE_UINTPTR_T 1
| #define HAVE_PTRDIFF_T 1
| #define HAVE_UNISTD_H 1
| #define HAVE_SYS_TIME_H 1
| #define HAVE_SYS_TYPES_H 1
| #define HAVE_SYS_STAT_H 1
| #define HAVE_IEEEFP_H 1
| #define HAVE_FENV_H 1
| #define HAVE_COMPLEX_H 1
| #define HAVE_MATH_H 1
| #define HAVE_STRUCT_STAT_ST_RDEV 1
| #define HAVE_MKSTEMP 1
| #define HAVE_STRTOLD 1
| #define HAVE_SNPRINTF 1
| #define HAVE_FTRUNCATE 1
| #define HAVE_CHSIZE 1
| #define HAVE_CHDIR 1
| #define HAVE_GETLOGIN 1
| #define HAVE_SLEEP 1
| #define HAVE_ALARM 1
| #define HAVE_ACCESS 1
| #define HAVE_SETMODE 1
| #define HAVE_GETTIMEOFDAY 1
| #define HAVE_STAT 1
| #define HAVE_FSTAT 1
| #define HAVE_VSNPRINTF 1
| #define HAVE_DUP 1
| #define HAVE_GETCWD 1
| #define HAVE_GETPID 1
| #define HAVE_UMASK 1
| #define HAVE_STRNLEN 1
| #define HAVE_LIBM 1
| #define HAVE_ACOSF 1
| #define HAVE_ACOS 1
| #define HAVE_ACOSL 1
| #define HAVE_ACOSHF 1
| #define HAVE_ACOSH 1
| #define HAVE_ACOSHL 1
| #define HAVE_ASINF 1
| #define HAVE_ASIN 1
| #define HAVE_ASINL 1
| #define HAVE_ASINHF 1
| #define HAVE_ASINH 1
| #define HAVE_ASINHL 1
| #define HAVE_ATAN2F 1
| #define HAVE_ATAN2 1
| #define HAVE_ATAN2L 1
| #define HAVE_ATANF 1
| #define HAVE_ATAN 1
| #define HAVE_ATANL 1
| #define HAVE_ATANHF 1
| #define HAVE_ATANH 1
| #define HAVE_ATANHL 1
| #define HAVE_CARGF 1
| #define HAVE_CARG 1
| #define HAVE_CARGL 1
| #define HAVE_CEILF 1
| #define HAVE_CEIL 1
| #define HAVE_CEILL 1
| #define HAVE_COPYSIGNF 1
| #define HAVE_COPYSIGN 1
| #define HAVE_COPYSIGNL 1
| #define HAVE_COSF 1
| #define HAVE_COS 1
| #define HAVE_COSL 1
| #define HAVE_CCOSF 1
| #define HAVE_CCOS 1
| #define HAVE_CCOSL 1
| #define HAVE_COSHF 1
| #define HAVE_COSH 1
| #define HAVE_COSHL 1
| #define HAVE_CCOSHF 1
| #define HAVE_CCOSH 1
| #define HAVE_CCOSHL 1
| #define HAVE_EXPF 1
| #define HAVE_EXP 1
| #define HAVE_EXPL 1
| #define HAVE_CEXPF 1
| #define HAVE_CEXP 1
| #define HAVE_CEXPL 1
| #define HAVE_FABSF 1
| #define HAVE_FABS 1
| #define HAVE_FABSL 1
| #define HAVE_CABSF 1
| #define HAVE_CABS 1
| #define HAVE_CABSL 1
| #define HAVE_FLOORF 1
| #define HAVE_FLOOR 1
| #define HAVE_FLOORL 1
| #define HAVE_FMAF 1
| #define HAVE_FMA 1
| #define HAVE_FMAL 1
| #define HAVE_FMODF 1
| #define HAVE_FMOD 1
| #define HAVE_FMODL 1
| #define HAVE_FREXPF 1
| #define HAVE_FREXP 1
| #define HAVE_FREXPL 1
| #define HAVE_HYPOTF 1
| #define HAVE_HYPOT 1
| #define HAVE_HYPOTL 1
| #define HAVE_LDEXPF 1
| #define HAVE_LDEXP 1
| #define HAVE_LDEXPL 1
| #define HAVE_LOGF 1
| #define HAVE_LOG 1
| #define HAVE_LOGL 1
| #define HAVE_CLOGF 1
| #define HAVE_CLOG 1
| #define HAVE_CLOGL 1
| #define HAVE_LOG10F 1
| #define HAVE_LOG10 1
| #define HAVE_LOG10L 1
| #define HAVE_CLOG10F 1
| #define HAVE_CLOG10 1
| #define HAVE_CLOG10L 1
| #define HAVE_NEXTAFTERF 1
| #define HAVE_NEXTAFTER 1
| #define HAVE_NEXTAFTERL 1
| #define HAVE_POWF 1
| #define HAVE_POW 1
| #define HAVE_CPOWF 1
| #define HAVE_CPOW 1
| #define HAVE_CPOWL 1
| #define HAVE_ROUNDF 1
| #define HAVE_ROUND 1
| #define HAVE_ROUNDL 1
| #define HAVE_LROUNDF 1
| #define HAVE_LROUND 1
| #define HAVE_LROUNDL 1
| #define HAVE_LLROUNDF 1
| #define HAVE_LLROUND 1
| #define HAVE_LLROUNDL 1
| #define HAVE_SCALBNF 1
| #define HAVE_SCALBN 1
| #define HAVE_SCALBNL 1
| #define HAVE_SINF 1
| #define HAVE_SIN 1
| #define HAVE_SINL 1
| #define HAVE_CSINF 1
| #define HAVE_CSIN 1
| #define HAVE_CSINL 1
| #define HAVE_SINHF 1
| #define HAVE_SINH 1
| #define HAVE_SINHL 1
| #define HAVE_CSINHF 1
| #define HAVE_CSINH 1
| #define HAVE_CSINHL 1
| #define HAVE_SQRTF 1
| #define HAVE_SQRT 1
| #define HAVE_SQRTL 1
| #define HAVE_CSQRTF 1
| #define HAVE_CSQRT 1
| #define HAVE_CSQRTL 1
| #define HAVE_TANF 1
| #define HAVE_TAN 1
| #define HAVE_TANL 1
| #define HAVE_CTANF 1
| #define HAVE_CTAN 1
| #define HAVE_CTANL 1
| #define HAVE_TANHF 1
| #define HAVE_TANH 1
| #define HAVE_TANHL 1
| #define HAVE_CTANHF 1
| #define HAVE_CTANH 1
| #define HAVE_CTANHL 1
| #define HAVE_TRUNCF 1
| #define HAVE_TRUNC 1
| #define HAVE_TRUNCL 1
| #define HAVE_ERFF 1
| #define HAVE_ERF 1
| #define HAVE_ERFCF 1
| #define HAVE_ERFC 1
| #define HAVE_ERFCL 1
| #define HAVE_J0 1
| #define HAVE_J1 1
| #define HAVE_JN 1
| #define HAVE_Y0 1
| #define HAVE_Y1 1
| #define HAVE_YN 1
| #define HAVE_TGAMMA 1
| #define HAVE_TGAMMAF 1
| #define HAVE_LGAMMA 1
| #define HAVE_LGAMMAF 1
| #define HAVE_CACOS 1
| #define HAVE_CACOSF 1
| #define HAVE_CACOSH 1
| #define HAVE_CACOSHF 1
| #define HAVE_CACOSHL 1
| #define HAVE_CACOSL 1
| #define HAVE_CASIN 1
| #define HAVE_CASINF 1
| #define HAVE_CASINH 1
| #define HAVE_CASINHF 1
| #define HAVE_CASINHL 1
| #define HAVE_CASINL 1
| #define HAVE_CATAN 1
| #define HAVE_CATANF 1
| #define HAVE_CATANH 1
| #define HAVE_CATANHF 1
| #define HAVE_CATANHL 1
| #define HAVE_CATANL 1
| #define HAVE_MINGW_SNPRINTF 1
| /* end confdefs.h.  */
| 
|     _Float128 foo (_Float128 x)
|     {
|      _Complex _Float128 z1, z2;
| 
|      z1 = x;
|      z2 = x / 7.F128;
|      z2 /= z1;
| 
|      return (_Float128) z2;
|     }
| 
|     _Float128 bar (_Float128 x)
|     {
|       return x * __builtin_huge_valf128 ();
|     }
| 
| int
| main ()
| {
| 
|     foo (1.2F128);
|     bar (1.2F128);
|     foo (1.2Q);
|     bar (1.2Q);
| 
|   ;
|   return 0;
| }
configure:30234: result: no

Solution

TODO

ZacWalk commented 10 months ago

As this does not appear to be trivial, I have tagged this as an enhancement.

From what I see the arch64-pe build is the same long double size as mingw clang aarch64. Maybe that is good enough initially and we can refine this for Windows compatibility later.

double long double _Float128 __float128
MSVC 64 64 Fail Fail
GCC x64 Linux 64 128 128 128
GCC Aarch64 Linux 64 128 128 Fail
Clang 16 Mingw x64 64 128 Fail Fail
Our toolchain 64 128 128 Fail
mstorsjo commented 10 months ago

FWIW, the in-progress port of GCC to aarch64-darwin also has the same situation, that the platform ABI defines long double as 64 bit.

See e.g. https://github.com/iains/gcc-darwin-arm64/commit/5f5030adef522fc16925235492c410f69ee89a9d which does #define LONG_DOUBLE_TYPE_SIZE 64, and https://github.com/iains/gcc-darwin-arm64/commit/f86186aded38e0c8cfd4527b3d1fdf954708442f with this commit message:

aarch64, Darwin: Support IEEE754 Quad Precision as __float128.

aarch64-apple-darwin has a C long double type which is the same as the double. In order to support a higher precision floating point type, similarly to x86_64-apple-darwin, we define define __float128 (and _Float128).

mstorsjo commented 7 months ago

Just for the record, I wanted to clarify one aspect mentioned further up in this thread:

A long double on aarch64 Linux is 128bit while on Windows it is 64bits in VC and LLVM.

This is slightly simplified - LLVM doesn't usually do one thing. LLVM can target either the MSVC ABI, or the mingw ABI. For x86, this means having 64 bit long doubles in MSVC mode but 80 bit x87 long doubles in mingw mode. The mingw mode in LLVM was developed to exactly (or as close as possible) match what GCC had been doing, defining the mingw ABI.

As there was no GCC for Windows on AArch64 back in 2017-2018 when we brought up the aarch64 mingw ABI in LLVM, we didn't have any reference to follow, so we settled on using 64 bit long doubles for mingw, just like MSVC, and because there's no HW support for anything else anyway.

At this time, the fact that aarch64-mingw has a 64 bit long double is codified in a number of places, all over mingw-w64-headers and mingw-w64-crt. Therefore, in order to match the already established aarch64 mingw ABI, using 64 bit long doubles would be the way to go.

(I get that it's not trivial to change, and that it might not be the highest priority, but I wanted to reframe the context; mingw generally isn't entirely ABI compatible with MSVC anyway, but this is an ABI break against the existing established aarch64 mingw ABI as well.)

I heard that attempts, in e.g. https://github.com/Windows-on-ARM-Experiments/gcc-woarm64/pull/3, to use 64 bit long doubles generally seem to work, but fails on Fortran somehow. I wonder what the aarch64-darwin port, at https://github.com/iains/gcc-darwin-arm64, does differently to avoid that issue there?