]> git.sesse.net Git - stockfish/blobdiff - src/Makefile
Fix a data race for NNUE
[stockfish] / src / Makefile
index 4741e722bfdd125d5fbdd260d31558767703577f..571172b29e0b13209f50d66733952d6a6c0a34ef 100644 (file)
@@ -282,6 +282,9 @@ ifeq ($(COMP),gcc)
        ifneq ($(KERNEL),Darwin)
           LDFLAGS += -Wl,--no-as-needed
        endif
+       
+       gccversion = $(shell $(CXX) --version)
+       gccisclang = $(findstring clang,$(gccversion))
 endif
 
 ifeq ($(COMP),mingw)
@@ -351,8 +354,8 @@ endif
 endif
 
 ifeq ($(KERNEL),Darwin)
-       CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.15
-       LDFLAGS += -arch $(arch) -mmacosx-version-min=10.15
+       CXXFLAGS += -arch $(arch) -mmacosx-version-min=10.14
+       LDFLAGS += -arch $(arch) -mmacosx-version-min=10.14
 endif
 
 ### Travis CI script uses COMPILER to overwrite CXX
@@ -496,18 +499,28 @@ endif
 ### needs access to the optimization flags.
 ifeq ($(optimize),yes)
 ifeq ($(debug), no)
-       ifeq ($(comp),$(filter $(comp),gcc clang))
+       ifeq ($(comp),clang)
+               CXXFLAGS += -flto=thin
+               LDFLAGS += $(CXXFLAGS)
+
+# GCC and CLANG use different methods for parallelizing LTO and CLANG pretends to be
+# GCC on some systems.
+       else ifeq ($(comp),gcc)
+       ifeq ($(gccisclang),)
                CXXFLAGS += -flto
+               LDFLAGS += $(CXXFLAGS) -flto=jobserver
+       else
+               CXXFLAGS += -flto=thin
                LDFLAGS += $(CXXFLAGS)
        endif
 
 # To use LTO and static linking on windows, the tool chain requires a recent gcc:
 # gcc version 10.1 in msys2 or TDM-GCC version 9.2 are know to work, older might not.
 # So, only enable it for a cross from Linux by default.
-       ifeq ($(comp),mingw)
+       else ifeq ($(comp),mingw)
        ifeq ($(KERNEL),Linux)
                CXXFLAGS += -flto
-               LDFLAGS += $(CXXFLAGS)
+               LDFLAGS += $(CXXFLAGS) -flto=jobserver
        endif
        endif
 endif
@@ -693,7 +706,7 @@ config-sanity:
        @test "$(comp)" = "gcc" || test "$(comp)" = "icc" || test "$(comp)" = "mingw" || test "$(comp)" = "clang"
 
 $(EXE): $(OBJS)
-       $(CXX) -o $@ $(OBJS) $(LDFLAGS)
+       +$(CXX) -o $@ $(OBJS) $(LDFLAGS)
 
 clang-profile-make:
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \