r225087 - Driver: reuse getCompilerRT in place of addSanitizerRTWindows
Saleem Abdulrasool
compnerd at compnerd.org
Fri Jan 2 12:00:57 PST 2015
Author: compnerd
Date: Fri Jan 2 14:00:55 2015
New Revision: 225087
URL: http://llvm.org/viewvc/llvm-project?rev=225087&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Driver/Tools.cpp
Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=225087&r1=225086&r2=225087&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Jan 2 14:00:55 2015
@@ -2105,6 +2105,9 @@ static void CollectArgsForIntegratedAsse
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(Compi
C.addCommand(llvm::make_unique<Command>(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(Co
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)));
}
}
More information about the cfe-commits
mailing list