<div dir="ltr">I guess the problem is the following:<div>Stage2 builds libomp.so instrumented with AddressSanitizer. Then omp tests are compiled without -fsanitize=address and load instrumented libomp.so which fails on missing symbols.</div><div><br></div><div>You can try to solve this in two ways:</div><div>1. Disable sanitizers on libomp.so even <span style="font-family:monospace">-DLLVM_USE_SANITIZER= is set. That can be hard if it uses some part of llvm as dependency. If so, you can try to build non-instrumented libomp.so using </span>ExternalProject_Add.</div><div>Should work but sanitizer will cover only the compiler binary not libomp.so.</div><div><span style="font-family:monospace"><br></span></div><div><span style="font-family:monospace">2. Use asan in all tests e.g. with </span>-DOPENMP_TEST_FLAGS=-fsanitize=address (better to do so in cmake file). Problem here is that stage2 does not build asan because it uses LLVM_USE_SANITIZER. We can just use stage1 compiler which contains asan libs. With a hack like this:</div><div><br></div><div>if(LLVM_USE_SANITIZER)<br> set(OPENMP_TEST_C_COMPILER ${CMAKE_C_COMPILER})<br> set(OPENMP_TEST_CXX_COMPILER ${CMAKE_CXX_COMPILER})<br><br> set(saved_CMAKE_C_FLAGS ${CMAKE_C_FLAGS})<br> set(saved_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})<br> <br> unset(CMAKE_C_FLAGS)<br> append_common_sanitizer_flags()<br> set(OPENMP_TEST_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address ${OPENMP_TEST_FLAGS}")<br><br> set(CMAKE_C_FLAGS ${saved_CMAKE_C_FLAGS})<br> set(CMAKE_CXX_FLAGS ${saved_CMAKE_CXX_FLAGS})<br>endif()<br></div><div><br></div><div>I can run most of the test:</div><div><br></div><div> Unsupported : 39<br></div><div> Passed : 241<br> Expectedly Failed: 2<br> Failed : 33 (it was 270+ before)<br></div><div><br></div><div>then you can fix or disable failing tests</div><div><br></div><div><br></div><div><br></div><div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 22 Oct 2020 at 05:31, Bryan Chan <<a href="mailto:bryanpkc@gmail.com">bryanpkc@gmail.com</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"><div dir="ltr"><div dir="ltr"><div><font face="monospace">Hi Vitaly,<br><br>This is the CMake command line I used:<br><br>cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$HOME/stage2 \<br> -DCMAKE_C_COMPILER=$HOME/stage1/bin/clang \<br> -DCMAKE_CXX_COMPILER=$HOME/stage1/bin/clang++ \<br> -DCOMPILER_RT_BUILD_BUILTINS=off -DCOMPILER_RT_BUILD_PROFILE=on \<br> -DCOMPILER_RT_BUILD_SANITIZERS=on -DCOMPILER_RT_BUILD_XRAY=off \<br> -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld;openmp" \<br> -DLLVM_ENABLE_ASSERTIONS=on -DLLVM_OPTIMIZED_TABLEGEN=on \<br> -DLLVM_STATIC_LINK_CXX_STDLIB=on -DLLVM_TARGETS_TO_BUILD="AArch64;X86" \<br> -DLLVM_USE_LINKER=gold -DLLVM_USE_SANITIZER=Address ../llvm<br><br>Stage 1 was built from the same source using the same CMake command, without<br>-DLLVM_USE_SANITIZER. CMAKE_C_FLAGS and CMAKE_CXX_FLAGS contained some<br>hardening options like "-fstack-protector-strong -D_FORTIFY_SOURCE=2" which<br>I omitted for brevity. I am building on an AArch64 CentOS system.<br><br>The Builtins-aarch64-linux test failures have disappeared after I set the<br>PATH and LD_LIBRARY_PATH environment variables to point to $HOME/stage1/bin<br>and $HOME/stage1/lib. But I still see the tools/gold/X86 and OpenMP test<br>failures.<br><br>Thanks,<br></font><div><div dir="ltr"><font face="monospace">--<br>Bryan</font></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 21, 2020 at 3:03 PM Vitaly Buka <<a href="mailto:vitalybuka@google.com" target="_blank">vitalybuka@google.com</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"><div dir="ltr">Can you please share the full cmake command line?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 21 Oct 2020 at 11:28, Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</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"><div dir="ltr"><a class="gmail_plusreply" id="gmail-m_3273732784918090638gmail-m_7026061716026343417gmail-m_-6192134940425195903plusReplyChip-0" href="mailto:vitalybuka@google.com" target="_blank">+Vitaly Buka</a> to help with the links to build bots. <br><div>Not sure if any of those cover OpenMP. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Oct 21, 2020 at 5:50 AM Bryan Chan <<a href="mailto:bryanpkc@gmail.com" target="_blank">bryanpkc@gmail.com</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"><div dir="ltr"><div><font face="monospace">Thanks Kostya, using Clang to build itself with ASan enabled, and running my<br></font></div><div><font face="monospace">build container in privileged mode, helped solve a lot of the problems. But I</font></div><div><font face="monospace">now encounter a lot of link errors while testing my stage-2 build:</font><div><font face="monospace"><br></font></div><div><font face="monospace">FAIL: libomp :: api/has_openmp.c (52345 of 54886)<br>******************** TEST 'libomp :: api/has_openmp.c' FAILED ********************<br>Script:<br>--<br>: 'RUN': at line 1'; /home/bryanpkc/llvm-project/build/./bin/clang -fopenmp -pthread -fno-experimental-isel -I /home/bryanpkc/llvm-project/openmp/runtime/test -I /home/bryanpkc/llvm-project/build/projects/openmp/runtime/src -L /home/bryanpkc/llvm-project/build/lib -I /h<br>ome/bryanpkc/llvm-project/openmp/runtime/test/ompt /home/bryanpkc/llvm-project/openmp/runtime/test/api/has_openmp.c -o /home/bryanpkc/llvm-project/build/projects/openmp/runtime/test/api/Output/has_openmp.c.tmp -lm -latomic && /home/bryanpkc/llvm-project/build/projects/openmp/runtime/test/api/Output/has_openmp.c.tmp<br>--<br>Exit Code: 1<br><br>Command Output (stdout):<br>--<br>$ ":" "RUN: at line 1"<br>$ "/home/bryanpkc/llvm-project/build/./bin/clang" "-fopenmp" "-pthread" "-fno-experimental-isel" "-I" "/home/bryanpkc/llvm-project/openmp/runtime/test" "-I" "/home/bryanpkc/llvm-project/build/projects/openmp/runtime/src" "-L" "/home/bryanpkc/llvm-project/build/lib" "-I" "/home/bryanpkc/llvm-project/openmp/runtime/test/ompt" "/home/bryanpkc/llvm-project/openmp/runtime/test/api/has_openmp.c" "-o" "/home/bryanpkc/llvm-project/build/projects/openmp/runtime/test/api/Output/has_openmp.c.tmp" "-lm" "-latomic"<br># command stderr:<br>/usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined reference to `__asan_load_cxx_array_cookie'<br>/usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined reference to `__asan_set_shadow_f8'<br>/usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined reference to `__asan_stack_malloc_8'<br>/usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined reference to `__asan_stack_malloc_2'<br>/usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined reference to `__asan_unregister_globals'<br></font><div><font face="monospace"><br></font></div><div><font face="monospace">This type of failures are affecting multiple groups of tests:</font></div><div><font face="monospace"><br></font></div><div><font face="monospace">Builtins-aarch64-linux :: *</font></div><div><font face="monospace">LLVM :: tools/gold/X86/*</font></div><div><font face="monospace">libomp :: *</font></div><div><font face="monospace">libomptarget :: *</font></div><div><font face="monospace"><br></font></div><div><div><font face="monospace">Any ideas? Could you point me to the build bot that has a good Clang/LLVM/OpenMP</font></div><div><font face="monospace">configuration with ASan enabled? Unfortunately the documentation at</font></div><div><font face="monospace"><a href="https://llvm.org/docs/CMake.html" target="_blank">https://llvm.org/docs/CMake.html</a> is not clear on how to get this working.<br></font></div><div><font face="monospace"><br clear="all"></font><div><div dir="ltr"><font face="monospace">--<br>Bryan</font></div></div><br></div></div></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 20, 2020 at 12:33 PM Kostya Serebryany <<a href="mailto:kcc@google.com" target="_blank">kcc@google.com</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"><div dir="ltr">Hi Bryan, <div><br></div><div>Yes, building LLVM with GCC+ASAN is a warranty void zone. </div><div>It can probably be made to work with some effort, but unless someone is willing to </div><div>maintain a public bot with this build, it will remain unsupported.</div><div><br></div><div>Building LLVM with LLVM+ASAN is fully supported, and the bots are maintained. </div><div><br></div><div>thanks! </div><div><br></div><div>--kcc </div><div> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Oct 20, 2020 at 7:39 AM Bryan Chan via cfe-dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.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"><div dir="ltr">Hi lists,<div><br></div><div>I am encountering a large number of check-clang failures after building Clang/LLVM with <span style="color:rgb(0,0,0);white-space:pre-wrap">-DLLVM_USE_SANITIZER=Address. </span>I have reported the issue on Bugzilla (<a href="https://bugs.llvm.org/show_bug.cgi?id=47678" target="_blank">https://bugs.llvm.org/show_bug.cgi?id=47678</a>). I cannot even compile helloworld.c with the resulting clang tool without a lot of false positives from ASan. Is it because I am not supposed to use GCC's AddressSanitizer when building Clang?</div><div><br clear="all"><div><div dir="ltr">--<br>Bryan</div></div></div></div>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>