mirror of
https://github.com/intel/llvm.git
synced 2026-01-15 12:25:46 +08:00
Driver: implement driver automagic support for -lcc_kext
Rewrite linker arguments to use libclang_rt.cc_kext.a instead of gcc-specific libcc_kext.a Resolves Radar 7808495 llvm-svn: 114193
This commit is contained in:
@@ -749,3 +749,5 @@ def Z_Xlinker__no_demangle : Flag<"-Z-Xlinker-no-demangle">, Flags<[Unsupported,
|
||||
// Reserved library options.
|
||||
def Z_reserved_lib_stdcxx : Flag<"-Z-reserved-lib-stdc++">,
|
||||
Flags<[LinkerInput, NoArgumentUnused, Unsupported]>, Group<reserved_lib_Group>;
|
||||
def Z_reserved_lib_cckext : Flag<"-Z-reserved-lib-cckext">,
|
||||
Flags<[LinkerInput, NoArgumentUnused, Unsupported]>, Group<reserved_lib_Group>;
|
||||
|
||||
@@ -177,6 +177,11 @@ public:
|
||||
/// for the given C++ standard library type.
|
||||
virtual void AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const;
|
||||
|
||||
/// AddCCKextLibArgs - Add the system specific linker arguments to use
|
||||
/// for kernel extensions (Darwin-specific).
|
||||
virtual void AddCCKextLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const;
|
||||
};
|
||||
|
||||
} // end namespace driver
|
||||
|
||||
@@ -158,15 +158,23 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Rewrite reserved library names, unless -nostdlib is present.
|
||||
if (!HasNostdlib && A->getOption().matches(options::OPT_l)) {
|
||||
// Rewrite reserved library names.
|
||||
if (A->getOption().matches(options::OPT_l)) {
|
||||
llvm::StringRef Value = A->getValue(Args);
|
||||
|
||||
if (Value == "stdc++") {
|
||||
// Rewrite unless -nostdlib is present.
|
||||
if (!HasNostdlib && Value == "stdc++") {
|
||||
DAL->AddFlagArg(A, Opts->getOption(
|
||||
options::OPT_Z_reserved_lib_stdcxx));
|
||||
continue;
|
||||
}
|
||||
|
||||
// Rewrite unconditionally.
|
||||
if (Value == "cc_kext") {
|
||||
DAL->AddFlagArg(A, Opts->getOption(
|
||||
options::OPT_Z_reserved_lib_cckext));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
DAL->append(*it);
|
||||
|
||||
@@ -222,3 +222,8 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ToolChain::AddCCKextLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const {
|
||||
CmdArgs.push_back("-lcc_kext");
|
||||
}
|
||||
|
||||
@@ -644,6 +644,27 @@ void DarwinClang::AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
}
|
||||
}
|
||||
|
||||
void DarwinClang::AddCCKextLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const {
|
||||
|
||||
// For Darwin platforms, use the compiler-rt-based support library
|
||||
// instead of the gcc-provided one (which is also incidentally
|
||||
// only present in the gcc lib dir, which makes it hard to find).
|
||||
|
||||
llvm::sys::Path P(getDriver().ResourceDir);
|
||||
P.appendComponent("lib");
|
||||
P.appendComponent("darwin");
|
||||
P.appendComponent("libclang_rt.cc_kext.a");
|
||||
|
||||
// For now, allow missing resource libraries to support developers who may
|
||||
// not have compiler-rt checked out or integrated into their build.
|
||||
if (!P.exists())
|
||||
getDriver().Diag(clang::diag::warn_drv_missing_resource_library)
|
||||
<< P.str();
|
||||
else
|
||||
CmdArgs.push_back(Args.MakeArgString(P.str()));
|
||||
}
|
||||
|
||||
DerivedArgList *Darwin::TranslateArgs(const DerivedArgList &Args,
|
||||
const char *BoundArch) const {
|
||||
DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
|
||||
|
||||
@@ -226,6 +226,9 @@ public:
|
||||
virtual void AddCXXStdlibLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const;
|
||||
|
||||
virtual void AddCCKextLibArgs(const ArgList &Args,
|
||||
ArgStringList &CmdArgs) const;
|
||||
|
||||
/// }
|
||||
};
|
||||
|
||||
|
||||
@@ -116,6 +116,8 @@ static void AddLinkerInputs(const ToolChain &TC,
|
||||
// Handle reserved library options.
|
||||
if (A.getOption().matches(options::OPT_Z_reserved_lib_stdcxx)) {
|
||||
TC.AddCXXStdlibLibArgs(Args, CmdArgs);
|
||||
} else if (A.getOption().matches(options::OPT_Z_reserved_lib_cckext)) {
|
||||
TC.AddCCKextLibArgs(Args, CmdArgs);
|
||||
} else
|
||||
A.renderAsInput(Args, CmdArgs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user