<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 - clang's -nodefaultlibs breaks XRay instrumentation"
   href="https://bugs.llvm.org/show_bug.cgi?id=40579">40579</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang's -nodefaultlibs breaks XRay instrumentation
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>XRay
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </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>enhancement
          </td>
        </tr>

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

        <tr>
          <th>Component</th>
          <td>Clang
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>dberris@google.com
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>lebedev.ri@gmail.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>I have just tried to build LLVM with xray instrumentation, and it fails with

CMake Warning at /build/libcxx/cmake/Modules/CheckLibcxxAtomic.cmake:52
(message):
  Host compiler appears to require libatomic, but cannot find it.
Call Stack (most recent call first):
  /build/libcxx/cmake/config-ix.cmake:63 (include)
  /build/libcxx/CMakeLists.txt:471 (include)


CMake Error at /build/libcxx/CMakeLists.txt:526 (message):
  C++11 or greater is required but the compiler does not support c++11


Configuring incomplete, errors occurred!


I have digged, and:

$ cat /tmp/test.cpp 
int main(int argc, char* argv[]) {
  return 0;
}
$ clang++ -fxray-instrument -fxray-instruction-threshold=0 -nodefaultlibs
/tmp/test.cpp 
ld: error: undefined symbol: __libc_csu_fini
<span class="quote">>>> referenced by /usr/lib64/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o:(_start)</span >

ld: error: undefined symbol: __libc_csu_init
<span class="quote">>>> referenced by /usr/lib64/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o:(_start)</span >

ld: error: undefined symbol: __libc_start_main
<span class="quote">>>> referenced by /usr/lib64/gcc/x86_64-linux-gnu/8/../../../x86_64-linux-gnu/crt1.o:(_start)</span >

ld: error: undefined symbol: __errno_location
<span class="quote">>>> referenced by sanitizer_allocator_checks.cc.o:(__sanitizer::SetErrnoToENOMEM()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: sigaction
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::internal_sigaction(int, void const*, void*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: getrlimit
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: pthread_attr_init
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: pthread_self
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: pthread_getattr_np
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: pthread_attr_destroy
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetThreadStackTopAndBottom(bool, unsigned long*, unsigned long*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: dlsym
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::SetEnv(char const*, char const*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: dlsym
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::InitTlsSize()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: confstr
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::ThreadDescriptorSize()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: dl_iterate_phdr
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::ListOfModules::init()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: getrusage
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetRSS()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: sched_getaffinity
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetNumberOfCPUs()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: __sched_cpucount
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::GetNumberOfCPUs()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: syslog
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::WriteOneLineToSyslog(char const*)) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: clock_gettime
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::MonotonicNanoTime()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: undefined symbol: getauxval
<span class="quote">>>> referenced by sanitizer_linux_libcdep.cc.o:(__sanitizer::ReExec()) in archive /usr/lib/llvm-9/lib/clang/9.0.0/lib/linux/libclang_rt.xray-x86_64.a</span >

ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all
errors)
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$ clang++ -fxray-instrument -fxray-instruction-threshold=0 /tmp/test.cpp 
$ # so it is -nodefaultlibs that is the culprit.</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>