[PATCH] D28359: [compiler-rt] Use common static library for sanitizer_common.

Marcos Pividori via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 5 16:30:20 PST 2017


mpividori added a comment.

In https://reviews.llvm.org/D28359#637524, @kcc wrote:

> Same comment as in the other part: 
>  I am not a fan of any such changes as they complicate things further.
>  Also, will the GCC build system and GCC driver have to change as well?
>
> Does it actually fix any problem that exists today?


@kcc

+ My main goal is to port libFuzzer to Windows.

+ To port libFuzzer to Windows, I need Santinizer Coverage to work on Windows.

+ To make Sanitizer Coverage work on Windows, I need to update the code, since currently it doesn't work because it relies on weak symbols.
This works fine for Linux, since weak symbols work in both cases, when using a static asan rt or when considering a shared asan rt.
In Windows, we have something similar to weak symbols, using "pragma"(/alternatename...". This works for static libraries but this doesn't work for dlls.
For MD, asan is implemented in a separate dll, and the linker will fails because we can not set "__sanitizer_cov_trace_*" functions as optional in "clang-rt_asan_dynamic-arch.dll".

So, to make it work on Windows, my proposal was just to decouple sanitizer coverage from asan and create an independent static library for sanitizer coverage. This static library will only include the functions:  "__sanitizer_cov_trace_*" as weak symbols.
Sanitizer coverage will always be a static library, no matter if asan is static or shared.

+ To create an independent static library for sanitizer coverage, I need to move sanitizer_common into a separate static library, which is the purpose of this diff.
I need sanitizer_common's code for the sanitizer coverage static library. Also that code is included in asan static library (asan is static when using MT on Windows, and by default on linux), resulting in link error because of multiple definitions.
So, I decided to separate sanitizer common into a different static library, and ensure it is only included once.

So, this is how I ended up with these changes.

I can isolate these changes, and include them only for Windows, but I thought it would be better to take the same approach for all the platforms: "decouple sanitizer coverage from the rest of sanitizers and always include it as a static library".


Repository:
  rL LLVM

https://reviews.llvm.org/D28359





More information about the llvm-commits mailing list