termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
13.3k stars 3.06k forks source link

Clang-10 error PGO #5539

Closed Alexei1981 closed 4 years ago

Alexei1981 commented 4 years ago

Hey. The clang has a profiling error. In the Clang-9 version (previous) this was not. Here is the full reproduction of the compilation error.


make profile-build COMP=clang ARCH=armv8 -j7

Config:
debug: 'no'
optimize: 'yes'
arch: 'armv8'
bits: '64'
prefetch: 'no'
popcnt: 'yes'
sse: 'no'
pext: 'no'

Flags:
CC: clang
CFLAGS: -Wall -std=c11  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE
LDFLAGS:  -lm -Wall -std=c11  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE -static-libgcc -fPIE -pie

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

Step 1/4. Building instrumented executable ...
make ARCH=armv8 COMP=clang clang-profile-make
make[1]: Entering directory '/data/data/com.termux/files/home/src'
make ARCH=armv8 COMP=clang \
EXTRACFLAGS='-fprofile-instr-generate ' \
EXTRALDFLAGS=' -fprofile-instr-generate' \
all
make[2]: Entering directory '/data/data/com.termux/files/home/src'
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o benchmark.o benchmark.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o bitbase.o bitbase.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o bitboard.o bitboard.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o endgame.o endgame.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o evaluate.o evaluate.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o main.o main.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o material.o material.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o misc.o misc.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o movegen.o movegen.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o movepick.o movepick.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o pawns.o pawns.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o position.o position.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o psqt.o psqt.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o search.o search.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o tbprobe.o tbprobe.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o thread.o thread.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o timeman.o timeman.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o tt.o tt.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o uci.o uci.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o ucioption.o ucioption.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o numa.o numa.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o settings.o settings.c
clang -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE   -c -o polybook.o polybook.c
clang -o cfish 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 tbprobe.o thread.o timeman.o tt.o uci.o ucioption.o numa.o settings.o polybook.o -fprofile-instr-generate -lm -Wall -std=c11 -fprofile-instr-generate  -pedantic -Wextra -Wshadow -Wno-missing-braces -Wno-missing-field-initializers -Wno-unknown-attributes -D_POSIX_C_SOURCE=199506L -DNDEBUG -O3 -DIS_64BIT -DUSE_POPCNT -flto -march=armv8-a -fPIE -static-libgcc -fPIE -pie
make[2]: Leaving directory '/data/data/com.termux/files/home/src'
make[1]: Leaving directory '/data/data/com.termux/files/home/src'

Step 2/4. Running benchmark for pgo-build ...
./cfish bench 16 1 15 > /dev/null

Position: 1/47

Position: 2/47

Position: 3/47

Position: 4/47

Position: 5/47

Position: 6/47

Position: 7/47

Position: 8/47

Position: 9/47

Position: 10/47

Position: 11/47

Position: 12/47

Position: 13/47

Position: 14/47

Position: 15/47

Position: 16/47

Position: 17/47

Position: 18/47

Position: 19/47

Position: 20/47

Position: 21/47

Position: 22/47

Position: 23/47

Position: 24/47

Position: 25/47

Position: 26/47

Position: 27/47

Position: 28/47

Position: 29/47

Position: 30/47

Position: 31/47

Position: 32/47

Position: 33/47

Position: 34/47

Position: 35/47

Position: 36/47

Position: 37/47

Position: 38/47

Position: 39/47

Position: 40/47

Position: 41/47

Position: 42/47

Position: 43/47

Position: 44/47

Position: 45/47

Position: 46/47

Position: 47/47

===========================
Total time (ms) : 39915
Nodes searched  : 10328120
Nodes/second    : 258752

Step 3/4. Building optimized executable ...
make ARCH=armv8 COMP=clang objclean
make[1]: Entering directory '/data/data/com.termux/files/home/src'
make[1]: Leaving directory '/data/data/com.termux/files/home/src'
make ARCH=armv8 COMP=clang clang-profile-use
make[1]: Entering directory '/data/data/com.termux/files/home/src'
llvm-profdata merge -output=cfish.profdata *.profraw
warning: default.profraw: Unsupported instrumentation profile format version
error: No profiles could be merged.
make[1]: *** [Makefile:522: clang-profile-use] Error 1
make[1]: Leaving directory '/data/data/com.termux/files/home/src'
make: *** [Makefile:448: profile-build] Error 2
Grimler91 commented 4 years ago

What project are you building here?

Alexei1981 commented 4 years ago

@Grimler91 chess engine: https://github.com/syzygy1/Cfish

finagolfin commented 4 years ago

If you could give us info about what's actually missing from clang 10, we could maybe fix it for you.

Alexei1981 commented 4 years ago

Thanks. A profiling bug has been fixed in the latest version of the compiler. Everything works well now. I think the whole problem was in the libcompiler-rt libraries. It's okay now.

chadbrewbaker commented 3 years ago

Still broken on macOS arm64. :( They didn't link zlib properly and it opens so many file pointers that sysctl kills it on large projects. Trying a fresh build of apple-llvm-project to see if they fixed it.