]> git.sesse.net Git - stockfish/commitdiff
Update Makefile for macOS
authorgsobala <gsobala@gmail.com>
Fri, 21 Aug 2020 10:28:53 +0000 (11:28 +0100)
committerJoost VandeVondele <Joost.VandeVondele@gmail.com>
Fri, 21 Aug 2020 15:59:21 +0000 (17:59 +0200)
Changes to deal with compilation (particularly profile-build) on macOS.
(1) The default toolchain has gcc masquerading as clang,
    the previous Makefile was not picking up the required changes
    to the different profiling tools.
(2) The previous Makefile test for gccisclang occurred before
    a potential overwrite of CXX by COMPCXX
(3) llvm-profdata no longer runs as a command on macOS and
    instead is invoked by ``xcrun llvm-profdata``
(4) Needs to support use of true gcc using e.g.
    ``make build ... COMPCXX=g++-10``
(5) enable profile-build in travis for macOS

closes https://github.com/official-stockfish/Stockfish/pull/3043

No functional change

.travis.yml
AUTHORS
src/Makefile

index 12596f1e32700f27e495476fcf104ef4cb48f0d0..a029c4fc818946063ae637a1617a1c58f5099757 100644 (file)
@@ -71,7 +71,8 @@ script:
   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-32-sse2 build && ../tests/signature.sh $benchref; fi
   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-32 build && ../tests/signature.sh $benchref; fi
   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=general-32 build && ../tests/signature.sh $benchref; fi
   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-32-sse2 build && ../tests/signature.sh $benchref; fi
   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=x86-32 build && ../tests/signature.sh $benchref; fi
   - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then make clean && make -j2 ARCH=general-32 build && ../tests/signature.sh $benchref; fi
-  - if [[ "$TRAVIS_OS_NAME" == "linux" && "$COMP" == "gcc" ]]; then make clean && make -j2 ARCH=x86-64-modern profile-build && ../tests/signature.sh $benchref; fi
+  # workaround: exclude a custom version of llvm+clang, which doesn't find llvm-profdata on ubuntu
+  - if [[ "$TRAVIS_OS_NAME" != "linux" || "$COMP" == "gcc" ]]; then make clean && make -j2 ARCH=x86-64-modern profile-build && ../tests/signature.sh $benchref; fi
 
   # compile only for some more advanced architectures (might not run in travis)
   - make clean && make -j2 ARCH=x86-64-avx2 build
 
   # compile only for some more advanced architectures (might not run in travis)
   - make clean && make -j2 ARCH=x86-64-avx2 build
diff --git a/AUTHORS b/AUTHORS
index d8f4d30e7c2bc035959eac851bb45658b6116837..c96f870a6a688680c07d93302df8f4040d99b0c8 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -59,6 +59,7 @@ Fauzi Akram Dabat (FauziAkram)
 Felix Wittmann
 gamander
 Gary Heckman (gheckman)
 Felix Wittmann
 gamander
 Gary Heckman (gheckman)
+George Sobala (gsobala)
 gguliash
 Gian-Carlo Pascutto (gcp)
 Gontran Lemaire (gonlem)
 gguliash
 Gian-Carlo Pascutto (gcp)
 Gontran Lemaire (gonlem)
index 79c7333ac26edc43fe73f3a44c8ad29e86296ca2..b969ba0466599ec7f10f8682b43c3096e8dfb2e4 100644 (file)
@@ -302,9 +302,6 @@ ifeq ($(COMP),gcc)
        ifneq ($(KERNEL),Darwin)
           LDFLAGS += -Wl,--no-as-needed
        endif
        ifneq ($(KERNEL),Darwin)
           LDFLAGS += -Wl,--no-as-needed
        endif
-
-       gccversion = $(shell $(CXX) --version)
-       gccisclang = $(findstring clang,$(gccversion))
 endif
 
 ifeq ($(COMP),mingw)
 endif
 
 ifeq ($(COMP),mingw)
@@ -376,6 +373,7 @@ endif
 ifeq ($(KERNEL),Darwin)
        CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.14
        LDFLAGS += -arch $(arch) -mmacosx-version-min=10.14
 ifeq ($(KERNEL),Darwin)
        CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.14
        LDFLAGS += -arch $(arch) -mmacosx-version-min=10.14
+       XCRUN = xcrun
 endif
 
 # To cross-compile for Android, NDK version r21 or later is recommended.
 endif
 
 # To cross-compile for Android, NDK version r21 or later is recommended.
@@ -407,6 +405,16 @@ ifdef COMPCXX
        CXX=$(COMPCXX)
 endif
 
        CXX=$(COMPCXX)
 endif
 
+### Sometimes gcc is really clang
+ifeq ($(COMP),gcc)
+       gccversion = $(shell $(CXX) --version)
+       gccisclang = $(findstring clang,$(gccversion))
+       ifneq ($(gccisclang),)
+               profile_make = clang-profile-make
+               profile_use = clang-profile-use
+       endif
+endif
+
 ### On mingw use Windows threads, otherwise POSIX
 ifneq ($(comp),mingw)
        # On Android Bionic's C library comes with its own pthread implementation bundled in
 ### On mingw use Windows threads, otherwise POSIX
 ifneq ($(comp),mingw)
        # On Android Bionic's C library comes with its own pthread implementation bundled in
@@ -798,7 +806,7 @@ clang-profile-make:
        all
 
 clang-profile-use:
        all
 
 clang-profile-use:
-       llvm-profdata merge -output=stockfish.profdata *.profraw
+       $(XCRUN) llvm-profdata merge -output=stockfish.profdata *.profraw
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
        EXTRALDFLAGS='-fprofile-use ' \
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
        EXTRALDFLAGS='-fprofile-use ' \