official-stockfish / Stockfish

A free and strong UCI chess engine
https://stockfishchess.org/
GNU General Public License v3.0
11.33k stars 2.25k forks source link

Clang-windows builds #1358

Closed d3vv closed 6 years ago

d3vv commented 6 years ago

Native Clang 5 for Windows (not mingw/msys/cygwin) using msvc libraries if its installed. Such clang will produce a "static" binary as well. Consequently we need "-Xclang -flto-visibility-public-std" CXXFLAGS into Makefile for successfully compilation. Moreover we need to remove -latomic and -lpthread from LDFLAGS. That is not all :)) If you have modern includes from Visual Studio 2017 for example, we need to replace -std=c++11 with -std=c++14 which is logical. In this case we will see characteristic warnings such as:

In file included from benchmark.cpp:26: In file included from ./position.h:29: In file included from ./bitboard.h:26: ./types.h:64:11: warning: 'IS_64BIT' macro redefined [-Wmacro-redefined]

define IS_64BIT

      ^

:2:9: note: previous definition is here

define IS_64BIT 1

    ^

1 warning generated.

As for mingw/msys/cygwin for -static LDFLAGS, we need CXXFLAGS="-Xclang -flto-visibility-public-std" too.

Unfortunately "profile-build" doesn't work for clang on windows. We can use just "build" only.

Would you like to do changes for Makefile with my suggestions? :)))

mstembera commented 6 years ago

Can you make the changes and turn this into a pull request?

d3vv commented 6 years ago

@mstembera No, I can't

mcostalba commented 6 years ago

Changing C++11 to C++14 can be done only after SF9 is out because it is a big change and will make many compilers obsolete, so it is really not something you want to do now.

snicolet commented 6 years ago

Let's reopen this one after we have decided to switch to C++14