[cfe-dev] AddressSanitizer

Bryan Chan via cfe-dev cfe-dev at lists.llvm.org
Thu Oct 22 05:30:29 PDT 2020


Hi Vitaly,

This is the CMake command line I used:

cmake -G Ninja -DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=$HOME/stage2 \
      -DCMAKE_C_COMPILER=$HOME/stage1/bin/clang \
      -DCMAKE_CXX_COMPILER=$HOME/stage1/bin/clang++ \
      -DCOMPILER_RT_BUILD_BUILTINS=off -DCOMPILER_RT_BUILD_PROFILE=on \
      -DCOMPILER_RT_BUILD_SANITIZERS=on -DCOMPILER_RT_BUILD_XRAY=off \
      -DLLVM_ENABLE_PROJECTS="clang;compiler-rt;lld;openmp" \
      -DLLVM_ENABLE_ASSERTIONS=on -DLLVM_OPTIMIZED_TABLEGEN=on \
      -DLLVM_STATIC_LINK_CXX_STDLIB=on
-DLLVM_TARGETS_TO_BUILD="AArch64;X86" \
      -DLLVM_USE_LINKER=gold -DLLVM_USE_SANITIZER=Address ../llvm

Stage 1 was built from the same source using the same CMake command, without
-DLLVM_USE_SANITIZER. CMAKE_C_FLAGS and CMAKE_CXX_FLAGS contained some
hardening options like "-fstack-protector-strong -D_FORTIFY_SOURCE=2" which
I omitted for brevity. I am building on an AArch64 CentOS system.

The Builtins-aarch64-linux test failures have disappeared after I set the
PATH and LD_LIBRARY_PATH environment variables to point to $HOME/stage1/bin
and $HOME/stage1/lib. But I still see the tools/gold/X86 and OpenMP test
failures.

Thanks,
--
Bryan


On Wed, Oct 21, 2020 at 3:03 PM Vitaly Buka <vitalybuka at google.com> wrote:

> Can you please share the full cmake command line?
>
> On Wed, 21 Oct 2020 at 11:28, Kostya Serebryany <kcc at google.com> wrote:
>
>> +Vitaly Buka <vitalybuka at google.com> to help with the links to build
>> bots.
>> Not sure if any of those cover OpenMP.
>>
>> On Wed, Oct 21, 2020 at 5:50 AM Bryan Chan <bryanpkc at gmail.com> wrote:
>>
>>> Thanks Kostya, using Clang to build itself with ASan enabled, and
>>> running my
>>> build container in privileged mode, helped solve a lot of the problems.
>>> But I
>>> now encounter a lot of link errors while testing my stage-2 build:
>>>
>>> FAIL: libomp :: api/has_openmp.c (52345 of 54886)
>>> ******************** TEST 'libomp :: api/has_openmp.c' FAILED
>>> ********************
>>> Script:
>>> --
>>> : '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
>>> 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
>>> --
>>> Exit Code: 1
>>>
>>> Command Output (stdout):
>>> --
>>> $ ":" "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"
>>> "/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"
>>> # command stderr:
>>> /usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined
>>> reference to `__asan_load_cxx_array_cookie'
>>> /usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined
>>> reference to `__asan_set_shadow_f8'
>>> /usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined
>>> reference to `__asan_stack_malloc_8'
>>> /usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined
>>> reference to `__asan_stack_malloc_2'
>>> /usr/bin/ld: /home/bryanpkc/llvm-project/build/lib/libomp.so: undefined
>>> reference to `__asan_unregister_globals'
>>>
>>> This type of failures are affecting multiple groups of tests:
>>>
>>> Builtins-aarch64-linux :: *
>>> LLVM :: tools/gold/X86/*
>>> libomp :: *
>>> libomptarget :: *
>>>
>>> Any ideas? Could you point me to the build bot that has a good
>>> Clang/LLVM/OpenMP
>>> configuration with ASan enabled? Unfortunately the documentation at
>>> https://llvm.org/docs/CMake.html is not clear on how to get this
>>> working.
>>>
>>> --
>>> Bryan
>>>
>>>
>>> On Tue, Oct 20, 2020 at 12:33 PM Kostya Serebryany <kcc at google.com>
>>> wrote:
>>>
>>>> Hi Bryan,
>>>>
>>>> Yes, building LLVM with GCC+ASAN is a warranty void zone.
>>>> It can probably be made to work with some effort, but unless someone is
>>>> willing to
>>>> maintain a public bot with this build, it will remain unsupported.
>>>>
>>>> Building LLVM with LLVM+ASAN is fully supported, and the bots are
>>>> maintained.
>>>>
>>>> thanks!
>>>>
>>>> --kcc
>>>>
>>>>
>>>> On Tue, Oct 20, 2020 at 7:39 AM Bryan Chan via cfe-dev <
>>>> cfe-dev at lists.llvm.org> wrote:
>>>>
>>>>> Hi lists,
>>>>>
>>>>> I am encountering a large number of check-clang failures after
>>>>> building Clang/LLVM with -DLLVM_USE_SANITIZER=Address. I have
>>>>> reported the issue on Bugzilla (
>>>>> https://bugs.llvm.org/show_bug.cgi?id=47678). 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?
>>>>>
>>>>> --
>>>>> Bryan
>>>>> _______________________________________________
>>>>> cfe-dev mailing list
>>>>> cfe-dev at lists.llvm.org
>>>>> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>>>>>
>>>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20201022/750f014f/attachment-0001.html>


More information about the cfe-dev mailing list