diff --git a/clang/include/clang/Driver/ToolChain.h b/clang/include/clang/Driver/ToolChain.h --- a/clang/include/clang/Driver/ToolChain.h +++ b/clang/include/clang/Driver/ToolChain.h @@ -201,6 +201,9 @@ // Accessors + /// Temporary for Darwin::Linker + const llvm::opt::ArgList &getArgs_DO_NOT_USE() const { return Args; } + const Driver &getDriver() const { return D; } llvm::vfs::FileSystem &getVFS() const; const llvm::Triple &getTriple() const { return Triple; } diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h --- a/clang/lib/Driver/ToolChains/Darwin.h +++ b/clang/lib/Driver/ToolChains/Darwin.h @@ -69,9 +69,10 @@ const InputInfoList &Inputs) const; public: - Linker(const ToolChain &TC) - : MachOTool("darwin::Linker", "linker", TC, RF_FileList, - llvm::sys::WEM_UTF8, "-filelist") {} + Linker(const ToolChain &TC, bool UseAtFile) + : MachOTool("darwin::Linker", "linker", TC, + UseAtFile ? RF_Full : RF_FileList, llvm::sys::WEM_UTF8, + UseAtFile ? "@" : "-filelist") {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -929,7 +929,22 @@ } } -Tool *MachO::buildLinker() const { return new tools::darwin::Linker(*this); } +Tool *MachO::buildLinker() const { + // Determine whether to use an @responsefile or the old -filelist mechanism. + bool UseAtFile = false; + unsigned Version[5] = {0, 0, 0, 0, 0}; + if (Arg *A = + getArgs_DO_NOT_USE().getLastArg(options::OPT_mlinker_version_EQ)) { + // We don't need to diagnose a parse error here, it'll be caught in + // ConstructJob. + if (Driver::GetReleaseVersion(A->getValue(), Version)) { + if (Version[0] >= 607) + UseAtFile = true; + } + } + + return new tools::darwin::Linker(*this, UseAtFile); +} Tool *MachO::buildAssembler() const { return new tools::darwin::Assembler(*this);