Skip to content
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

Show compiler info at startup #2327

Closed
wants to merge 7 commits into from

Conversation

snicolet
Copy link
Member

@snicolet snicolet commented Sep 24, 2019

This patch shows a description of the compiler used to compile Stockfish when starting from the console.

Usage:

./stockfish
compiler

Example of output:

Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott

Compiled by clang++ 9.0.0 on Apple
 __VERSION__ macro expands to: 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)

No functional change

This patch shows a description of the compiler used to compile Stockfish
 when starting from the console.

Example of output:

```

Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott

Compiled by clang++ 9.0.0 on Apple
 __VERSION__ macro expands to: 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.38)

```

No functional change
@snicolet
Copy link
Member Author

snicolet commented Sep 24, 2019

We could use this to triple-check the compiler used for tournament binaries before submission.

Of course, this is only to be used in the last few days before submissions, and my plan is to revert this just after the start of TCEC super-final.

The patch is incomplete at this point because I can't test on Linux nor on Windows, any improvement appreciated.

@Rocky640
Copy link

works here on windows

Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott

Compiled by g++ (GNUC) 6.1.0 on MingGW32
 __VERSION__ macro expands to: 6.1.0

maybe we should keep this, but display this information only after some compilerinfo command

@31m059
Copy link

31m059 commented Sep 24, 2019

Windows Subsystem for Linux

Stockfish 240919 64 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott

Compiled by g++ (GNUC) 7.4.0 on unknown system
__VERSION__ macro expands to: 7.4.0

@xoto10
Copy link
Contributor

xoto10 commented Sep 24, 2019

Same linux output for me.

I like the idea of creating a compilerinfo command like eval, etc. Would allow us to do this at will without making and reverting commits.

There is not much more time before the superfinal submission is needed now, the bonus round may finish about 36 hours from now (see Schedule tab). Quote from Aloril just now about superfinal start time (after a few hours of testing) - "Maybe in about 2 days 17min" !
I guess we should submit our version tomorrow evening?

@snicolet
Copy link
Member Author

@31m059 Do you know a macro which is defined only on Windows Subsystem for Linux?
@xoto10 Same question for your version of Linux?

@Rocky640
Copy link

Rocky640 commented Sep 24, 2019

As it is MSVC does not work well here

Stockfish 240919 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott

Compiled by MSVC (version _MSC_FULL_VER._MSC_BUILD) on unknown system
 __VERSION__ macro expands to: (undefined macro)



However after the following change:

const std::string compiler_info() {
  #define STRINGIFY2(x) #x
  #define STRINGIFY(x) STRINGIFY2(x)

I get a better output

Stockfish 240919 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott

Compiled by MSVC (version 191627026.1) on unknown system
 __VERSION__ macro expands to: (undefined macro)

@ppigazzini
Copy link
Contributor

ppigazzini commented Sep 24, 2019

EDIT_000 after 33c993b
Ubuntu 18.04 cross compilation for Windows

Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 7.3.0 on MingGW32
 __VERSION__ macro expands to: 7.3-posix 20180312

@snicolet
Copy link
Member Author

snicolet commented Sep 24, 2019

Now you have to type the command in the console after launching Stockfish:

./stockfish
compiler

@snicolet
Copy link
Member Author

@Rocky640 Why is it a better output? I don't see the difference :-)

@Rocky640
Copy link

Sorry, you should see the difference now, I edited by previous post.

@snicolet
Copy link
Member Author

Thanks!

@ppigazzini
Copy link
Contributor

ppigazzini commented Sep 24, 2019

After a296668

  • WSL (Ubuntu 18.04)
Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 7.4.0 on unknown system
 __VERSION__ macro expands to: 7.4.0
  • Ubuntu 18.04
Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 7.4.0 on unknown system
 __VERSION__ macro expands to: 7.4.0
  • Ubuntu 18.04 cross compilation for Windows
Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 7.3.0 on MingGW32
 __VERSION__ macro expands to: 7.3-posix 20180312
  • msys2
Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 9.2.0 on MingGW32
 __VERSION__ macro expands to: 9.2.0
  • mingw-w64
Stockfish 240919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 8.1.0 on MingGW32
 __VERSION__ macro expands to: 8.1.0

@xoto10
Copy link
Contributor

xoto10 commented Sep 24, 2019

@snicolet
Maybe this page is useful?

@snicolet
Copy link
Member Author

@xoto10 thanks, I was also looking at https://sourceforge.net/p/predef/wiki/OperatingSystems/

@31m059
Copy link

31m059 commented Sep 25, 2019

@snicolet Sorry for the late response. To my knowledge there is no such macro; the simplest approach I've seen online is to check whether /proc/version contains the string "Microsoft".

It seems odd that there isn't one...

@gonzalezjo
Copy link

gonzalezjo commented Sep 25, 2019

@snicolet
Copy link
Member Author

OK, the systemd approach is too complicate for my taste, I will just report Linux. Can you check that it does that instead of reporting "unknown system"?

@ppigazzini
Copy link
Contributor

ppigazzini commented Sep 25, 2019

After a6d5a8b

  • WSL (Ubuntu 18.04)
Stockfish 250919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 7.4.0 on Linux
 __VERSION__ macro expands to: 7.4.0
  • Ubuntu 18.04
Stockfish 250919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 7.4.0 on Linux
 __VERSION__ macro expands to: 7.4.0
  • Ubuntu 18.04 cross compilation for Windows
Stockfish 250919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 7.3.0 on MingGW64
 __VERSION__ macro expands to: 7.3-posix 20180312
  • msys2
Stockfish 250919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 9.2.0 on MingGW64
 __VERSION__ macro expands to: 9.2.0
  • mingw-w64
Stockfish 250919 64 POPCNT by T. Romstad, M. Costalba, J. Kiiski, G. Linscott
compiler

Compiled by g++ (GNUC) 8.1.0 on MingGW64
 __VERSION__ macro expands to: 8.1.0

@snicolet
Copy link
Member Author

@ppigazzini Thanks for testing again :-)

The output is now correct, is it? Ubuntu cross compilation and msys2 do use MinGW64 as shown?

@ppigazzini
Copy link
Contributor

ppigazzini commented Sep 25, 2019

@snicolet yes
http://mingw-w64.org
http://mingw-w64.org/doku.php/download
https://en.wikipedia.org/wiki/MinGW#MinGW-w64

  • Ubuntu 18.04 cross compiler for Windows
$ x86_64-w64-mingw32-c++-posix -v
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32-c++-posix
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-w64-mingw32/7.3-posix/lto-wrapper
Target: x86_64-w64-mingw32
Configured with: ../../src/configure --build=x86_64-linux-gnu --prefix=/usr --includedir='/usr/include' --mandir='/usr/share/man' --infodir='/usr/share/info' --sysconfdir=/etc --localstatedir=/var --disable-silent-rules --libdir='/usr/lib/x86_64-linux-gnu' --libexecdir='/usr/lib/x86_64-linux-gnu' --disable-maintainer-mode --disable-dependency-tracking --prefix=/usr --enable-shared --enable-static --disable-multilib --with-system-zlib --libexecdir=/usr/lib --without-included-gettext --libdir=/usr/lib --enable-libstdcxx-time=yes --with-tune=generic --with-headers=/usr/x86_64-w64-mingw32/include --enable-version-specific-runtime-libs --enable-fully-dynamic-string --enable-libgomp --enable-languages=c,c++,fortran,objc,obj-c++,ada --enable-lto --with-plugin-ld --enable-threads=posix --program-suffix=-posix --program-prefix=x86_64-w64-mingw32- --target=x86_64-w64-mingw32 --with-as=/usr/bin/x86_64-w64-mingw32-as --with-ld=/usr/bin/x86_64-w64-mingw32-ld --enable-libatomic --enable-libstdcxx-filesystem-ts=yes
Thread model: posix
gcc version 7.3-posix 20180312 (GCC)
  • msys2
$ g++ -v
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/9.2.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../gcc-9.2.0/configure --prefix=/mingw64 --with-local-prefix=/mingw64/local --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --with-native-system-header-dir=/mingw64/x86_64-w64-mingw32/include --libexecdir=/mingw64/lib --enable-bootstrap --with-arch=x86-64 --with-tune=generic --enable-languages=c,lto,c++,fortran,ada,objc,obj-c++ --enable-shared --enable-static --enable-libatomic --enable-threads=posix --enable-graphite --enable-fully-dynamic-string --enable-libstdcxx-filesystem-ts=yes --enable-libstdcxx-time=yes --disable-libstdcxx-pch --disable-libstdcxx-debug --disable-isl-version-check --enable-lto --enable-libgomp --disable-multilib --enable-checking=release --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --enable-plugin --with-libiconv --with-system-zlib --with-gmp=/mingw64 --with-mpfr=/mingw64 --with-mpc=/mingw64 --with-isl=/mingw64 --with-pkgversion='Rev2, Built by MSYS2 project' --with-bugurl=https://sourceforge.net/projects/msys2 --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 9.2.0 (Rev2, Built by MSYS2 project)
  • mingw-w64
$ g++ -v
Using built-in specs.
COLLECT_GCC=C:\msys64\mingw64-810\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/msys64/mingw64-810/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project)

@ppigazzini
Copy link
Contributor

@ppigazzini
Copy link
Contributor

@snicolet good catch 👍

@noobpwnftw
Copy link
Contributor

noobpwnftw commented Sep 25, 2019

How about a Makefile define approach, it is easier to get information with CC -v and pass processed version string and target platform to the code.

Usually projects do that with a configure script.

@snicolet
Copy link
Member Author

snicolet commented Sep 25, 2019

@noobpwnftw
Indeed, if we somehow managed to pass to Stockfish a variable from the Makefile with the result of $COMP -v , it would be very easy to show it from the C++ code and the C++ code would be simple enough that we could keep it in master.

Does anybody want to dig into the Makefile and look if this is feasible without a configure script?

@snicolet
Copy link
Member Author

Merged via 0436f01, but I keep the pull request open, of course.

snicolet added a commit that referenced this pull request Sep 26, 2019
Revert the previous patch now that the binary for the super-final
of TCEC season 16 has been sent.

Maybe the feature of showing the name of compiler will be added to the
master branch in the future. But we may use a cleaner way to code it, see
some ideas using the Makefile approach at the end of pull request #2327 :
#2327

Bench: 3618154
@snicolet
Copy link
Member Author

Closing this pull request now that the development version has been restored in commit 8726beb.

I may open another pull request for discussing a lighter Makefile approach, as suggested here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants