Skip to content

Commit b34f107

Browse files
Kenostaticfloat
andauthored
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 <[email protected]>
1 parent 5a27b4c commit b34f107

File tree

3 files changed

+16
-1
lines changed

3 files changed

+16
-1
lines changed

Make.inc

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ $(error "the mingw32 compiler you are using fails the openblas testsuite. please
5555
endif
5656

5757
# OS-specific stuff
58+
ifeq ($(ARCH),arm64)
59+
override ARCH := aarch64
60+
endif
5861
ifeq ($(findstring arm,$(ARCH)),arm)
5962
override ARCH := arm
6063
MARCH ?= armv7-a
@@ -144,6 +147,16 @@ CFLAGS_add += -I$(OPENLIBM_HOME)/ld128
144147
endif
145148
endif
146149

150+
ifneq ($(filter $(ARCH),i387 amd64),)
151+
# Determines whether `long double` is the same as `double` on this arch.
152+
# linux x86_64, for instance, `long double` is 80 bits wide, whereas on macOS aarch64,
153+
# `long double` is the same as `double`.
154+
LONG_DOUBLE_NOT_DOUBLE := 1
155+
else ifeq ($(ARCH), aarch64)
156+
ifneq ($(OS),Darwin)
157+
LONG_DOUBLE_NOT_DOUBLE := 1
158+
endif
159+
endif
147160

148161
%.c.o: %.c
149162
$(CC) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_add) -c $< -o $@

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ OPENLIBM_HOME=$(abspath .)
22
include ./Make.inc
33

44
SUBDIRS = src $(ARCH) bsdsrc
5+
ifeq ($(LONG_DOUBLE_NOT_DOUBLE),1)
56
# Add ld80 directory on x86 and x64
67
ifneq ($(filter $(ARCH),i387 amd64),)
78
SUBDIRS += ld80
@@ -11,6 +12,7 @@ SUBDIRS += ld128
1112
else
1213
endif
1314
endif
15+
endif
1416

1517
define INC_template
1618
TEST=test

src/Make.files

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ endif
4444
endif
4545

4646
# Add in long double functions for x86, x64 and aarch64
47-
ifneq ($(filter $(ARCH),i387 amd64 aarch64),)
47+
ifeq ($(LONG_DOUBLE_NOT_DOUBLE),1)
4848
# C99 long double functions
4949
$(CUR_SRCS) += s_copysignl.c s_fabsl.c s_llrintl.c s_lrintl.c s_modfl.c
5050

0 commit comments

Comments
 (0)