Harsh 00 via llvm-dev
2018-Mar-11 17:41 UTC
[llvm-dev] Using Xray compilation with C programs
Hi all,
I was interested in trying out the Xray profiling component in LLVM and was
trying to compile a C program with Clang with Xray flags. Unfortunately, I
keep getting a linker error everytime I try to compile the C program with
Clang. However, the error goes away when I try to compile the same C
program with Clang++ with -xc++ flag.
Searching around for this issue, looks like somebody has already filed a
bug for this issue:
https://bugs.llvm.org/show_bug.cgi?id=34904
Is there any way to get around this bug or to solve this issue?
Issue description from the filed bug:
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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20180311/63a74415/attachment.html>
David Blaikie via llvm-dev
2018-Mar-12 15:18 UTC
[llvm-dev] Using Xray compilation with C programs
Dean - any ideas if this is/should be supported? (I think the last time we discussed this with Kostya the answer was sanitizer-like runtime libraries shouldn't use any C++ features? (for reasons like this, and others) so maybe this case is another to add to the list of motivations to continue/complete that work?) On Sun, Mar 11, 2018 at 12:05 PM Harsh 00 via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi all, > > I was interested in trying out the Xray profiling component in LLVM and > was trying to compile a C program with Clang with Xray flags. > Unfortunately, I keep getting a linker error everytime I try to compile the > C program with Clang. However, the error goes away when I try to compile > the same C program with Clang++ with -xc++ flag. > > Searching around for this issue, looks like somebody has already filed a > bug for this issue: > https://bugs.llvm.org/show_bug.cgi?id=34904 > > Is there any way to get around this bug or to solve this issue? > > Issue description from the filed bug: > > 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> > > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20180312/94655af5/attachment.html>
Seemingly Similar Threads
- XRay Trace of Clang, Loadable through Chrome Trace Viewer
- [cfe-dev] XRay Trace of Clang, Loadable through Chrome Trace Viewer
- [XRay] Build instrumented Clang, some analysis results
- [X-ray] How to check successful instrumentation and generate call trace?
- [llvm-xray] llvm-xray cannot log every functions