forked from OSchip/llvm-project
[Driver] Support object files in addition to static and shared libraries in compiler-rt
This change introduces support for object files in addition to static and shared libraries which were already supported which requires changing the type of the argument from boolean to an enum. Differential Revision: https://reviews.llvm.org/D56044 llvm-svn: 355891
This commit is contained in:
parent
e8475f78e2
commit
930d46a2ef
|
@ -104,6 +104,8 @@ public:
|
||||||
RM_Disabled,
|
RM_Disabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum FileType { FT_Object, FT_Static, FT_Shared };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend class RegisterEffectiveTriple;
|
friend class RegisterEffectiveTriple;
|
||||||
|
|
||||||
|
@ -371,11 +373,11 @@ public:
|
||||||
|
|
||||||
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
|
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args,
|
||||||
StringRef Component,
|
StringRef Component,
|
||||||
bool Shared = false) const;
|
FileType Type = ToolChain::FT_Static) const;
|
||||||
|
|
||||||
const char *getCompilerRTArgString(const llvm::opt::ArgList &Args,
|
const char *
|
||||||
StringRef Component,
|
getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component,
|
||||||
bool Shared = false) const;
|
FileType Type = ToolChain::FT_Static) const;
|
||||||
|
|
||||||
// Returns <ResourceDir>/lib/<OSName>/<arch>. This is used by runtimes (such
|
// Returns <ResourceDir>/lib/<OSName>/<arch>. This is used by runtimes (such
|
||||||
// as OpenMP) to find arch-specific libraries.
|
// as OpenMP) to find arch-specific libraries.
|
||||||
|
|
|
@ -362,16 +362,27 @@ std::string ToolChain::getCompilerRTPath() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
|
std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
|
||||||
bool Shared) const {
|
FileType Type) const {
|
||||||
const llvm::Triple &TT = getTriple();
|
const llvm::Triple &TT = getTriple();
|
||||||
bool IsITANMSVCWindows =
|
bool IsITANMSVCWindows =
|
||||||
TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
|
TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
|
||||||
|
|
||||||
const char *Prefix = IsITANMSVCWindows ? "" : "lib";
|
const char *Prefix =
|
||||||
const char *Suffix = Shared ? (Triple.isOSWindows() ? ".lib" : ".so")
|
IsITANMSVCWindows || Type == ToolChain::FT_Object ? "" : "lib";
|
||||||
: (IsITANMSVCWindows ? ".lib" : ".a");
|
const char *Suffix;
|
||||||
if (Shared && Triple.isWindowsGNUEnvironment())
|
switch (Type) {
|
||||||
Suffix = ".dll.a";
|
case ToolChain::FT_Object:
|
||||||
|
Suffix = IsITANMSVCWindows ? ".obj" : ".o";
|
||||||
|
break;
|
||||||
|
case ToolChain::FT_Static:
|
||||||
|
Suffix = IsITANMSVCWindows ? ".lib" : ".a";
|
||||||
|
break;
|
||||||
|
case ToolChain::FT_Shared:
|
||||||
|
Suffix = Triple.isOSWindows()
|
||||||
|
? (Triple.isWindowsGNUEnvironment() ? ".dll.a" : ".lib")
|
||||||
|
: ".so";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &LibPath : getLibraryPaths()) {
|
for (const auto &LibPath : getLibraryPaths()) {
|
||||||
SmallString<128> P(LibPath);
|
SmallString<128> P(LibPath);
|
||||||
|
@ -390,8 +401,8 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
|
||||||
|
|
||||||
const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
|
const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
|
||||||
StringRef Component,
|
StringRef Component,
|
||||||
bool Shared) const {
|
FileType Type) const {
|
||||||
return Args.MakeArgString(getCompilerRT(Args, Component, Shared));
|
return Args.MakeArgString(getCompilerRT(Args, Component, Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ToolChain::getArchSpecificLibPath() const {
|
std::string ToolChain::getArchSpecificLibPath() const {
|
||||||
|
|
|
@ -535,7 +535,8 @@ static void addSanitizerRuntime(const ToolChain &TC, const ArgList &Args,
|
||||||
// Wrap any static runtimes that must be forced into executable in
|
// Wrap any static runtimes that must be forced into executable in
|
||||||
// whole-archive.
|
// whole-archive.
|
||||||
if (IsWhole) CmdArgs.push_back("--whole-archive");
|
if (IsWhole) CmdArgs.push_back("--whole-archive");
|
||||||
CmdArgs.push_back(TC.getCompilerRTArgString(Args, Sanitizer, IsShared));
|
CmdArgs.push_back(TC.getCompilerRTArgString(
|
||||||
|
Args, Sanitizer, IsShared ? ToolChain::FT_Shared : ToolChain::FT_Static));
|
||||||
if (IsWhole) CmdArgs.push_back("--no-whole-archive");
|
if (IsWhole) CmdArgs.push_back("--no-whole-archive");
|
||||||
|
|
||||||
if (IsShared) {
|
if (IsShared) {
|
||||||
|
|
|
@ -248,8 +248,8 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||||
|
|
||||||
if (Sanitize.needsAsanRt()) {
|
if (Sanitize.needsAsanRt()) {
|
||||||
// MinGW always links against a shared MSVCRT.
|
// MinGW always links against a shared MSVCRT.
|
||||||
CmdArgs.push_back(
|
CmdArgs.push_back(TC.getCompilerRTArgString(Args, "asan_dynamic",
|
||||||
TC.getCompilerRTArgString(Args, "asan_dynamic", true));
|
ToolChain::FT_Shared));
|
||||||
CmdArgs.push_back(
|
CmdArgs.push_back(
|
||||||
TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
|
TC.getCompilerRTArgString(Args, "asan_dynamic_runtime_thunk"));
|
||||||
CmdArgs.push_back(Args.MakeArgString("--require-defined"));
|
CmdArgs.push_back(Args.MakeArgString("--require-defined"));
|
||||||
|
|
|
@ -118,11 +118,23 @@ void MipsLLVMToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||||
|
|
||||||
std::string MipsLLVMToolChain::getCompilerRT(const ArgList &Args,
|
std::string MipsLLVMToolChain::getCompilerRT(const ArgList &Args,
|
||||||
StringRef Component,
|
StringRef Component,
|
||||||
bool Shared) const {
|
FileType Type) const {
|
||||||
SmallString<128> Path(getDriver().ResourceDir);
|
SmallString<128> Path(getDriver().ResourceDir);
|
||||||
llvm::sys::path::append(Path, SelectedMultilib.osSuffix(), "lib" + LibSuffix,
|
llvm::sys::path::append(Path, SelectedMultilib.osSuffix(), "lib" + LibSuffix,
|
||||||
getOS());
|
getOS());
|
||||||
llvm::sys::path::append(Path, Twine("libclang_rt." + Component + "-" +
|
const char *Suffix;
|
||||||
"mips" + (Shared ? ".so" : ".a")));
|
switch (Type) {
|
||||||
|
case ToolChain::FT_Object:
|
||||||
|
Suffix = ".o";
|
||||||
|
break;
|
||||||
|
case ToolChain::FT_Static:
|
||||||
|
Suffix = ".a";
|
||||||
|
break;
|
||||||
|
case ToolChain::FT_Shared:
|
||||||
|
Suffix = ".so";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
llvm::sys::path::append(
|
||||||
|
Path, Twine("libclang_rt." + Component + "-" + "mips" + Suffix));
|
||||||
return Path.str();
|
return Path.str();
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,8 +37,9 @@ public:
|
||||||
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
|
void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args,
|
||||||
llvm::opt::ArgStringList &CmdArgs) const override;
|
llvm::opt::ArgStringList &CmdArgs) const override;
|
||||||
|
|
||||||
std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
|
std::string
|
||||||
bool Shared = false) const override;
|
getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component,
|
||||||
|
FileType Type = ToolChain::FT_Static) const override;
|
||||||
|
|
||||||
std::string computeSysRoot() const override;
|
std::string computeSysRoot() const override;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue