From b34f107e24e97cd7b4eedc6868e330a9ff321120 Mon Sep 17 00:00:00 2001 From: Keno Fischer Date: Thu, 3 Sep 2020 18:27:17 -0400 Subject: [PATCH] Fix Apple Silicon build (#214) My previous Apple Silicon build went through, so I thought it already worked, but it turns out it accidentally built an armv7 build instead. This actually fixes the Apple Silicon build. One thing to note in particular is that on Apple Silicong `long double` is the same as `double` while on Linux `long double` is a 128 bit double-double format. Co-authored-by: Elliot Saba --- Make.inc | 13 +++++++++++++ Makefile | 2 ++ src/Make.files | 2 +- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/Make.inc b/Make.inc index 8fb0eca..adeb33d 100644 --- a/Make.inc +++ b/Make.inc @@ -55,6 +55,9 @@ $(error "the mingw32 compiler you are using fails the openblas testsuite. please endif # OS-specific stuff +ifeq ($(ARCH),arm64) +override ARCH := aarch64 +endif ifeq ($(findstring arm,$(ARCH)),arm) override ARCH := arm MARCH ?= armv7-a @@ -144,6 +147,16 @@ CFLAGS_add += -I$(OPENLIBM_HOME)/ld128 endif endif +ifneq ($(filter $(ARCH),i387 amd64),) +# Determines whether `long double` is the same as `double` on this arch. +# linux x86_64, for instance, `long double` is 80 bits wide, whereas on macOS aarch64, +# `long double` is the same as `double`. +LONG_DOUBLE_NOT_DOUBLE := 1 +else ifeq ($(ARCH), aarch64) +ifneq ($(OS),Darwin) +LONG_DOUBLE_NOT_DOUBLE := 1 +endif +endif %.c.o: %.c $(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@ diff --git a/Makefile b/Makefile index 2ffceb5..865123e 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ OPENLIBM_HOME=$(abspath .) include ./Make.inc SUBDIRS = src $(ARCH) bsdsrc +ifeq ($(LONG_DOUBLE_NOT_DOUBLE),1) # Add ld80 directory on x86 and x64 ifneq ($(filter $(ARCH),i387 amd64),) SUBDIRS += ld80 @@ -11,6 +12,7 @@ SUBDIRS += ld128 else endif endif +endif define INC_template TEST=test diff --git a/src/Make.files b/src/Make.files index 301bd2f..5170403 100644 --- a/src/Make.files +++ b/src/Make.files @@ -44,7 +44,7 @@ endif endif # Add in long double functions for x86, x64 and aarch64 -ifneq ($(filter $(ARCH),i387 amd64 aarch64),) +ifeq ($(LONG_DOUBLE_NOT_DOUBLE),1) # C99 long double functions $(CUR_SRCS) += s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c