I’ve recently landed patches to address this. Please try again with the latest in HEAD?
Yeah, this one was kind-of a known issue. We have marked a lot of functions in log interface headers
In general, yes — and we’re working on making this easier to do incrementally. Right now we’re working on profiling mode [0] which is taking up all/most of my time. We need additional reviewers/testers and it would be great if you can help with some of that (if you’re interested).
That being said, the intent is definitely to support using the XRay APIs in C. We haven’t prioritised making this work yet, but I’m definitely open to reviewing patches to making this a first-class supported use-case for XRay.
Note that we’ve marked a lot of APIs in the logging API in preparation for this as deprecated, with the intent of reducing the API surface even further (or providing more convenient APIs). Your feedback would be really helpful in shaping that API not just for C but potentially for other languages that have support for C bindings.
The documentation mentions XRay works with C/C++/Objective-C/Objective-C++ under “Using XRay” (https://llvm.org/docs/XRay.html) and the white paper mentions that “XRay is not specific to a class of applications and is applicable to any C/C++-based binary -- from storage servers handling multiple thousands of requests per second to debugging command-line tools and unit tests”.
I give more detail about the problem below.
I am running Ubuntu 16.04.1 on a x86_64 machine and am using clang 7.0.
henry@OptiPlex-9010:~$ uname -a
Linux OptiPlex-9010 4.13.0-43-generic #48~16.04.1-Ubuntu SMP Thu May 17 12:56:46 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Below is a C test file I wrote: (test_pthread.c)
==============================
#include <stdio.h>
#include <pthread.h>
__attribute__((xray_always_instrument))
void print_parent()
{
printf("I am parent\n");
}
__attribute__((xray_always_instrument))
void* print_child(void* unused)
{
printf("I am child\n");
return NULL;
}
int main()
{
print_parent();
int num_threads = 10;
pthread_t tids[num_threads];
for(int i = 0; i < num_threads; i++)
{
pthread_create(&tids[i], NULL, print_child, NULL);
}
for(int i = 0; i < num_threads; i++)
{
pthread_join(tids[i], NULL);
}
return 0;
}
./clang -fxray-instrument test_pthread.c
Clang produces errors about c++: (xray_clang_error.txt)
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::thresholdTicks()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:79: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:79: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:81: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:81: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::basicLoggingInit(unsigned long, unsigned long, void*, unsigned long)':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:423: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:423: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:385: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:385: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::getGlobalFd()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `openLogFile':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `operator()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:151: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:151: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `thresholdTicks':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:81: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:81: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:79: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:79: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::getGlobalFd()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `openLogFile':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::getGlobalFd()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `openLogFile':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::getGlobalFd()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `openLogFile':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::getGlobalFd()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:113: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `openLogFile':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:93: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:91: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `operator()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:151: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:151: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `thresholdTicks':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:81: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:81: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:79: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:79: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `__xray::basicLogDynamicInitializer()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:497: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:497: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-basic-x86_64.a(xray_basic_logging.cc.o): In function `operator()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:494: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_basic_logging.cc:494: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `__xray::thresholdTicks()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:325: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:325: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:323: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:323: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `__xray::(anonymous namespace)::fdrCommonHeaderInfo()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:688: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:688: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `operator()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:680: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:680: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:678: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:678: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `__xray::fdrIterator(XRayBuffer)':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:726: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:726: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `getTimestamp':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `__xray::fdrLoggingHandleCustomEvent(void*, unsigned long)':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:928: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:928: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `getTimestamp':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `__xray::fdrLoggingHandleTypedEvent(unsigned short, void const*, unsigned long)':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:978: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:978: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `getTimestamp':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `processFunctionHook':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:633: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:633: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:643: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:643: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `writeFunctionRecord':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:309: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:309: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `thresholdTicks':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:325: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:325: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:323: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:323: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `writeFunctionRecord':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:299: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:299: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `getTimestamp':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:884: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `processFunctionHook':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:633: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:633: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:643: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:643: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `writeFunctionRecord':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:309: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:309: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `thresholdTicks':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:325: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:325: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:323: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:323: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `writeFunctionRecord':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:299: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:299: undefined reference to `__cxa_guard_release'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `__xray::fdrLoggingFlush()':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:790: undefined reference to `operator delete(void*)'
/home/henry/build_xray/llvm-instrumented-build/lib/clang/7.0.0/lib/linux/libclang_rt.xray-fdr-x86_64.a(xray_fdr_logging.cc.o): In function `__xray::fdrLoggingInit(unsigned long, unsigned long, void*, unsigned long)':
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:1096: undefined reference to `operator delete(void*)'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:1101: undefined reference to `operator new(unsigned long)'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:1106: undefined reference to `operator delete(void*)'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:1123: undefined reference to `__cxa_guard_acquire'
/home/henry/build_xray/llvm-project/compiler-rt/lib/xray/xray_fdr_logging.cc:1123: undefined reference to `__cxa_guard_release'
clang-7: error: linker command failed with exit code 1 (use -v to see invocation)
Instead, I compiled using clang++ with the –xc flag mentioned in this post: http://lists.llvm.org/pipermail/llvm-dev/2018-March/121716.html
./clang++ -fxray-instrument -xc test_pthread.c
It compiles without any errors and the executable works fine.
Yes, this particular problem has been fixed very recently (Friday last week). Please try with the most recent version in HEAD.
These are going to change soon, as we remove the (deprecated) way of configuring FDR mode to only support the string-based configuration.
For FDR mode, we can certainly make some changes in the header to make the C++-specific parts conditional on whether it’s being compiled in C++ or C. Optionally we can also accelerate the removal of the struct-based config in favour of the flag-based config support only.
Patches would be welcome for either direction.