diff --git a/.github/workflows/avx2_compilers.yml b/.github/workflows/avx2_compilers.yml index 5ceb62bd9..075553bde 100644 --- a/.github/workflows/avx2_compilers.yml +++ b/.github/workflows/avx2_compilers.yml @@ -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 diff --git a/src/Makefile b/src/Makefile index ff70a73c9..dff34638c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -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.