forked from OSchip/llvm-project
[WebAssembly] Initial linking support.
This begins minimal support for invoking 'ld' from clang for WebAssembly targets. Differential Revision: http://reviews.llvm.org/D15586 llvm-svn: 255848
This commit is contained in:
parent
4172953813
commit
5281686cdd
|
@ -4418,6 +4418,13 @@ Tool *MyriadToolChain::buildLinker() const {
|
|||
return new tools::Myriad::Linker(*this);
|
||||
}
|
||||
|
||||
WebAssembly::WebAssembly(const Driver &D, const llvm::Triple &Triple,
|
||||
const llvm::opt::ArgList &Args)
|
||||
: ToolChain(D, Triple, Args) {
|
||||
// Use LLD by default.
|
||||
DefaultLinker = "lld";
|
||||
}
|
||||
|
||||
bool WebAssembly::IsMathErrnoDefault() const { return false; }
|
||||
|
||||
bool WebAssembly::IsObjCNonFragileABIDefault() const { return true; }
|
||||
|
@ -4440,6 +4447,8 @@ bool WebAssembly::hasBlocksRuntime() const { return false; }
|
|||
// TODO: Support profiling.
|
||||
bool WebAssembly::SupportsProfiling() const { return false; }
|
||||
|
||||
bool WebAssembly::HasNativeLLVMSupport() const { return true; }
|
||||
|
||||
void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
|
||||
ArgStringList &CC1Args) const {
|
||||
if (DriverArgs.hasFlag(options::OPT_fuse_init_array,
|
||||
|
@ -4447,6 +4456,10 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
|
|||
CC1Args.push_back("-fuse-init-array");
|
||||
}
|
||||
|
||||
Tool *WebAssembly::buildLinker() const {
|
||||
return new tools::wasm::Linker(*this);
|
||||
}
|
||||
|
||||
PS4CPU::PS4CPU(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
|
||||
: Generic_ELF(D, Triple, Args) {
|
||||
if (Args.hasArg(options::OPT_static))
|
||||
|
|
|
@ -1088,8 +1088,7 @@ private:
|
|||
class LLVM_LIBRARY_VISIBILITY WebAssembly final : public ToolChain {
|
||||
public:
|
||||
WebAssembly(const Driver &D, const llvm::Triple &Triple,
|
||||
const llvm::opt::ArgList &Args)
|
||||
: ToolChain(D, Triple, Args) {}
|
||||
const llvm::opt::ArgList &Args);
|
||||
|
||||
private:
|
||||
bool IsMathErrnoDefault() const override;
|
||||
|
@ -1102,8 +1101,11 @@ private:
|
|||
bool hasBlocksRuntime() const override;
|
||||
bool SupportsObjCGC() const override;
|
||||
bool SupportsProfiling() const override;
|
||||
bool HasNativeLLVMSupport() const override;
|
||||
void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
|
||||
llvm::opt::ArgStringList &CC1Args) const override;
|
||||
|
||||
Tool *buildLinker() const override;
|
||||
};
|
||||
|
||||
class LLVM_LIBRARY_VISIBILITY PS4CPU : public Generic_ELF {
|
||||
|
|
|
@ -6439,6 +6439,34 @@ void amdgpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
|||
}
|
||||
// AMDGPU tools end.
|
||||
|
||||
wasm::Linker::Linker(const ToolChain &TC)
|
||||
: GnuTool("wasm::Linker", "lld", TC) {}
|
||||
|
||||
bool wasm::Linker::isLinkJob() const {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool wasm::Linker::hasIntegratedCPP() const {
|
||||
return false;
|
||||
}
|
||||
|
||||
void wasm::Linker::ConstructJob(Compilation &C, const JobAction &JA,
|
||||
const InputInfo &Output,
|
||||
const InputInfoList &Inputs,
|
||||
const ArgList &Args,
|
||||
const char *LinkingOutput) const {
|
||||
const char *Linker = Args.MakeArgString(getToolChain().GetLinkerPath());
|
||||
ArgStringList CmdArgs;
|
||||
CmdArgs.push_back("-flavor");
|
||||
CmdArgs.push_back("ld");
|
||||
CmdArgs.push_back("-target");
|
||||
CmdArgs.push_back(Args.MakeArgString(getToolChain().getTripleString()));
|
||||
AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs);
|
||||
CmdArgs.push_back("-o");
|
||||
CmdArgs.push_back(Output.getFilename());
|
||||
C.addCommand(llvm::make_unique<Command>(JA, *this, Linker, CmdArgs, Inputs));
|
||||
}
|
||||
|
||||
const std::string arm::getARMArch(StringRef Arch, const llvm::Triple &Triple) {
|
||||
std::string MArch;
|
||||
if (!Arch.empty())
|
||||
|
|
|
@ -245,6 +245,21 @@ public:
|
|||
|
||||
} // end namespace amdgpu
|
||||
|
||||
namespace wasm {
|
||||
|
||||
class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool {
|
||||
public:
|
||||
explicit Linker(const ToolChain &TC);
|
||||
bool isLinkJob() const override;
|
||||
bool hasIntegratedCPP() const override;
|
||||
void ConstructJob(Compilation &C, const JobAction &JA,
|
||||
const InputInfo &Output, const InputInfoList &Inputs,
|
||||
const llvm::opt::ArgList &TCArgs,
|
||||
const char *LinkingOutput) const override;
|
||||
};
|
||||
|
||||
} // end namespace wasm
|
||||
|
||||
namespace arm {
|
||||
std::string getARMTargetCPU(StringRef CPU, StringRef Arch,
|
||||
const llvm::Triple &Triple);
|
||||
|
|
Loading…
Reference in New Issue