From: Saleem Abdulrasool Date: Fri, 2 Jan 2015 20:00:55 +0000 (+0000) Subject: Driver: reuse getCompilerRT in place of addSanitizerRTWindows X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3d124dd14bb2fe8de1ffb5c98dcff9ce7eb74508;p=clang Driver: reuse getCompilerRT in place of addSanitizerRTWindows The logic for addSanitizerRTWindows was performing the same logical operation as getCompilerRT, which was previously fully generalised for Linux and Windows. This avoids having a duplication of the logic for building up the name of a clang_rt component. This change does move the current limitation for Windows into getArchNameForCompilerRTLib, where it is assumed that the architecture for Windows is always i386. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@225087 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 6c19cc7ce4..ecca1a461d 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -2105,6 +2105,9 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, static StringRef getArchNameForCompilerRTLib(const ToolChain &TC) { if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb) return "arm"; + // FIXME: handle 64-bit + if (TC.getTriple().isOSWindows()) + return "i386"; return TC.getArchName(); } @@ -7807,15 +7810,6 @@ void dragonfly::Link::ConstructJob(Compilation &C, const JobAction &JA, C.addCommand(llvm::make_unique(JA, *this, Exec, CmdArgs)); } -static void addSanitizerRTWindows(const ToolChain &TC, const ArgList &Args, - ArgStringList &CmdArgs, - StringRef RTName) { - SmallString<128> LibSanitizer(getCompilerRTLibDir(TC)); - llvm::sys::path::append(LibSanitizer, - Twine("clang_rt.") + RTName + ".lib"); - CmdArgs.push_back(Args.MakeArgString(LibSanitizer)); -} - // Try to find Exe from a Visual Studio distribution. This first tries to find // an installed copy of Visual Studio and, failing that, looks in the PATH, // making sure that whatever executable that's found is not a same-named exe @@ -7904,19 +7898,25 @@ void visualstudio::Link::ConstructJob(Compilation &C, const JobAction &JA, if (TC.getSanitizerArgs().needsAsanRt()) { CmdArgs.push_back(Args.MakeArgString("-debug")); CmdArgs.push_back(Args.MakeArgString("-incremental:no")); - // FIXME: Handle 64-bit. if (Args.hasArg(options::OPT__SLASH_MD, options::OPT__SLASH_MDd)) { - addSanitizerRTWindows(TC, Args, CmdArgs, "asan_dynamic-i386"); - addSanitizerRTWindows(TC, Args, CmdArgs, - "asan_dynamic_runtime_thunk-i386"); + static const char *CompilerRTComponents[] = { + "asan_dynamic", + "asan_dynamic_runtime_thunk", + }; + for (const auto &Component : CompilerRTComponents) + CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, Component))); // Make sure the dynamic runtime thunk is not optimized out at link time // to ensure proper SEH handling. CmdArgs.push_back(Args.MakeArgString("-include:___asan_seh_interceptor")); } else if (DLL) { - addSanitizerRTWindows(TC, Args, CmdArgs, "asan_dll_thunk-i386"); + CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, "asan_dll_thunk"))); } else { - addSanitizerRTWindows(TC, Args, CmdArgs, "asan-i386"); - addSanitizerRTWindows(TC, Args, CmdArgs, "asan_cxx-i386"); + static const char *CompilerRTComponents[] = { + "asan", + "asan_cxx", + }; + for (const auto &Component : CompilerRTComponents) + CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, Component))); } }