<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 - Linking fails on C programs with xray instrumentation enabled"
   href="https://bugs.llvm.org/show_bug.cgi?id=34904">34904</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Linking fails on C programs with xray instrumentation enabled
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </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>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>jbulow-llvm@jongel.net
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>According to documentation it should be possible to use xray instrumentation on
C program by specifying the flags -fxray-instrument.

Linking fails when compiling the following program:

----8<----- (minimal.c)
int main ()
{
  return 0;
}
----8<-----
$ clang --version
clang version 6.0.0 (trunk 315272)
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /home/jonasbu/local/bin

$ clang -fxray-instrument minimal.c                                             
/home/jonasbu/local/lib/clang/6.0.0/lib/linux/libclang_rt.xray-x86_64.a(xray_inmemory_log.cc.o):
In function `getGlobalFd()':
/home/jonasbu/llvm-clang/llvm/projects/compiler-rt/lib/xray/xray_inmemory_log.cc:123:
undefined reference to `__cxa_guard_acquire'
/home/jonasbu/llvm-clang/llvm/projects/compiler-rt/lib/xray/xray_inmemory_log.cc:123:
undefined reference to `__cxa_guard_release'
/home/jonasbu/local/lib/clang/6.0.0/lib/linux/libclang_rt.xray-x86_64.a(xray_inmemory_log.cc.o):
In function `__xray_InMemoryRawLog<__xray_InMemoryEmulateTSC(int32_t,
XRayEntryType)::<lambda(uint8_t&)> >':
/home/jonasbu/llvm-clang/llvm/projects/compiler-rt/lib/xray/xray_inmemory_log.cc:136:
undefined reference to `__cxa_thread_atexit'
/home/jonasbu/local/lib/clang/6.0.0/lib/linux/libclang_rt.xray-x86_64.a(xray_inmemory_log.cc.o):
In function `__xray_OpenLogFile':
/home/jonasbu/llvm-clang/llvm/projects/compiler-rt/lib/xray/xray_inmemory_log.cc:85:
undefined reference to `__cxa_guard_acquire'
/home/jonasbu/llvm-clang/llvm/projects/compiler-rt/lib/xray/xray_inmemory_log.cc:85:
undefined reference to `__cxa_guard_release'
/home/jonasbu/llvm-clang/llvm/projects/compiler-rt/lib/xray/xray_inmemory_log.cc:87:
undefined reference to `__cxa_guard_acquire'
/home/jonasbu/llvm-clang/llvm/projects/compiler-rt/lib/xray/xray_inmemory_log.cc:87:
undefined reference to `__cxa_guard_release'
...
...
...

As expected, the same program compiles and links fine as a C++ program:

$ clang++ -xc++ -fxray-instrument minimal.c
<no output>
$</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>