feat(build): use lld for clang if available

Also simplify the CI.

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

No functional change
This commit is contained in:
ppigazzini
2026-02-08 15:22:06 +01:00
committed by Disservin
parent 3cde1560f6
commit e3a5c40f05
2 changed files with 24 additions and 12 deletions
-1
View File
@@ -74,7 +74,6 @@ jobs:
run: |
export CXXFLAGS="-Werror"
if [ "${{ matrix.ver }}" -ge 20 ]; then
export LDFLAGS="-fuse-ld=lld"
apt install -y lld
fi
make clean
+24 -11
View File
@@ -854,27 +854,40 @@ endif
### This is a mix of compile and link time options because the lto link phase
### needs access to the optimization flags.
ifeq ($(optimize),yes)
ifeq ($(debug), no)
ifeq ($(debug),no)
ifneq ($(KERNEL),Darwin)
LLD_BIN := $(shell command -v ld.lld 2>/dev/null)
ifeq ($(LLD_BIN),)
LLD_BIN := $(shell command -v lld 2>/dev/null)
endif
ifneq ($(LLD_BIN),)
ifeq ($(comp),clang)
LDFLAGS += -fuse-ld=lld
else ifeq ($(comp),gcc)
ifneq ($(gccisclang),)
LDFLAGS += -fuse-ld=lld
endif
endif
endif
endif
ifeq ($(comp),$(filter $(comp),clang icx))
CXXFLAGS += -flto=full
ifeq ($(comp),icx)
CXXFLAGS += -fwhole-program-vtables
endif
ifeq ($(target_windows),yes)
CXXFLAGS += -fuse-ld=lld
endif
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 -flto-partition=one
LDFLAGS += $(CXXFLAGS) -flto=jobserver
else
CXXFLAGS += -flto=full
LDFLAGS += $(CXXFLAGS)
endif
ifeq ($(gccisclang),)
CXXFLAGS += -flto -flto-partition=one
LDFLAGS += $(CXXFLAGS) -flto=jobserver
else
CXXFLAGS += -flto=full
LDFLAGS += $(CXXFLAGS)
endif
# To use LTO and static linking on Windows,
# the tool chain requires gcc version 10.1 or later.