[PATCH] D27869: [libFuzzer] Diff 24 - Use clang as linker in Windows, to properly include sanitizer libraries.

Reid Kleckner via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 27 16:45:17 PST 2016


rnk added a comment.

In https://reviews.llvm.org/D27869#631527, @kcc wrote:

> I was asking about "build the static archive libFuzzer.lib" but actually I'd like to see both.


LLVMFuzzer.lib is basically this command:

  link.exe /lib /nologo /machine:x64 /out:lib\LLVMFuzzer.lib lib\Fuzzer\CMakeFiles\LLVMFuzzerNoMainObjects.dir\*.obj lib\Fuzzer\CMakeFiles\LLVMFuzzer.dir\FuzzerMain.cpp.obj

LLVMFuzzer-NullDerefTest links like this:

  link.exe /nologo lib\Fuzzer\test\CMakeFiles\LLVMFuzzer-NullDerefTest.dir\NullDerefTest.cpp.obj  /out:lib\Fuzzer\test\LLVMFuzzer-NullDerefTest.exe /implib:lib\LLVMFuzzer-NullDerefTest.lib /pdb:lib\Fuzzer\test\LLVMFuzzer-NullDerefTest.pdb /version:0.0  /machine:x64 /MANIFEST:NO /STACK:10000000 -debug /INCREMENTAL:NO /subsystem:console  lib\LLVMFuzzer.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib

Many of those arguments are unnecessary, and would maybe not be present without cmake, but the important point is that executables are not linked by calling the clang driver on Windows. This is true in every Windows build system I've ever encountered that wasn't ported from Unix.

The link step above fails because the ASan RTL is not listed on the link line. We can solve this problem in either of these ways:

1. Break convention as Marcos is doing here and call clang-cl to do the link manually.
2. Duplicate the clang driver logic to pass the appropriate asan runtimes into LLVM cmake. Chromium already duplicates this logic itself.


Repository:
  rL LLVM

https://reviews.llvm.org/D27869





More information about the llvm-commits mailing list