Skip to content

Build and include LLVM sanitizer libraries built by vcpkg #715

@ekilmer

Description

@ekilmer

If we want to use the clang compiler built with vcpkg as a self-contained toolchain, we should also have the option to build the target project with the equivalent sanitizer support.

I think this might be enabled by building the compiler-rt project https://compiler-rt.llvm.org/

Initially, this should be limited to the Address and Undefined sanitizers at first, both to reduce release artifact blowup and because other sanitizers like Memory sanitizer require instrumented standard c++ library.

The following command should work in order to close this issue:

CXXFLAGS="-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections -Wl,-undefined,dynamic_lookup" \
CFLAGS="-fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls -ffunction-sections -fdata-sections -Wl,-undefined,dynamic_lookup" \
LDFLAGS="-fsanitize=address -Wl,-undefined,dynamic_lookup" \
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
  -DCMAKE_INSTALL_PREFIX=$(pwd)/install -DVCPKG_ROOT="/Users/ekilmer/src/cxx-common/vcpkg" ..

Currently, it errors with something like:

/usr/bin/ld: cannot find .... 
<vcpkg_root>/installed/x64-linux-rel/lib/clang/11.0.0/lib/linux/libclang_rt.asan-x86_64.a: No such file or directory

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions