<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Building LLVM 7.0 with libstdc++ 8, clang 6 and MemorySanitizer enabled failes on invocation of llvm-tblgen"
   href="https://bugs.llvm.org/show_bug.cgi?id=39128">39128</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Building LLVM 7.0 with libstdc++ 8, clang 6 and MemorySanitizer enabled failes on invocation of llvm-tblgen
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>new-bugs
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>new bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>t.klatt.oss@mailbox.org
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I'm trying to build (at least) libcxx and libcxxabi with MemorySanitizer in
order to reduce false positives when using MemorySanitizer with my own code.

I'm using the Clang 6.0 as provided via Ubuntu packages and the following CMake
call:

cmake -GNinja -DCMAKE_INSTALL_PREFIX=/opt/llvm/dist/7.0.0 \
  -DCMAKE_C_COMPILER=/usr/bin/clang \
  -DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
  -DCMAKE_BUILD_TYPE=Release \
  -DLLVM_INCLUDE_EXAMPLES=OFF \
  -DLLVM_INCLUDE_BENCHMARKS=OFF \
  -DLLVM_INCLUDE_TESTS=OFF \
  -DLLVM_USE_LINKER=gold \
  -DLLVM_BUILD_LLVM_DYLIB=ON \
  -DLLVM_CCACHE_BUILD=ON \
  -DLLVM_CCACHE_DIR=/opt/llvm/ccache \
  -DLLVM_USE_SANITIZER=Memory \
  -DLLVM_ENABLE_PROJECTS="clang;libcxx;libcxxabi;openmp;compiler-rt;lld;polly"
\
  /opt/llvm/src/7.0.0/llvm

and subsequently

$> ninja all
[  3% - 4327/6/<a href="mailto:180@2.1">180@2.1</a> - 83.887] Building Attributes.inc...
FAILED: include/llvm/IR/Attributes.inc.tmp 
cd /opt/llvm/build/7.0.0 && /opt/llvm/build/7.0.0/bin/llvm-tblgen -gen-attrs -I
/opt/llvm/src/7.0.0/llvm/include/llvm/IR -I /opt/llvm/src/7.0.0/llvm/include
/opt/llvm/src/7.0.0/llvm/include/llvm/IR/Attributes.td -o
include/llvm/IR/Attributes.inc.tmp -d include/llvm/IR/Attributes.inc.d
==8842==WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 0x6a6aaf in _M_lower_bound
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_tree.h:1903:7
    #1 0x6a6aaf in find
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_tree.h:2552
    #2 0x6a6aaf in find
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_map.h:1195
    #3 0x6a6aaf in llvm::RecordKeeper::getClass(llvm::StringRef) const
/opt/llvm/src/7.0.0/llvm/include/llvm/TableGen/Record.h:1612
    #4 0xb4ae6e in llvm::TGParser::ParseClass()
/opt/llvm/src/7.0.0/llvm/lib/TableGen/TGParser.cpp:2648:28
    #5 0xb4ac7b in llvm::TGParser::ParseObject(llvm::MultiClass*)
/opt/llvm/src/7.0.0/llvm/lib/TableGen/TGParser.cpp:3010:12
    #6 0xb527ca in llvm::TGParser::ParseFile()
/opt/llvm/src/7.0.0/llvm/lib/TableGen/TGParser.cpp:3022:9
    #7 0xac535f in llvm::TableGenMain(char*, bool (*)(llvm::raw_ostream&,
llvm::RecordKeeper&)) /opt/llvm/src/7.0.0/llvm/lib/TableGen/Main.cpp:96:14
    #8 0x9f3163 in main
/opt/llvm/src/7.0.0/llvm/utils/TableGen/TableGen.cpp:247:10
    #9 0x7fccbb16bb96 in __libc_start_main
/build/glibc-OTsEL5/glibc-2.27/csu/../csu/libc-start.c:310
    #10 0x424b29 in _start (/opt/llvm/build/7.0.0/bin/llvm-tblgen+0x424b29)

SUMMARY: MemorySanitizer: use-of-uninitialized-value
/usr/bin/../lib/gcc/x86_64-linux-gnu/8/../../../../include/c++/8/bits/stl_tree.h:1903:7
in _M_lower_bound
Exiting
[  4% - 4327/1/<a href="mailto:185@2.1">185@2.1</a> - 86.645] Building CXX object
lib/MC/CMakeFiles/LLVMMC.dir/ELFObjectWriter.cpp.o
ninja: build stopped: subcommand failed.


It seems, Clang is using the libstdc++ from the GCC 8 installation (via Ubuntu
packages).

$> /usr/bin/gcc-8 --version
gcc-8 (Ubuntu 8.2.0-1ubuntu2~18.04) 8.2.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$> /usr/bin/clang --version
clang version 6.0.0-1ubuntu2 (tags/RELEASE_600/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin


I'm happy to provide further information.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>