-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix a linker bug with Clang on Windows #3084
Conversation
that's a workaround for a compiler bug, right? |
Yes. |
BTW, does this influence compilation on macOS? |
I do a compile on macOS (10.16.6) yesterday and some minutes bevor. No problems, binary running :) |
4cc11fd
to
4a19eb3
Compare
@vondele Thanks. It probably would have affected maOS. New version pushed. |
https://github.com/official-stockfish/Stockfish/blob/e0bafa1911ede61b9268e0b461a5d8856d6cd6be/src/Makefile#L606 So basically lines 606 and 608 are an or condition What you do is an and condition: Because $(KERNEL) either contains "MINGW" (when run from the MSYS shell) or "MSYS" (when run from the Windows CMD shell) but never both, your condition can never be true so this basically never adds -flto=thin to CXXFLAGS. If you want to add -flto=thin to CXXFLAGS only if $(KERNEL) neither contains "MINGW" nor "MSYS" you do: ifeq ($(findstring MINGW,$(KERNEL)),)
ifeq ($(findstring MSYS,$(KERNEL)),)
CXXFLAGS += -flto=thin
endif
endif (notice the change from ifneq to ifeq) Edit: about the indentation: The convention is that if several ifeq/ifneq are part of the same condition but can't be written on a single line (because make doesn't have real && and || operators) you don't indent. |
Maybe we should not use link time optimization at all: we keep patching SF source and Makefile to workaround around buggy lto compiler implementations :-( |
AFAIK, most issues have been windows related. So fixing #2958 would help. |
@gvreuls Thank you for taking the time to explain. Fixed. |
Using the llvm linker with adding the line -fuse-ld=lld to the linker parameters does work for me on msys2. |
@erbsenzaehler Using |
The linker is not installed by default. You can get it with pacman -Syu mingw-w64-x86_64-lld |
@erbsenzaehler Thanks! I can confirm that works. I leave it to @vondele whether we want to depend on the lld linker being installed or disable lto. |
I would think that since clang on mingw is anyway not the default, we can expect users of clang to install the needed linker for a functional toolchain. Not so different from the situation on ubuntu where just installing clang++ is not enough needs llvm installed as well. So, I would tend to add the correct lld flag instead of disabling lto. @mstembera can you do that? |
Done. However should it be added for Windows only? |
bench: 3736029
Ok Appveyor didn't like the flag so windows only. |
other linkers might fail to link during the LTO phase. The linker might have to be installed using `pacman -Syu mingw-w64-x86_64-lld` closes official-stockfish/Stockfish#3084 No functional change.
other linkers might fail to link during the LTO phase. The linker might have to be installed using `pacman -Syu mingw-w64-x86_64-lld` closes official-stockfish#3084 No functional change.
other linkers might fail to link during the LTO phase. The linker might have to be installed using `pacman -Syu mingw-w64-x86_64-lld` closes official-stockfish#3084 No functional change.
When compiling
make build ARCH=x86-64-bmi2 COMP=clang -j
with Clang version 10.0.1 (latest from MSYS2) on Windows the link step fails with:
bench: 3736029