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

compilation problem for os X gcc #351

Closed MehdiMhalla closed 9 years ago

MehdiMhalla commented 9 years ago

Just to say that profile build failed with gcc48 and gcc49 and gcc51 (osX 10.10.3) for both build and profile-build

the reason was g++: error: unrecognized command line option '-Wl'

PS: with clang only build worked (as usual)

Here is the message starting from the warning (same for the 3 gcc):

syzygy/tbprobe.cpp: In function 'probeab(Position&, int, int, int)': syzygy/tbprobe.cpp:206:14: warning: array subscript is above array bounds [-Warray-bounds] p[i++] = pop_lsb(&bb) ^ mirror; ^ syzygy/tbprobe.cpp:206:14: warning: array subscript is above array bounds [-Warray-bounds] syzygy/tbprobe.cpp: In function 'Tablebases::probedtz(Position&, int)': syzygy/tbprobe.cpp:316:14: warning: array subscript is above array bounds [-Warray-bounds] p[i++] = pop_lsb(&bb) ^ mirror; ^ syzygy/tbprobe.cpp:316:14: warning: array subscript is above array bounds [-Warray-bounds] g++ -o stockfish benchmark.o bitbase.o bitboard.o endgame.o evaluate.o main.o material.o misc.o movegen.o movepick.o pawns.o position.o psqt.o search.o thread.o timeman.o tt.o uci.o ucioption.o syzygy/tbprobe.o -lgcov -Wl -arch x86_64 -mmacosx-version-min=10.9 -lpthread -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11 -fprofile-generate -pedantic -Wno-long-long -Wextra -Wshadow -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -DUSE_BSFQ -flto g++: error: unrecognized command line option '-Wl' make[2]: * [stockfish] Error 1 make[1]: * [gcc-profile-make] Error 2 make: *\ [profile-build] Error 2

braich commented 9 years ago

Remove these lines and rebuild. This commit seems to be the cause of the problem. -Wl Option is used to pass options to the linker from gcc command line. From this conversation it is clear that --no-as-needed linker option must be removed for gcc compile in Darwin. So if no options must be passed to the linker then no need in -Wl option

zamar commented 9 years ago

Someone please verify that the fix suggested by braich fixes the problem for MacOSX and open a pull request.

MehdiMhalla commented 9 years ago

thx alot braich it (removing the else lines) indeed fixed the old error now it compiles for gcc48 (there is a problem with gcc5 but it is a new error and much less relevant as now there is a way to have a profile build) PS: for the gcc5 error it is it goes over the complete bench however in the creation of exe step : Total time (ms) : 37097 Nodes searched : 62254458 Nodes/second : 1678153

Step 3/4. Building final executable ... /Applications/Xcode.app/Contents/Developer/usr/bin/make ARCH=x86-64-modern COMP=gcc gcc-profile-use /Applications/Xcode.app/Contents/Developer/usr/bin/make ARCH=x86-64-modern COMP=gcc \ EXTRACXXFLAGS='-fprofile-use -fno-peel-loops -fno-tracer' \ EXTRALDFLAGS='-lgcov' \ all g++ -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wno-long-long -Wextra -Wshadow -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -DUSE_BSFQ -msse3 -mpopcnt -DUSE_POPCNT -flto -c -o benchmark.o benchmark.cpp g++ -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wno-long-long -Wextra -Wshadow -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -DUSE_BSFQ -msse3 -mpopcnt -DUSE_POPCNT -flto -c -o bitbase.o bitbase.cpp g++ -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wno-long-long -Wextra -Wshadow -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -DUSE_BSFQ -msse3 -mpopcnt -DUSE_POPCNT -flto -c -o bitboard.o bitboard.cpp g++ -Wall -Wcast-qual -fno-exceptions -fno-rtti -std=c++11 -fprofile-use -fno-peel-loops -fno-tracer -pedantic -Wno-long-long -Wextra -Wshadow -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -DUSE_BSFQ -msse3 -mpopcnt -DUSE_POPCNT -flto -c -o endgame.o endgame.cpp :492:FATAL:Symbol ___cold_sect_of_operator() already defined. make[2]: * [endgame.o] Error 1 make[1]: * [gcc-profile-use] Error 2 make: *\ [profile-build] Error 2