]> git.sesse.net Git - stockfish/commitdiff
Enable LTO for clang
authorsyzygy1 <3028851+syzygy1@users.noreply.github.com>
Mon, 5 Feb 2018 23:43:29 +0000 (00:43 +0100)
committerStéphane Nicolet <cassio@free.fr>
Mon, 5 Feb 2018 23:46:50 +0000 (00:46 +0100)
Enable link-time optimization in the Makefile when compiling with clang.
Also update travis.yml to use clang++-5.0 and llvm-5.0-dev.

No functional change.

.travis.yml
src/Makefile

index 8586921a887527f70fae0a0f63373e6476831afa..7a0b111f887a7147685f2c9606cfe9a382a29b4c 100644 (file)
@@ -18,11 +18,12 @@ matrix:
       compiler: clang
       addons:
         apt:
       compiler: clang
       addons:
         apt:
-          sources: ['ubuntu-toolchain-r-test']
-          packages: ['clang', 'g++-multilib', 'valgrind', 'expect']
+          sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-trusty-5.0']
+          packages: ['clang-5.0', 'llvm-5.0-dev', 'g++-multilib', 'valgrind', 'expect']
       env:
       env:
-        - COMPILER=clang++
+        - COMPILER=clang++-5.0
         - COMP=clang
         - COMP=clang
+        - LDFLAGS=-fuse-ld=gold
 
     - os: osx
       compiler: gcc
 
     - os: osx
       compiler: gcc
index 72afcc35629405af04cb8d583172472277a98330..f6f36727ae7ecc860b78cbdcdfb48664e71ad359 100644 (file)
@@ -302,8 +302,6 @@ ifeq ($(optimize),yes)
 
        ifeq ($(comp),clang)
                ifeq ($(KERNEL),Darwin)
 
        ifeq ($(comp),clang)
                ifeq ($(KERNEL),Darwin)
-                               CXXFLAGS += -flto
-                               LDFLAGS += $(CXXFLAGS)
                        ifeq ($(arch),i386)
                                CXXFLAGS += -mdynamic-no-pic
                        endif
                        ifeq ($(arch),i386)
                                CXXFLAGS += -mdynamic-no-pic
                        endif
@@ -349,24 +347,20 @@ endif
 ### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows.
 ### This is a mix of compile and link time options because the lto link phase
 ### needs access to the optimization flags.
 ### 3.8 Link Time Optimization, it works since gcc 4.5 but not on mingw under Windows.
 ### This is a mix of compile and link time options because the lto link phase
 ### needs access to the optimization flags.
-ifeq ($(comp),gcc)
-       ifeq ($(optimize),yes)
-       ifeq ($(debug),no)
+ifeq ($(optimize),yes)
+ifeq ($(debug), no)
+       ifeq ($(comp),$(filter $(comp),gcc clang))
                CXXFLAGS += -flto
                LDFLAGS += $(CXXFLAGS)
        endif
                CXXFLAGS += -flto
                LDFLAGS += $(CXXFLAGS)
        endif
-       endif
-endif
 
 
-ifeq ($(comp),mingw)
+       ifeq ($(comp),mingw)
        ifeq ($(KERNEL),Linux)
        ifeq ($(KERNEL),Linux)
-       ifeq ($(optimize),yes)
-       ifeq ($(debug),no)
                CXXFLAGS += -flto
                LDFLAGS += $(CXXFLAGS)
        endif
        endif
                CXXFLAGS += -flto
                LDFLAGS += $(CXXFLAGS)
        endif
        endif
-       endif
+endif
 endif
 
 ### 3.9 Android 5 can only run position independent executables. Note that this
 endif
 
 ### 3.9 Android 5 can only run position independent executables. Note that this