From 939b694bfda27017c34a8cdccc81f2bb2ef44079 Mon Sep 17 00:00:00 2001 From: George Sobala Date: Mon, 13 Dec 2021 15:29:31 +0000 Subject: [PATCH] Fix for profile-build failure using gcc on MacOS 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 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Makefile b/src/Makefile index 3cf97873..5e263772 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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