From be365f65836dd3e136cd4157d6ce49cabd0a3447 Mon Sep 17 00:00:00 2001 From: Marcos Pividori Date: Thu, 9 Feb 2017 18:22:35 +0000 Subject: [PATCH] [windows] [asan] Add wholearchive flag when including asan_cxx lib. We need -wholearchive for asan_cxx, the same than for asan. Clang Driver will add asan_cxx at the beginning of the arg list that we pass to the linker. To ensure that all the static libraries are linked to asan_cxx, we force the linker to include the object files in asan_cxx. This fixes some linker errors when compiling with address sanitizer for MT and passing the static library libFuzzer. Differential Revision: https://reviews.llvm.org/D29754 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@294604 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/Tools.cpp | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 1eddefd4f0..7b48e1da92 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -11006,13 +11006,14 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, } else if (DLL) { CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dll_thunk")); } else { - for (const auto &Lib : {"asan", "asan_cxx"}) + for (const auto &Lib : {"asan", "asan_cxx"}) { CmdArgs.push_back(TC.getCompilerRTArgString(Args, Lib)); - // Make sure the linker consider all object files from the static library. - // This is necessary because instrumented dlls need access to all the - // interface exported by the static lib in the main executable. - CmdArgs.push_back(Args.MakeArgString(std::string("-wholearchive:") + - TC.getCompilerRT(Args, "asan"))); + // Make sure the linker consider all object files from the static lib. + // This is necessary because instrumented dlls need access to all the + // interface exported by the static lib in the main executable. + CmdArgs.push_back(Args.MakeArgString(std::string("-wholearchive:") + + TC.getCompilerRT(Args, Lib))); + } } } -- 2.40.0