AndyGrant / Ethereal

Ethereal, a UCI Chess Engine by Andrew Grant
GNU General Public License v3.0
343 stars 79 forks source link

Missing -static in CFLAGS? #215

Open mibere opened 3 months ago

mibere commented 3 months ago

Hi Andrew,

the compilation with

mingw32-make pgo

on Windows 10 with MSYS2 CLANG64 (clang: 18.1.8, Target: x86_64-w64-windows-gnu, Thread model: posix) is successful, you can run the created 64bit executable (Ethereal.exe) without problems in the MSYS2 environment.

But, if you try to run the executable outside of the MSYS2 environment there is an error that the libwinpthread-1.dll is missing.

I solved it by changing line 45 in the makefile

CFLAGS   = -O3 $(WFLAGS) -DNDEBUG -flto $(NN) $(NNFLAGS) -march=native

to

CFLAGS   = -O3 $(WFLAGS) -DNDEBUG -flto $(NN) $(NNFLAGS) -march=native -static

Or even better here

...
RFLAGS   = -O3 $(WFLAGS) -DNDEBUG -flto $(NN) $(NNFLAGS) -static
CFLAGS   = -O3 $(WFLAGS) -DNDEBUG -flto $(NN) $(NNFLAGS) -march=native
TFLAGS   = -O3 $(WFLAGS) -DNDEBUG -flto $(NN) $(NNFLAGS) -march=native -fopenmp -DTUNE
PGOFLAGS = -fno-asynchronous-unwind-tables

ifeq ($(MSYSTEM), CLANG64)
    CFLAGS += -static
endif
...
AndyGrant commented 3 months ago

Yeah I would not say that in general the -static is missing. I have some release targets that use -static. The assumption is that non-release targets are native builds ( hence -march=native ).

Although none of the release targets will satisfy you, as they are all intended for specific architectures, and will lose some benefit that is obtained with the native builds. So your local hack is probably a long term solution.

I hate makefiles. They are incoherently hard to use for no reason. However, allowing a static=1 or static=on or something in compilation, to force add -static, is not too terrible a thing to have.

mibere commented 3 months ago

Feel free to close this ticket or keep it open as reminder.

For me, the easiest way to set up and use Clang on Windows is with MSYS2. In this case, however, the use of -static is more or less mandatory.

In the meantime, I have created a fork of the repository in which I use a customized makefile, also with PGO for non-native.