[cfe-dev] How to configure an autools project with Clang sanitizers library?

Peter Collingbourne peter at pcc.me.uk
Mon May 26 18:32:47 PDT 2014


On Thu, May 22, 2014 at 05:45:55PM -0500, Frederico Araujo wrote:
> Hi,
> 
> I've tried to compile Apache Httpd (and several other open source projects)
> with clang using the dataflow sanitizer. I set the CC environment variable
> to point to my clang installation and I specified the "-fsanitize=dataflow"
> in the CFLAGS and/or LDFLAGS environment variables.

FWIW, I normally set CC to "clang -fsanitize=foo" when I want to use a
sanitizer.

> However, the configure script fails when running its C compiler tests (in
> Apache's case, the first problem occurs for the APR library). The following
> is an excerpt of the config.log output:
> 
> (...)
> configure:5409: checking whether the C compiler works
> configure:5431: /usr/local/llvm/build/Debug+Asserts/bin/clang
> -fsanitize=dataflow conftest.c  >&5

This path name would appear to indicate that you are building LLVM/Clang
with the makefiles. As I mentioned before, this doesn't work well at the
moment with dfsan (sorry). Can you please try building LLVM/Clang with CMake?

> /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/Scrt1.o(.debug_info):
> relocation 0 has invalid symbol index 11
> /usr/bin/ld: /usr/lib/debug/usr/lib/x86_64-linux-gnu/Scrt1.o(.debug_info):
> relocation 1 has invalid symbol index 12
> (...)
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../x86_64-linux-gnu/Scrt1.o: In
> function `_start':
> (.text+0x20): undefined reference to `main'
> /usr/local/llvm/build/Debug+Asserts/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a(dfsan_interceptors.o):
> In function `InitializeInterceptors':
> /usr/local/llvm/projects/compiler-rt/lib/dfsan/dfsan_interceptors.cc:40:
> undefined reference to `__interception::GetRealFunctionAddress(char const*,
> unsigned long*, unsigned long, unsigned long)'
> /usr/local/llvm/projects/compiler-rt/lib/dfsan/dfsan_interceptors.cc:41:
> undefined reference to `__interception::GetRealFunctionAddress(char const*,

I do not understand why this might be happening. The interception_linux.o
file is supposed to provide the definition of this symbol. Can you please
show us the output of:

  $ nm /usr/local/llvm/build/Debug+Asserts/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.dfsan-x86_64.a

?

> unsigned long*, unsigned long, unsigned long)'
> (...)(.data.rel.ro._ZTIN11__sanitizer17ThreadContextBaseE[_ZTIN11__sanitizer17ThreadContextBaseE]+0x0):
> undefined reference to `vtable for __cxxabiv1::__class_type_info'

This is the same problem that you had before, which I believe is fixed now.
Are you sure that you have updated compiler-rt?

Thanks,
-- 
Peter



More information about the cfe-dev mailing list