<div dir="ltr"><div>What compiler are you using to compile stage 1?</div><div><br></div><div>I get a different failure during stage 2:</div><div><br></div><div>[1864/2833] Building DiagnosticParseKinds.inc...<br>FAILED: tools/clang/include/clang/Basic/DiagnosticParseKinds.inc <br>cd /local/ssd1/sajjadm/llvm-project/stage2 && /local/ssd1/sajjadm/llvm-project/stage2/bin/clang-tblgen -gen-clang-diags-defs -clang-component=Parse -I /local/ssd1/sajjadm/llvm-project/clang/include/clang/Basic -I /local/ssd1/sajjadm/llvm-project/llvm/include /local/ssd1/sajjadm/llvm-project/clang/include/clang/Basic/Diagnostic.td -o tools/clang/include/clang/Basic/DiagnosticParseKinds.inc -d tools/clang/include/clang/Basic/DiagnosticParseKinds.inc.d<br>pure virtual method called<br>terminate called without an active exception<br></div><div><br></div><div>I made a small tweak to the source code (commented out the new function's declaration in InstrProfiling.h) and with that stage 2 compiled cleanly but then stage 3 had a similar problem:</div><div><br></div><div>FAILED: lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o <br>/local/ssd1/sajjadm/llvm-project/stage2/bin/clang++  -DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Demangle -I/local/ssd1/sajjadm/llvm-project/llvm/lib/Demangle -I/usr/include/libxml2 -Iinclude -I/local/ssd1/sajjadm/llvm-project/llvm/include -fPIC -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion -fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG    -fno-exceptions -fno-rtti -MD -MT lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o -MF lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o.d -o lib/Demangle/CMakeFiles/LLVMDemangle.dir/Demangle.cpp.o -c /local/ssd1/sajjadm/llvm-project/llvm/lib/Demangle/Demangle.cpp<br>pure virtual method called<br>terminate called without an active exception<br></div><div><br></div><div>My stage 1 compiler is GCC 7.3.0</div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 12, 2019 at 1:42 AM Hans Wennborg <<a href="mailto:hans@chromium.org" target="_blank">hans@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">We noticed in Chromium (we're trying to start building Clang itself<br>
with PGO) that this change is causing IR-instrumented Clang to become<br>
crashy. (+gbiv in case he saw similar issues)<br>
<br>
I've reverted it (and the follow-up with test cases) in r363134.<br>
<br>
To reproduce on a Linux workstation, in the llvm monorepo checked out<br>
at c1867557d93d622f761b57af6e66e3e518bc0b9f / r362676<br>
<br>
$ ( mkdir build.stage1 && cd build.stage1 && cmake -GNinja<br>
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS="clang;compiler-rt"<br>
../llvm && ninja )<br>
$ ( mkdir build.stage2 && cd build.stage2 &&<br>
CC=${PWD}/../build.stage1/bin/clang<br>
CXX=${PWD}/../build.stage1/bin/clang++ cmake -GNinja<br>
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang<br>
-DLLVM_BUILD_INSTRUMENTED=IR ../llvm && ninja clang )<br>
$ ( mkdir build.stage3 && cd build.stage3 &&<br>
CC=${PWD}/../build.stage2/bin/clang<br>
CXX=${PWD}/../build.stage2/bin/clang++ cmake -GNinja<br>
-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang ../llvm &&<br>
ninja clang )<br>
<br>
The instrumented Clang now crashes pretty soon, in this case:<br>
<br>
[5/2833] Building CXX object<br>
lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.cpp.o<br>
FAILED: lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.cpp.o<br>
/work/llvm.monorepo/build.stage2/bin/clang++  -DGTEST_HAS_RTTI=0<br>
-D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS<br>
-D__STDC_LIMIT_MACROS -Ilib/Support<br>
-I/work/llvm.monorepo/llvm/lib/Support -I/usr/include/libxml2<br>
-Iinclude -I/work/llvm.monorepo/llvm/include -fPIC<br>
-fvisibility-inlines-hidden -Werror=date-time<br>
-Werror=unguarded-availability-new -std=c++11 -Wall -Wextra<br>
-Wno-unused-parameter -Wwrite-strings -Wcast-qual<br>
-Wmissing-field-initializers -pedantic -Wno-long-long<br>
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type<br>
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion<br>
-fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG<br>
 -fno-exceptions -fno-rtti -MD -MT<br>
lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.cpp.o -MF<br>
lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.cpp.o.d -o<br>
lib/Support/CMakeFiles/LLVMSupport.dir/ConvertUTF.cpp.o -c<br>
/work/llvm.monorepo/llvm/lib/Support/ConvertUTF.cpp<br>
/work/llvm.monorepo/build.stage2/bin/clang++(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x27)[0x2b98537]<br>
/work/llvm.monorepo/build.stage2/bin/clang++[0x2b98c3f]<br>
/lib/x86_64-linux-gnu/libpthread.so.0(+0x123a0)[0x7f8ad19a03a0]<br>
/work/llvm.monorepo/build.stage2/bin/clang++[0x5817d2b]<br>
/work/llvm.monorepo/build.stage2/bin/clang++[0x5817c42]<br>
/work/llvm.monorepo/build.stage2/bin/clang++[0x58172e2]<br>
/lib/x86_64-linux-gnu/libc.so.6(+0x392ec)[0x7f8ad04942ec]<br>
/lib/x86_64-linux-gnu/libc.so.6(+0x3941a)[0x7f8ad049441a]<br>
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf2)[0x7f8ad047e532]<br>
/work/llvm.monorepo/build.stage2/bin/clang++(_start+0x2a)[0xa2b75a]<br>
<br>
It's interesting to see libpthread.so on the stack. Maybe that<br>
suggests recursive locking or something?<br>
<br>
Trying to recompile just that file with the instrumented Clang works<br>
fine, the crash doesn't happen every time (which is why I haven't<br>
caught it in a debugger), but running many compilations in parallel<br>
reproduces the issue fairly reliably:<br>
<br>
$ cd build.stage3<br>
$ for x in `seq 1 100` ; do ( ../build.stage2/bin/clang++<br>
-DGTEST_HAS_RTTI=0 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS<br>
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Ilib/Support<br>
-I../llvm/lib/Support -Iinclude -I../llvm/include -fPIC<br>
-fvisibility-inlines-hidden -Werror=date-time<br>
-Werror=unguarded-availability-new -std=c++11 -Wall -Wextra<br>
-Wno-unused-parameter -Wwrite-strings -Wcast-qual<br>
-Wmissing-field-initializers -pedantic -Wno-long-long<br>
-Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type<br>
-Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion<br>
-fdiagnostics-color -ffunction-sections -fdata-sections -O3 -DNDEBUG<br>
-fno-exceptions -fno-rtti -c ../llvm/lib/Support/ConvertUTF.cpp -o<br>
/dev/null && echo OK ) & done<br>
<br>
/work/llvm.monorepo/build.stage2/bin/clang-9(_ZN4llvm3sys15PrintStackTraceERNS_11raw_ostreamE+0x27)[0x2b98537]<br>
/work/llvm.monorepo/build.stage2/bin/clang-9[0x2b98c3f]<br>
/lib/x86_64-linux-gnu/libpthread.so.0(+0x123a0)[0x7fd08f2bf3a0]<br>
/work/llvm.monorepo/build.stage2/bin/clang-9[0x5817d2b]<br>
/work/llvm.monorepo/build.stage2/bin/clang-9[0x5817c42]<br>
/work/llvm.monorepo/build.stage2/bin/clang-9[0x58172e2]<br>
/lib/x86_64-linux-gnu/libc.so.6(+0x392ec)[0x7fd08ddb32ec]<br>
/lib/x86_64-linux-gnu/libc.so.6(+0x3941a)[0x7fd08ddb341a]<br>
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf2)[0x7fd08dd9d532]<br>
/work/llvm.monorepo/build.stage2/bin/clang-9(_start+0x2a)[0xa2b75a]<br>
clang-9: error: unable to execute command: Segmentation fault<br>
clang-9: error: clang frontend command failed due to signal (use -v to<br>
see invocation)<br>
clang version 9.0.0 (<a href="https://github.com/llvm/llvm-project" rel="noreferrer" target="_blank">https://github.com/llvm/llvm-project</a><br>
c1867557d93d622f761b57af6e66e3e518bc0b9f)<br>
Target: x86_64-unknown-linux-gnu<br>
Thread model: posix<br>
InstalledDir: /work/llvm.monorepo/build.stage3/../build.stage2/bin<br>
<br>
<br>
On Thu, Jun 6, 2019 at 8:32 AM Xinliang David Li via llvm-commits<br>
<<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>> wrote:<br>
><br>
> Author: davidxl<br>
> Date: Wed Jun  5 23:35:18 2019<br>
> New Revision: 362676<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=362676&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=362676&view=rev</a><br>
> Log:<br>
> [Profile]: Add runtime interface to specify file handle for profile data.<br>
><br>
> Author: Sajjad Mirza<br>
><br>
> Differential Revision: <a href="http://reviews.llvm.org/D62541" rel="noreferrer" target="_blank">http://reviews.llvm.org/D62541</a><br>
</blockquote></div>