1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-30 00:33:09 +00:00

Fixes for ARM compilation

The target:

Odroid U3 (http://www.hardkernel.com/main/products/prdt_info.php?g_code=g138745696275)
Debian Jessie
As listed in #550 and #638 three modifications are needed for compilation to work:

float-abi flag for GCC If an FPU is present and supported by the installed os then passed value need to be hard.
I didn't find any better solution than using readelf to check for the availibilty of Tag_ABI_VFP_args which sould indicate support for the FPU. The check is only done if the arch is arm and if readelf is not present
on the system, there will be an error (/bin/sh: 1: readelf: not found) but it will not break and will continue with the default softfp value. Outputing the error is not really acceptable but I wanted some feedback on the
check itself.

-lpthread is needed on armv7 outside of Android
I replaced UNAME with KERNEL and OS to allow to differentiate Android.

m32 flag
My understanding is that outside of Android the flag is generating errors on armv7.

These modifications should introduce change only for non Android armv7 build.

No functional change.
This commit is contained in:
Jacques 2016-10-08 12:15:43 +02:00 committed by Marco Costalba
parent fdf3a51c68
commit a3fe80c36a

View file

@ -22,7 +22,10 @@
### ========================================================================== ### ==========================================================================
### Establish the operating system name ### Establish the operating system name
UNAME = $(shell uname) KERNEL = $(shell uname -s)
ifneq ($(KERNEL),Darwin)
OS = $(shell uname -o)
endif
### Executable name ### Executable name
EXE = stockfish EXE = stockfish
@ -145,8 +148,17 @@ endif
ifeq ($(COMP),gcc) ifeq ($(COMP),gcc)
comp=gcc comp=gcc
CXX=g++ CXX=g++
CXXFLAGS += -pedantic -Wextra -Wshadow -m$(bits) CXXFLAGS += -pedantic -Wextra -Wshadow
ifneq ($(UNAME),Darwin)
ifeq ($(ARCH),armv7)
ifeq ($(OS),Android)
CXXFLAGS += -m$(bits)
endif
else
CXXFLAGS += -m$(bits)
endif
ifneq ($(KERNEL),Darwin)
LDFLAGS += -Wl,--no-as-needed LDFLAGS += -Wl,--no-as-needed
endif endif
endif endif
@ -154,7 +166,7 @@ endif
ifeq ($(COMP),mingw) ifeq ($(COMP),mingw)
comp=mingw comp=mingw
ifeq ($(UNAME),Linux) ifeq ($(KERNEL),Linux)
ifeq ($(bits),64) ifeq ($(bits),64)
ifeq ($(shell which x86_64-w64-mingw32-c++-posix),) ifeq ($(shell which x86_64-w64-mingw32-c++-posix),)
CXX=x86_64-w64-mingw32-c++ CXX=x86_64-w64-mingw32-c++
@ -185,9 +197,19 @@ endif
ifeq ($(COMP),clang) ifeq ($(COMP),clang)
comp=clang comp=clang
CXX=clang++ CXX=clang++
CXXFLAGS += -pedantic -Wextra -Wshadow -m$(bits) CXXFLAGS += -pedantic -Wextra -Wshadow
LDFLAGS += -m$(bits)
ifeq ($(UNAME),Darwin) ifeq ($(ARCH),armv7)
ifeq ($(OS),Android)
CXXFLAGS += -m$(bits)
LDFLAGS += -m$(bits)
endif
else
CXXFLAGS += -m$(bits)
LDFLAGS += -m$(bits)
endif
ifeq ($(KERNEL),Darwin)
CXXFLAGS += -stdlib=libc++ CXXFLAGS += -stdlib=libc++
DEPENDFLAGS += -stdlib=libc++ DEPENDFLAGS += -stdlib=libc++
endif endif
@ -205,7 +227,7 @@ else
profile_clean = gcc-profile-clean profile_clean = gcc-profile-clean
endif endif
ifeq ($(UNAME),Darwin) ifeq ($(KERNEL),Darwin)
CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.9 CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.9
LDFLAGS += -arch $(arch) -mmacosx-version-min=10.9 LDFLAGS += -arch $(arch) -mmacosx-version-min=10.9
endif endif
@ -223,9 +245,9 @@ endif
### On mingw use Windows threads, otherwise POSIX ### On mingw use Windows threads, otherwise POSIX
ifneq ($(comp),mingw) ifneq ($(comp),mingw)
# On Android Bionic's C library comes with its own pthread implementation bundled in # On Android Bionic's C library comes with its own pthread implementation bundled in
ifneq ($(arch),armv7) ifneq ($(OS),Android)
# Haiku has pthreads in its libroot, so only link it in on other platforms # Haiku has pthreads in its libroot, so only link it in on other platforms
ifneq ($(UNAME),Haiku) ifneq ($(KERNEL),Haiku)
LDFLAGS += -lpthread LDFLAGS += -lpthread
endif endif
endif endif
@ -245,7 +267,7 @@ ifeq ($(optimize),yes)
ifeq ($(comp),gcc) ifeq ($(comp),gcc)
ifeq ($(UNAME),Darwin) ifeq ($(KERNEL),Darwin)
ifeq ($(arch),i386) ifeq ($(arch),i386)
CXXFLAGS += -mdynamic-no-pic CXXFLAGS += -mdynamic-no-pic
endif endif
@ -254,19 +276,19 @@ ifeq ($(optimize),yes)
endif endif
endif endif
ifeq ($(arch),armv7) ifeq ($(OS), Android)
CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp CXXFLAGS += -fno-gcse -mthumb -march=armv7-a -mfloat-abi=softfp
endif endif
endif endif
ifeq ($(comp),icc) ifeq ($(comp),icc)
ifeq ($(UNAME),Darwin) ifeq ($(KERNEL),Darwin)
CXXFLAGS += -mdynamic-no-pic CXXFLAGS += -mdynamic-no-pic
endif endif
endif endif
ifeq ($(comp),clang) ifeq ($(comp),clang)
ifeq ($(UNAME),Darwin) ifeq ($(KERNEL),Darwin)
ifeq ($(pext),no) ifeq ($(pext),no)
CXXFLAGS += -flto CXXFLAGS += -flto
LDFLAGS += $(CXXFLAGS) LDFLAGS += $(CXXFLAGS)
@ -326,7 +348,7 @@ ifeq ($(comp),gcc)
endif endif
ifeq ($(comp),mingw) ifeq ($(comp),mingw)
ifeq ($(UNAME),Linux) ifeq ($(KERNEL),Linux)
ifeq ($(optimize),yes) ifeq ($(optimize),yes)
ifeq ($(debug),no) ifeq ($(debug),no)
CXXFLAGS += -flto CXXFLAGS += -flto
@ -338,7 +360,7 @@ endif
### 3.9 Android 5 can only run position independent executables. Note that this ### 3.9 Android 5 can only run position independent executables. Note that this
### breaks Android 4.0 and earlier. ### breaks Android 4.0 and earlier.
ifeq ($(arch),armv7) ifeq ($(OS), Android)
CXXFLAGS += -fPIE CXXFLAGS += -fPIE
LDFLAGS += -fPIE -pie LDFLAGS += -fPIE -pie
endif endif
@ -446,6 +468,8 @@ config-sanity:
@echo "optimize: '$(optimize)'" @echo "optimize: '$(optimize)'"
@echo "arch: '$(arch)'" @echo "arch: '$(arch)'"
@echo "bits: '$(bits)'" @echo "bits: '$(bits)'"
@echo "kernel: '$(KERNEL)'"
@echo "os: '$(OS)'"
@echo "prefetch: '$(prefetch)'" @echo "prefetch: '$(prefetch)'"
@echo "popcnt: '$(popcnt)'" @echo "popcnt: '$(popcnt)'"
@echo "sse: '$(sse)'" @echo "sse: '$(sse)'"