]> git.sesse.net Git - stockfish/commitdiff
Fix for profile-build failure using gcc on MacOS
authorGeorge Sobala <gsobala@gmail.com>
Mon, 13 Dec 2021 15:29:31 +0000 (15:29 +0000)
committerStéphane Nicolet <cassio@free.fr>
Fri, 17 Dec 2021 17:52:09 +0000 (18:52 +0100)
Fixes https://github.com/official-stockfish/Stockfish/issues/3846 ,
where the profiling SF binary generated by GCC on MacOS would launch
but failed to quit. Tested with gcc-8, gcc9, gcc10, gcc-11.

The problem can be fixed by adding -fvisibility=hidden to the compiler
flags, see for example the following piece of Apple documentation:
https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/CppRuntimeEnv/Articles/SymbolVisibility.html

For instance this now works:
   make -j8 profile-build ARCH=x86-64-avx2 COMP=gcc COMPCXX=g++-11

No functional change

src/Makefile

index 3cf97873d8a7411eaf26a8c68a1b1fb0b7c0d02c..5e2637729a192f6b32d14eb12ee3f7b2a021371d 100644 (file)
@@ -459,6 +459,9 @@ else ifeq ($(comp),clang)
 else
        profile_make = gcc-profile-make
        profile_use = gcc-profile-use
+       ifeq ($(KERNEL),Darwin)
+               EXTRAPROFILEFLAGS = -fvisibility=hidden
+       endif
 endif
 
 ### Travis CI script uses COMPILER to overwrite CXX
@@ -920,12 +923,14 @@ gcc-profile-make:
        @mkdir -p profdir
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-generate=profdir' \
+       EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
        EXTRALDFLAGS='-lgcov' \
        all
 
 gcc-profile-use:
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-use=profdir -fno-peel-loops -fno-tracer' \
+       EXTRACXXFLAGS+=$(EXTRAPROFILEFLAGS) \
        EXTRALDFLAGS='-lgcov' \
        all