Skip to content

Commit

Permalink
Fix Apple Silicon build (#214)
Browse files Browse the repository at this point in the history
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 <staticfloat@gmail.com>
  • Loading branch information
Keno and staticfloat authored Sep 3, 2020
1 parent 5a27b4c commit b34f107
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
13 changes: 13 additions & 0 deletions Make.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 $@
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -11,6 +12,7 @@ SUBDIRS += ld128
else
endif
endif
endif

define INC_template
TEST=test
Expand Down
2 changes: 1 addition & 1 deletion src/Make.files
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit b34f107

Please sign in to comment.