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

Improve Readme.md about compiling #2724

Closed
wants to merge 1 commit into from
Closed

Improve Readme.md about compiling #2724

wants to merge 1 commit into from

Conversation

nguyenpham
Copy link
Contributor

Reparagraph, add an example how to compile on Unix-like systems

Reparagraph, add an example how to compile on Unix-like systems
@vondele
Copy link
Member

vondele commented Jun 8, 2020

It would be better to use make -j profile-build ARCH=x86-64-modern in the example, that will be suitable for most users.

@nguyenpham
Copy link
Contributor Author

I use make build ARCH=x86-64 from the first example when a user types make help. Do you want me to modify Makefile too for being consistent (all will be make -j profile-build ARCH=x86-64-modern)?

@vondele
Copy link
Member

vondele commented Jun 9, 2020

yes, updating help would be good. Also, move profile-build to the first line of supported targets, and call it > standard build, while build could be > non-PGO build.

@nguyenpham
Copy link
Contributor Author

I have just tried to build with all profile-build commands: make -j profile-build ARCH=x86-64-modern and make profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-4.8. They all failed on my computer (iMac 2017, Catalina). I have called make clean before calling them to make sure they wouldn't be affected by other compiling.

I may solve/ask help to solve that problem later. However, it looks like that kind of building has a higher chance of failing for newcomers. Thus I suggest keeping the current first example (make build ARCH=x86-64) since it is the safer one.

@vondele
Copy link
Member

vondele commented Jun 9, 2020

OK, interesting, let's keep in the form you have right now.

Maybe file an issue for that, together with info on the compiler used, and the output of the compilation. I'm guessing this is specific to mac. Edit: or the very old gcc you have on the system.

@nguyenpham
Copy link
Contributor Author

In my computer gcc is actually clang and it is Apple clang version 11.0.3 (clang-1103.0.32.62) - quite up to date. I guess it is not the problem of too old compilers but too new ones ;)

@vondele
Copy link
Member

vondele commented Jun 9, 2020

so also the g++-4.8 in the make command above links to clang? Anyway, that's most likely the reason. I can get clang to profile-build with the following:

make -j ARCH=x86-64-modern COMP=clang profile-build

with the following change to the makefile (providing the specific version of llvm-profdata, which might be an ubuntu clang installation issue):

diff --git a/src/Makefile b/src/Makefile
index 016aafec1..c42edcf4d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -510,7 +510,7 @@ clang-profile-make:
        all
 
 clang-profile-use:
-       llvm-profdata merge -output=stockfish.profdata *.profraw
+       llvm-profdata-10 merge -output=stockfish.profdata *.profraw
        $(MAKE) ARCH=$(ARCH) COMP=$(COMP) \
        EXTRACXXFLAGS='-fprofile-instr-use=stockfish.profdata' \
        EXTRALDFLAGS='-fprofile-use ' \

@vondele
Copy link
Member

vondele commented Jun 9, 2020

see also #2053

@nguyenpham
Copy link
Contributor Author

nguyenpham commented Jun 9, 2020

My computer links g++ to clang but doesn't know g++-4.8. Your command make -j ARCH=x86-64-modern COMP=clang profile-build failed too:

(after changing Makefile as your suggestion)

nguyenpham@iMac src % make clean  
nguyenpham@iMac src % 
nguyenpham@iMac src % make profile-build ARCH=x86-64-bmi2 COMP=gcc COMPCXX=g++-4.8
make: [.depend] Error 127 (ignored)

Config:
debug: 'no'
sanitize: 'no'
optimize: 'yes'
arch: 'x86_64'
bits: '64'
kernel: 'Darwin'
os: ''
prefetch: 'yes'
popcnt: 'yes'
sse: 'yes'
pext: 'yes'

Flags:
CXX: g++-4.8
CXXFLAGS: -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m64 -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_PEXT -msse4 -mbmi2 -flto
LDFLAGS:  -m64 -arch x86_64 -mmacosx-version-min=10.9 -lpthread -Wall -Wcast-qual -fno-exceptions -std=c++11  -pedantic -Wextra -Wshadow -m64 -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_PEXT -msse4 -mbmi2 -flto

Testing config sanity. If this fails, try 'make help' ...


Step 1/4. Building instrumented executable ...
/Library/Developer/CommandLineTools/usr/bin/make ARCH=x86-64-bmi2 COMP=gcc gcc-profile-make
/Library/Developer/CommandLineTools/usr/bin/make ARCH=x86-64-bmi2 COMP=gcc \
	EXTRACXXFLAGS='-fprofile-generate' \
	EXTRALDFLAGS='-lgcov' \
	all
g++-4.8 -Wall -Wcast-qual -fno-exceptions -std=c++11 -fprofile-generate -pedantic -Wextra -Wshadow -m64 -arch x86_64 -mmacosx-version-min=10.9 -DNDEBUG -O3 -mdynamic-no-pic -DIS_64BIT -msse -msse3 -mpopcnt -DUSE_POPCNT -DUSE_PEXT -msse4 -mbmi2 -flto   -c -o benchmark.o benchmark.cpp
make[2]: g++-4.8: No such file or directory
make[2]: *** [benchmark.o] Error 1
make[1]: *** [gcc-profile-make] Error 2
make: *** [profile-build] Error 2

@vondele
Copy link
Member

vondele commented Jun 9, 2020

yes, you'll need to figure out how to get the llvm-profdata tool to run. Seemingly doesn't work (see issue above, or workaround I posted for ubuntu).

@vondele vondele added the to be merged Will be merged shortly label Jun 9, 2020
@MichaelB7
Copy link
Contributor

MichaelB7 commented Jun 9, 2020

Make an alias called “llvm-profdata” have it set to the actual llvm-profdata exe - name will vary by version name - add the path to the folder where the exe is located on your bash profile. My guess is that you are running Catalina OS upgraded on a Mac that was running Mojave.

@vondele vondele closed this in b081e52 Jun 9, 2020
@vondele
Copy link
Member

vondele commented Jun 9, 2020

Thanks!

MichaelB7 pushed a commit to MichaelB7/Stockfish that referenced this pull request Jun 13, 2020
Reparagraph, add an example how to compile on Unix-like systems

closes official-stockfish#2724

No functional change
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
to be merged Will be merged shortly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants