1
0
Fork 0
mirror of https://github.com/sockspls/badfish synced 2025-04-29 16:23:09 +00:00

Speedup Makefile on Windows

The Makefile is notoriously slow on windows, because of new processes
being spawned I believe. This pr improves it a little bit for the help
and config-sanity targets, with the latter also improving `make -j
build` because it depends on that. On the same machine ubuntu (wsl) is
more than 3 times faster, if there are other improvements we can make
I'd be happy to hear about them. Ultimately
https://github.com/official-stockfish/Stockfish/pull/5543 also aims to
improve this I believe, but it will take some additional time before
that lands.

```
make config-sanity:

    patch: 6.199s
    master: 12.738s

make help:

    patch: 3.1s
    master: 11.49s

make -j build:

    patch: 36s
    master: 43.25s

make -j build:

    master ubuntu: 10s
```

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

No functional change
This commit is contained in:
Disservin 2024-10-19 16:56:02 +02:00
parent 2ce47573b4
commit c15113554f

View file

@ -851,75 +851,75 @@ endif
### ========================================================================== ### ==========================================================================
help: help:
@echo "" @echo "" && \
@echo "To compile stockfish, type: " echo "To compile stockfish, type: " && \
@echo "" echo "" && \
@echo "make -j target [ARCH=arch] [COMP=compiler] [COMPCXX=cxx]" echo "make -j target [ARCH=arch] [COMP=compiler] [COMPCXX=cxx]" && \
@echo "" echo "" && \
@echo "Supported targets:" echo "Supported targets:" && \
@echo "" echo "" && \
@echo "help > Display architecture details" echo "help > Display architecture details" && \
@echo "profile-build > standard build with profile-guided optimization" echo "profile-build > standard build with profile-guided optimization" && \
@echo "build > skip profile-guided optimization" echo "build > skip profile-guided optimization" && \
@echo "net > Download the default nnue nets" echo "net > Download the default nnue nets" && \
@echo "strip > Strip executable" echo "strip > Strip executable" && \
@echo "install > Install executable" echo "install > Install executable" && \
@echo "clean > Clean up" echo "clean > Clean up" && \
@echo "" echo "" && \
@echo "Supported archs:" echo "Supported archs:" && \
@echo "" echo "" && \
@echo "native > select the best architecture for the host processor (default)" echo "native > select the best architecture for the host processor (default)" && \
@echo "x86-64-vnni512 > x86 64-bit with vnni 512bit support" echo "x86-64-vnni512 > x86 64-bit with vnni 512bit support" && \
@echo "x86-64-vnni256 > x86 64-bit with vnni 512bit support, limit operands to 256bit wide" echo "x86-64-vnni256 > x86 64-bit with vnni 512bit support, limit operands to 256bit wide" && \
@echo "x86-64-avx512 > x86 64-bit with avx512 support" echo "x86-64-avx512 > x86 64-bit with avx512 support" && \
@echo "x86-64-avxvnni > x86 64-bit with vnni 256bit support" echo "x86-64-avxvnni > x86 64-bit with vnni 256bit support" && \
@echo "x86-64-bmi2 > x86 64-bit with bmi2 support" echo "x86-64-bmi2 > x86 64-bit with bmi2 support" && \
@echo "x86-64-avx2 > x86 64-bit with avx2 support" echo "x86-64-avx2 > x86 64-bit with avx2 support" && \
@echo "x86-64-sse41-popcnt > x86 64-bit with sse41 and popcnt support" echo "x86-64-sse41-popcnt > x86 64-bit with sse41 and popcnt support" && \
@echo "x86-64-modern > deprecated, currently x86-64-sse41-popcnt" echo "x86-64-modern > deprecated, currently x86-64-sse41-popcnt" && \
@echo "x86-64-ssse3 > x86 64-bit with ssse3 support" echo "x86-64-ssse3 > x86 64-bit with ssse3 support" && \
@echo "x86-64-sse3-popcnt > x86 64-bit with sse3 compile and popcnt support" echo "x86-64-sse3-popcnt > x86 64-bit with sse3 compile and popcnt support" && \
@echo "x86-64 > x86 64-bit generic (with sse2 support)" echo "x86-64 > x86 64-bit generic (with sse2 support)" && \
@echo "x86-32-sse41-popcnt > x86 32-bit with sse41 and popcnt support" echo "x86-32-sse41-popcnt > x86 32-bit with sse41 and popcnt support" && \
@echo "x86-32-sse2 > x86 32-bit with sse2 support" echo "x86-32-sse2 > x86 32-bit with sse2 support" && \
@echo "x86-32 > x86 32-bit generic (with mmx compile support)" echo "x86-32 > x86 32-bit generic (with mmx compile support)" && \
@echo "ppc-64 > PPC 64-bit" echo "ppc-64 > PPC 64-bit" && \
@echo "ppc-64-altivec > PPC 64-bit with altivec support" echo "ppc-64-altivec > PPC 64-bit with altivec support" && \
@echo "ppc-64-vsx > PPC 64-bit with vsx support" echo "ppc-64-vsx > PPC 64-bit with vsx support" && \
@echo "ppc-32 > PPC 32-bit" echo "ppc-32 > PPC 32-bit" && \
@echo "armv7 > ARMv7 32-bit" echo "armv7 > ARMv7 32-bit" && \
@echo "armv7-neon > ARMv7 32-bit with popcnt and neon" echo "armv7-neon > ARMv7 32-bit with popcnt and neon" && \
@echo "armv8 > ARMv8 64-bit with popcnt and neon" echo "armv8 > ARMv8 64-bit with popcnt and neon" && \
@echo "armv8-dotprod > ARMv8 64-bit with popcnt, neon and dot product support" echo "armv8-dotprod > ARMv8 64-bit with popcnt, neon and dot product support" && \
@echo "e2k > Elbrus 2000" echo "e2k > Elbrus 2000" && \
@echo "apple-silicon > Apple silicon ARM64" echo "apple-silicon > Apple silicon ARM64" && \
@echo "general-64 > unspecified 64-bit" echo "general-64 > unspecified 64-bit" && \
@echo "general-32 > unspecified 32-bit" echo "general-32 > unspecified 32-bit" && \
@echo "riscv64 > RISC-V 64-bit" echo "riscv64 > RISC-V 64-bit" && \
@echo "loongarch64 > LoongArch 64-bit" echo "loongarch64 > LoongArch 64-bit" && \
@echo "loongarch64-lsx > LoongArch 64-bit with SIMD eXtension" echo "loongarch64-lsx > LoongArch 64-bit with SIMD eXtension" && \
@echo "loongarch64-lasx > LoongArch 64-bit with Advanced SIMD eXtension" echo "loongarch64-lasx > LoongArch 64-bit with Advanced SIMD eXtension" && \
@echo "" echo "" && \
@echo "Supported compilers:" echo "Supported compilers:" && \
@echo "" echo "" && \
@echo "gcc > GNU compiler (default)" echo "gcc > GNU compiler (default)" && \
@echo "mingw > GNU compiler with MinGW under Windows" echo "mingw > GNU compiler with MinGW under Windows" && \
@echo "clang > LLVM Clang compiler" echo "clang > LLVM Clang compiler" && \
@echo "icx > Intel oneAPI DPC++/C++ Compiler" echo "icx > Intel oneAPI DPC++/C++ Compiler" && \
@echo "ndk > Google NDK to cross-compile for Android" echo "ndk > Google NDK to cross-compile for Android" && \
@echo "" echo "" && \
@echo "Simple examples. If you don't know what to do, you likely want to run one of: " echo "Simple examples. If you don't know what to do, you likely want to run one of: " && \
@echo "" echo "" && \
@echo "make -j profile-build ARCH=x86-64-avx2 # typically a fast compile for common systems " echo "make -j profile-build ARCH=x86-64-avx2 # typically a fast compile for common systems " && \
@echo "make -j profile-build ARCH=x86-64-sse41-popcnt # A more portable compile for 64-bit systems " echo "make -j profile-build ARCH=x86-64-sse41-popcnt # A more portable compile for 64-bit systems " && \
@echo "make -j profile-build ARCH=x86-64 # A portable compile for 64-bit systems " echo "make -j profile-build ARCH=x86-64 # A portable compile for 64-bit systems " && \
@echo "" echo "" && \
@echo "Advanced examples, for experienced users: " echo "Advanced examples, for experienced users: " && \
@echo "" echo "" && \
@echo "make -j profile-build ARCH=x86-64-avxvnni" echo "make -j profile-build ARCH=x86-64-avxvnni" && \
@echo "make -j profile-build ARCH=x86-64-avxvnni COMP=gcc COMPCXX=g++-12.0" echo "make -j profile-build ARCH=x86-64-avxvnni COMP=gcc COMPCXX=g++-12.0" && \
@echo "make -j build ARCH=x86-64-ssse3 COMP=clang" echo "make -j build ARCH=x86-64-ssse3 COMP=clang" && \
@echo "" echo ""
ifneq ($(SUPPORTED_ARCH), true) ifneq ($(SUPPORTED_ARCH), true)
@echo "Specify a supported architecture with the ARCH option for more details" @echo "Specify a supported architecture with the ARCH option for more details"
@echo "" @echo ""
@ -1000,69 +1000,71 @@ all: $(EXE) .depend
config-sanity: net config-sanity: net
@echo "" @echo ""
@echo "Config:" @echo "Config:" && \
@echo "debug: '$(debug)'" echo "debug: '$(debug)'" && \
@echo "sanitize: '$(sanitize)'" echo "sanitize: '$(sanitize)'" && \
@echo "optimize: '$(optimize)'" echo "optimize: '$(optimize)'" && \
@echo "arch: '$(arch)'" echo "arch: '$(arch)'" && \
@echo "bits: '$(bits)'" echo "bits: '$(bits)'" && \
@echo "kernel: '$(KERNEL)'" echo "kernel: '$(KERNEL)'" && \
@echo "os: '$(OS)'" echo "os: '$(OS)'" && \
@echo "prefetch: '$(prefetch)'" echo "prefetch: '$(prefetch)'" && \
@echo "popcnt: '$(popcnt)'" echo "popcnt: '$(popcnt)'" && \
@echo "pext: '$(pext)'" echo "pext: '$(pext)'" && \
@echo "sse: '$(sse)'" echo "sse: '$(sse)'" && \
@echo "mmx: '$(mmx)'" echo "mmx: '$(mmx)'" && \
@echo "sse2: '$(sse2)'" echo "sse2: '$(sse2)'" && \
@echo "ssse3: '$(ssse3)'" echo "ssse3: '$(ssse3)'" && \
@echo "sse41: '$(sse41)'" echo "sse41: '$(sse41)'" && \
@echo "avx2: '$(avx2)'" echo "avx2: '$(avx2)'" && \
@echo "avxvnni: '$(avxvnni)'" echo "avxvnni: '$(avxvnni)'" && \
@echo "avx512: '$(avx512)'" echo "avx512: '$(avx512)'" && \
@echo "vnni256: '$(vnni256)'" echo "vnni256: '$(vnni256)'" && \
@echo "vnni512: '$(vnni512)'" echo "vnni512: '$(vnni512)'" && \
@echo "altivec: '$(altivec)'" echo "altivec: '$(altivec)'" && \
@echo "vsx: '$(vsx)'" echo "vsx: '$(vsx)'" && \
@echo "neon: '$(neon)'" echo "neon: '$(neon)'" && \
@echo "dotprod: '$(dotprod)'" echo "dotprod: '$(dotprod)'" && \
@echo "arm_version: '$(arm_version)'" echo "arm_version: '$(arm_version)'" && \
@echo "lsx: '$(lsx)'" echo "lsx: '$(lsx)'" && \
@echo "lasx: '$(lasx)'" echo "lasx: '$(lasx)'" && \
@echo "target_windows: '$(target_windows)'" echo "target_windows: '$(target_windows)'" && \
@echo "" echo "" && \
@echo "Flags:" echo "Flags:" && \
@echo "CXX: $(CXX)" echo "CXX: $(CXX)" && \
@echo "CXXFLAGS: $(CXXFLAGS)" echo "CXXFLAGS: $(CXXFLAGS)" && \
@echo "LDFLAGS: $(LDFLAGS)" echo "LDFLAGS: $(LDFLAGS)" && \
@echo "" echo "" && \
@echo "Testing config sanity. If this fails, try 'make help' ..." echo "Testing config sanity. If this fails, try 'make help' ..." && \
@echo "" echo "" && \
@test "$(debug)" = "yes" || test "$(debug)" = "no" (test "$(debug)" = "yes" || test "$(debug)" = "no") && \
@test "$(optimize)" = "yes" || test "$(optimize)" = "no" (test "$(optimize)" = "yes" || test "$(optimize)" = "no") && \
@test "$(SUPPORTED_ARCH)" = "true" (test "$(SUPPORTED_ARCH)" = "true") && \
@test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \ (test "$(arch)" = "any" || test "$(arch)" = "x86_64" || test "$(arch)" = "i386" || \
test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \ test "$(arch)" = "ppc64" || test "$(arch)" = "ppc" || test "$(arch)" = "e2k" || \
test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" || test "$(arch)" = "riscv64" || test "$(arch)" = "loongarch64" test "$(arch)" = "armv7" || test "$(arch)" = "armv8" || test "$(arch)" = "arm64" || \
@test "$(bits)" = "32" || test "$(bits)" = "64" test "$(arch)" = "riscv64" || test "$(arch)" = "loongarch64") && \
@test "$(prefetch)" = "yes" || test "$(prefetch)" = "no" (test "$(bits)" = "32" || test "$(bits)" = "64") && \
@test "$(popcnt)" = "yes" || test "$(popcnt)" = "no" (test "$(prefetch)" = "yes" || test "$(prefetch)" = "no") && \
@test "$(pext)" = "yes" || test "$(pext)" = "no" (test "$(popcnt)" = "yes" || test "$(popcnt)" = "no") && \
@test "$(sse)" = "yes" || test "$(sse)" = "no" (test "$(pext)" = "yes" || test "$(pext)" = "no") && \
@test "$(mmx)" = "yes" || test "$(mmx)" = "no" (test "$(sse)" = "yes" || test "$(sse)" = "no") && \
@test "$(sse2)" = "yes" || test "$(sse2)" = "no" (test "$(mmx)" = "yes" || test "$(mmx)" = "no") && \
@test "$(ssse3)" = "yes" || test "$(ssse3)" = "no" (test "$(sse2)" = "yes" || test "$(sse2)" = "no") && \
@test "$(sse41)" = "yes" || test "$(sse41)" = "no" (test "$(ssse3)" = "yes" || test "$(ssse3)" = "no") && \
@test "$(avx2)" = "yes" || test "$(avx2)" = "no" (test "$(sse41)" = "yes" || test "$(sse41)" = "no") && \
@test "$(avx512)" = "yes" || test "$(avx512)" = "no" (test "$(avx2)" = "yes" || test "$(avx2)" = "no") && \
@test "$(vnni256)" = "yes" || test "$(vnni256)" = "no" (test "$(avx512)" = "yes" || test "$(avx512)" = "no") && \
@test "$(vnni512)" = "yes" || test "$(vnni512)" = "no" (test "$(vnni256)" = "yes" || test "$(vnni256)" = "no") && \
@test "$(altivec)" = "yes" || test "$(altivec)" = "no" (test "$(vnni512)" = "yes" || test "$(vnni512)" = "no") && \
@test "$(vsx)" = "yes" || test "$(vsx)" = "no" (test "$(altivec)" = "yes" || test "$(altivec)" = "no") && \
@test "$(neon)" = "yes" || test "$(neon)" = "no" (test "$(vsx)" = "yes" || test "$(vsx)" = "no") && \
@test "$(lsx)" = "yes" || test "$(lsx)" = "no" (test "$(neon)" = "yes" || test "$(neon)" = "no") && \
@test "$(lasx)" = "yes" || test "$(lasx)" = "no" (test "$(lsx)" = "yes" || test "$(lsx)" = "no") && \
@test "$(comp)" = "gcc" || test "$(comp)" = "icx" || test "$(comp)" = "mingw" || test "$(comp)" = "clang" \ (test "$(lasx)" = "yes" || test "$(lasx)" = "no") && \
|| test "$(comp)" = "armv7a-linux-androideabi16-clang" || test "$(comp)" = "aarch64-linux-android21-clang" (test "$(comp)" = "gcc" || test "$(comp)" = "icx" || test "$(comp)" = "mingw" || \
test "$(comp)" = "clang" || test "$(comp)" = "armv7a-linux-androideabi16-clang" || \
test "$(comp)" = "aarch64-linux-android21-clang")
$(EXE): $(OBJS) $(EXE): $(OBJS)
+$(CXX) -o $@ $(OBJS) $(LDFLAGS) +$(CXX) -o $@ $(OBJS) $(LDFLAGS)