}
// Until ARM libraries are build separately, we have them all in one library
-static StringRef getArchNameForCompilerRTLib(const ToolChain &TC) {
- if (TC.getTriple().isWindowsMSVCEnvironment() &&
- TC.getArch() == llvm::Triple::x86)
+static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
+ const ArgList &Args) {
+ const llvm::Triple &Triple = TC.getTriple();
+ bool IsWindows = Triple.isOSWindows();
+
+ if (Triple.isWindowsMSVCEnvironment() && TC.getArch() == llvm::Triple::x86)
return "i386";
+
if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
- return "arm";
+ return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
+ ? "armhf"
+ : "arm";
+
return TC.getArchName();
}
return Res;
}
-SmallString<128> tools::getCompilerRT(const ToolChain &TC, StringRef Component,
- bool Shared) {
+SmallString<128> tools::getCompilerRT(const ToolChain &TC, const ArgList &Args,
+ StringRef Component, bool Shared) {
const char *Env = TC.getTriple().getEnvironment() == llvm::Triple::Android
? "-android"
: "";
bool IsOSWindows = TC.getTriple().isOSWindows();
bool IsITANMSVCWindows = TC.getTriple().isWindowsMSVCEnvironment() ||
TC.getTriple().isWindowsItaniumEnvironment();
- StringRef Arch = getArchNameForCompilerRTLib(TC);
+ StringRef Arch = getArchNameForCompilerRTLib(TC, Args);
const char *Prefix = IsITANMSVCWindows ? "" : "lib";
const char *Suffix =
Shared ? (IsOSWindows ? ".dll" : ".so") : (IsITANMSVCWindows ? ".lib" : ".a");
return Path;
}
+static const char *getCompilerRTArgString(const ToolChain &TC,
+ const llvm::opt::ArgList &Args,
+ StringRef Component,
+ bool Shared = false) {
+ return Args.MakeArgString(getCompilerRT(TC, Args, Component, Shared));
+}
+
// This adds the static libclang_rt.builtins-arch.a directly to the command line
// FIXME: Make sure we can also emit shared objects if they're requested
// and available, check for possible errors, etc.
static void addClangRT(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs) {
- CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, "builtins")));
+ CmdArgs.push_back(getCompilerRTArgString(TC, Args, "builtins"));
}
static void addProfileRT(const ToolChain &TC, const ArgList &Args,
Args.hasArg(options::OPT_coverage)))
return;
- CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, "profile")));
+ CmdArgs.push_back(getCompilerRTArgString(TC, Args, "profile"));
}
namespace {
// whole-archive.
if (!IsShared)
CmdArgs.push_back("-whole-archive");
- CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, Sanitizer, IsShared)));
+ CmdArgs.push_back(getCompilerRTArgString(TC, Args, Sanitizer, IsShared));
if (!IsShared)
CmdArgs.push_back("-no-whole-archive");
}
static bool addSanitizerDynamicList(const ToolChain &TC, const ArgList &Args,
ArgStringList &CmdArgs,
StringRef Sanitizer) {
- SmallString<128> SanRT = getCompilerRT(TC, Sanitizer);
+ SmallString<128> SanRT = getCompilerRT(TC, Args, Sanitizer);
if (llvm::sys::fs::exists(SanRT + ".syms")) {
CmdArgs.push_back(Args.MakeArgString("--dynamic-list=" + SanRT + ".syms"));
return true;
"asan_dynamic", "asan_dynamic_runtime_thunk",
};
for (const auto &Component : CompilerRTComponents)
- CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, Component)));
+ CmdArgs.push_back(getCompilerRTArgString(TC, Args, 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) {
- CmdArgs.push_back(
- Args.MakeArgString(getCompilerRT(TC, "asan_dll_thunk")));
+ CmdArgs.push_back(getCompilerRTArgString(TC, Args, "asan_dll_thunk"));
} else {
static const char *CompilerRTComponents[] = {
"asan", "asan_cxx",
};
for (const auto &Component : CompilerRTComponents)
- CmdArgs.push_back(Args.MakeArgString(getCompilerRT(TC, Component)));
+ CmdArgs.push_back(getCompilerRTArgString(TC, Args, Component));
}
}
--- /dev/null
+// RUN: %clang -target arm-linux-gnueabi -rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix ARM-GNUEABI
+// ARM-GNUEABI: "{{.*}}/libclang_rt.builtins-arm.a"
+
+// RUN: %clang -target arm-linux-gnueabi -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 | FileCheck %s -check-prefix ARM-GNUEABI-ABI
+// ARM-GNUEABI-ABI: "{{.*}}/libclang_rt.builtins-armhf.a"
+
+// RUN: %clang -target arm-linux-gnueabihf -rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix ARM-GNUEABIHF
+// ARM-GNUEABIHF: "{{.*}}/libclang_rt.builtins-armhf.a"
+
+// RUN: %clang -target arm-linux-gnueabihf -rtlib=compiler-rt -mfloat-abi=soft -### %s 2>&1 | FileCheck %s -check-prefix ARM-GNUEABIHF-ABI
+// ARM-GNUEABIHF-ABI: "{{.*}}/libclang_rt.builtins-arm.a"
+
+// RUN: %clang -target arm-windows-itanium -rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix ARM-WINDOWS
+// ARM-WINDOWS: "{{.*}}/clang_rt.builtins-arm.lib"
+
+// RUN: %clang -target arm-linux-androideabi -rtlib=compiler-rt -### %s 2>&1 | FileCheck %s -check-prefix ARM-ANDROID
+// ARM-ANDROID: "{{.*}}/libclang_rt.builtins-arm-android.a"
+
+// RUN: %clang -target arm-linux-androideabi -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 | FileCheck %s -check-prefix ARM-ANDROIDHF
+// ARM-ANDROIDHF: "{{.*}}/libclang_rt.builtins-armhf-android.a"
+