[LLVMbugs] [Bug 22690] New: Add option to add -lc++abi flag to TSan lit tests

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Tue Feb 24 22:50:19 PST 2015


            Bug ID: 22690
           Summary: Add option to add -lc++abi flag to TSan lit tests
           Product: compiler-rt
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: compiler-rt
          Assignee: unassignedbugs at nondot.org
          Reporter: will at wmitchell.net
                CC: llvmbugs at cs.uiuc.edu
    Classification: Unclassified

When using libc++ with libc++abi on Linux (Debian Testing for me) it becomes
necessary to manually link to libc++abi by adding -lc++abi when linking against
libc++. (Though some changes may happen regarding this, see

The problem is I see 128 test case failures all within ThreadSanitizer. All of
the failures look like:

FAIL: ThreadSanitizer :: write_in_reader_lock.cc (182 of 268)
******************** TEST 'ThreadSanitizer :: write_in_reader_lock.cc' FAILED
/home/will/Repos/llvm_projects/build/./bin/clang --driver-mode=g++
-fsanitize=thread -Wall -m64 -gline-tables-only -std=c++11
/home/will/Repos/llvm_projects/compiler-rt/test/tsan/write_in_reader_lock.cc -o
| FileCheck
Exit Code: 1

Command Output (stderr):
undefined reference to `std::bad_alloc::bad_alloc()'
undefined reference to `__cxa_current_primary_exception'
undefined reference to `__cxa_uncaught_exception'
undefined reference to `__cxa_increment_exception_refcount'
undefined reference to `std::bad_cast::bad_cast()'
undefined reference to `__cxa_decrement_exception_refcount'
undefined reference to `__cxa_rethrow_primary_exception'
clang-3.7: error: linker command failed with exit code 1 (use -v to see


These are all because libc++abi isn't being linked into the TSan test cases.

I have checked out the git repos of clang, clang-tools-extra, compiler-rt,
libcxx, libcxxabi, lldb, and llvm. Appropriate symlinks are set up to build
everything with cmake, with libcxx, libcxxabi, and compiler-rt in particular
symlinked out of llvm/projects.

I'm configuring cmake as:
CC=clang CXX=clang++ cmake ../llvm -G Ninja -DCMAKE_BUILD_TYPE=Release

and building by:
ninja && ninja check-all

I have verified that adding -lc++abi fixes these errors by applying the
following patch:

diff --git a/test/lit.common.cfg b/test/lit.common.cfg
index 0a55186..1c76ccf 100644
--- a/test/lit.common.cfg
+++ b/test/lit.common.cfg
@@ -22,7 +22,7 @@ if (not compiler_path) or (not
 compiler_id = getattr(config, 'compiler_id', None)
 if compiler_id == "Clang":
   if platform.system() != 'Windows':
-    config.cxx_mode_flags = ["--driver-mode=g++"]
+    config.cxx_mode_flags = ["--driver-mode=g++ -lc++abi"]
     config.cxx_mode_flags = []
   # We assume that sanitizers should provide good enough error

Of course this patch is completely wrong as it is the wrong place to add the
flag, but it was the first obvious place I saw that would propogate through to
building the tests to verify the problem/solution.

It seems to me the correct fix is to add a CMake option of something like
COMPILER_RT_LINK_LIBCXXABI, but I don't understand lit well enough to provide a
patch. It might also be that this option should be in LLVM's CMake, but as far
as I can see only TSan currently runs tests that use the standard library.

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150225/3edbee84/attachment.html>

More information about the llvm-bugs mailing list