diff --git a/clang/include/clang/Driver/Job.h b/clang/include/clang/Driver/Job.h --- a/clang/include/clang/Driver/Job.h +++ b/clang/include/clang/Driver/Job.h @@ -16,6 +16,7 @@ #include "llvm/ADT/StringRef.h" #include "llvm/ADT/iterator.h" #include "llvm/Option/Option.h" +#include "llvm/Support/Program.h" #include #include #include @@ -36,6 +37,69 @@ : Filename(Filename), VFSPath(VFSPath) {} }; +// Encodes the kind of response file supported for a command invocation. +// Response files are necessary if the command line gets too large, requiring +// the arguments to be transferred to a file. +struct ResponseFileSupport { + enum ResponseFileKind { + // Provides full support for response files, which means we can transfer + // all tool input arguments to a file. + RF_Full, + // Input file names can live in a file, but flags can't. This is a special + // case for old versions of Apple's ld64. + RF_FileList, + // Does not support response files: all arguments must be passed via + // command line. + RF_None + }; + /// The level of support for response files. + ResponseFileKind ResponseKind; + + /// The encoding to use when writing response files on Windows. Ignored on + /// other host OSes. + /// + /// Windows use cases: - GCC and Binutils on mingw only accept ANSI response + /// files encoded with the system current code page. + /// - MSVC's CL.exe and LINK.exe accept UTF16 on Windows. + /// - Clang accepts both UTF8 and UTF16. + /// + /// FIXME: When GNU tools learn how to parse UTF16 on Windows, we should + /// always use UTF16 for Windows, which is the Windows official encoding for + /// international characters. + llvm::sys::WindowsEncodingMethod ResponseEncoding; + + /// What prefix to use for the command-line argument when passing a response + /// file. + const char *ResponseFlag; + + /// Returns a ResponseFileSupport indicating that response files are not + /// supported. + static constexpr ResponseFileSupport None() { + return {RF_None, llvm::sys::WEM_UTF8, nullptr}; + } + + /// Returns a ResponseFileSupport indicating that response files are + /// supported, using the @file syntax. On windows, the file is written in the + /// UTF8 encoding. On other OSes, no re-encoding occurs. + static constexpr ResponseFileSupport AtFileUTF8() { + return {RF_Full, llvm::sys::WEM_UTF8, "@"}; + } + + /// Returns a ResponseFileSupport indicating that response files are + /// supported, using the @file syntax. On windows, the file is written in the + /// current ANSI code-page encoding. On other OSes, no re-encoding occurs. + static constexpr ResponseFileSupport AtFileCurCP() { + return {RF_Full, llvm::sys::WEM_CurrentCodePage, "@"}; + } + + /// Returns a ResponseFileSupport indicating that response files are + /// supported, using the @file syntax. On windows, the file is written in the + /// UTF-16 encoding. On other OSes, no re-encoding occurs. + static constexpr ResponseFileSupport AtFileUTF16() { + return {RF_Full, llvm::sys::WEM_UTF16, "@"}; + } +}; + /// Command - An executable path/name and argument vector to /// execute. class Command { @@ -45,6 +109,9 @@ /// Tool - The tool which caused the creation of this job. const Tool &Creator; + /// Whether and how to generate response files if the arguments are too long. + ResponseFileSupport ResponseSupport; + /// The executable to run. const char *Executable; @@ -89,7 +156,8 @@ /// Whether the command will be executed in this process or not. bool InProcess = false; - Command(const Action &Source, const Tool &Creator, const char *Executable, + Command(const Action &Source, const Tool &Creator, + ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef Inputs); // FIXME: This really shouldn't be copyable, but is currently copied in some @@ -109,11 +177,16 @@ /// getCreator - Return the Tool which caused the creation of this job. const Tool &getCreator() const { return Creator; } + /// Returns the kind of response file supported by the current invocation. + const ResponseFileSupport &getResponseFileSupport() { + return ResponseSupport; + } + /// Set to pass arguments via a response file when launching the command void setResponseFile(const char *FileName); - /// Set an input file list, necessary if we need to use a response file but - /// the tool being called only supports input files lists. + /// Set an input file list, necessary if you specified an RF_FileList response + /// file support. void setInputFileList(llvm::opt::ArgStringList List) { InputFileList = std::move(List); } @@ -136,7 +209,8 @@ /// Use the CC1 tool callback when available, to avoid creating a new process class CC1Command : public Command { public: - CC1Command(const Action &Source, const Tool &Creator, const char *Executable, + CC1Command(const Action &Source, const Tool &Creator, + ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef Inputs); @@ -154,7 +228,7 @@ class FallbackCommand : public Command { public: FallbackCommand(const Action &Source_, const Tool &Creator_, - const char *Executable_, + ResponseFileSupport ResponseSupport, const char *Executable_, const llvm::opt::ArgStringList &Arguments_, ArrayRef Inputs, std::unique_ptr Fallback_); @@ -173,6 +247,7 @@ class ForceSuccessCommand : public Command { public: ForceSuccessCommand(const Action &Source_, const Tool &Creator_, + ResponseFileSupport ResponseSupport, const char *Executable_, const llvm::opt::ArgStringList &Arguments_, ArrayRef Inputs); diff --git a/clang/include/clang/Driver/Tool.h b/clang/include/clang/Driver/Tool.h --- a/clang/include/clang/Driver/Tool.h +++ b/clang/include/clang/Driver/Tool.h @@ -10,7 +10,6 @@ #define LLVM_CLANG_DRIVER_TOOL_H #include "clang/Basic/LLVM.h" -#include "llvm/Support/Program.h" namespace llvm { namespace opt { @@ -31,24 +30,6 @@ /// Tool - Information on a specific compilation tool. class Tool { -public: - // Documents the level of support for response files in this tool. - // Response files are necessary if the command line gets too large, - // requiring the arguments to be transferred to a file. - enum ResponseFileSupport { - // Provides full support for response files, which means we can transfer - // all tool input arguments to a file. E.g.: clang, gcc, binutils and MSVC - // tools. - RF_Full, - // Input file names can live in a file, but flags can't. E.g.: ld64 (Mac - // OS X linker). - RF_FileList, - // Does not support response files: all arguments must be passed via - // command line. - RF_None - }; - -private: /// The tool name (for debugging). const char *Name; @@ -58,20 +39,8 @@ /// The tool chain this tool is a part of. const ToolChain &TheToolChain; - /// The level of support for response files seen in this tool - const ResponseFileSupport ResponseSupport; - - /// The encoding to use when writing response files for this tool on Windows - const llvm::sys::WindowsEncodingMethod ResponseEncoding; - - /// The flag used to pass a response file via command line to this tool - const char *const ResponseFlag; - public: - Tool(const char *Name, const char *ShortName, const ToolChain &TC, - ResponseFileSupport ResponseSupport = RF_None, - llvm::sys::WindowsEncodingMethod ResponseEncoding = llvm::sys::WEM_UTF8, - const char *ResponseFlag = "@"); + Tool(const char *Name, const char *ShortName, const ToolChain &TC); public: virtual ~Tool(); @@ -87,29 +56,6 @@ virtual bool hasIntegratedCPP() const = 0; virtual bool isLinkJob() const { return false; } virtual bool isDsymutilJob() const { return false; } - /// Returns the level of support for response files of this tool, - /// whether it accepts arguments to be passed via a file on disk. - ResponseFileSupport getResponseFilesSupport() const { - return ResponseSupport; - } - /// Returns which encoding the response file should use. This is only - /// relevant on Windows platforms where there are different encodings being - /// accepted for different tools. On UNIX, UTF8 is universal. - /// - /// Windows use cases: - GCC and Binutils on mingw only accept ANSI response - /// files encoded with the system current code page. - /// - MSVC's CL.exe and LINK.exe accept UTF16 on Windows. - /// - Clang accepts both UTF8 and UTF16. - /// - /// FIXME: When GNU tools learn how to parse UTF16 on Windows, we should - /// always use UTF16 for Windows, which is the Windows official encoding for - /// international characters. - llvm::sys::WindowsEncodingMethod getResponseFileEncoding() const { - return ResponseEncoding; - } - /// Returns which prefix to use when passing the name of a response - /// file as a parameter to this tool. - const char *getResponseFileFlag() const { return ResponseFlag; } /// Does this tool have "good" standardized diagnostics, or should the /// driver add an additional "command failed" diagnostic on failures. 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,9 +201,6 @@ // 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/Driver.cpp b/clang/lib/Driver/Driver.cpp --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1456,7 +1456,8 @@ // capacity if the tool does not support response files, there is a chance/ // that things will just work without a response file, so we silently just // skip it. - if (Cmd.getCreator().getResponseFilesSupport() == Tool::RF_None || + if (Cmd.getResponseFileSupport().ResponseKind == + ResponseFileSupport::RF_None || llvm::sys::commandLineFitsWithinSystemLimits(Cmd.getExecutable(), Cmd.getArguments())) return; diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp --- a/clang/lib/Driver/Job.cpp +++ b/clang/lib/Driver/Job.cpp @@ -36,11 +36,11 @@ using namespace driver; Command::Command(const Action &Source, const Tool &Creator, - const char *Executable, + ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef Inputs) - : Source(Source), Creator(Creator), Executable(Executable), - Arguments(Arguments) { + : Source(Source), Creator(Creator), ResponseSupport(ResponseSupport), + Executable(Executable), Arguments(Arguments) { for (const auto &II : Inputs) if (II.isFilename()) InputFilenames.push_back(II.getFilename()); @@ -102,7 +102,7 @@ void Command::writeResponseFile(raw_ostream &OS) const { // In a file list, we only write the set of inputs to the response file - if (Creator.getResponseFilesSupport() == Tool::RF_FileList) { + if (ResponseSupport.ResponseKind == ResponseFileSupport::RF_FileList) { for (const auto *Arg : InputFileList) { OS << Arg << '\n'; } @@ -131,7 +131,7 @@ // When not a file list, all arguments are sent to the response file. // This leaves us to set the argv to a single parameter, requesting the tool // to read the response file. - if (Creator.getResponseFilesSupport() != Tool::RF_FileList) { + if (ResponseSupport.ResponseKind != ResponseFileSupport::RF_FileList) { Out.push_back(Executable); Out.push_back(ResponseFileFlag.c_str()); return; @@ -149,7 +149,7 @@ Out.push_back(Arg); } else if (FirstInput) { FirstInput = false; - Out.push_back(Creator.getResponseFileFlag()); + Out.push_back(ResponseSupport.ResponseFlag); Out.push_back(ResponseFile); } } @@ -277,7 +277,7 @@ writeResponseFile(OS); // Avoiding duplicated newline terminator, since FileLists are // newline-separated. - if (Creator.getResponseFilesSupport() != Tool::RF_FileList) + if (ResponseSupport.ResponseKind != ResponseFileSupport::RF_FileList) OS << "\n"; OS << " (end of response file)"; } @@ -287,7 +287,7 @@ void Command::setResponseFile(const char *FileName) { ResponseFile = FileName; - ResponseFileFlag = Creator.getResponseFileFlag(); + ResponseFileFlag = ResponseSupport.ResponseFlag; ResponseFileFlag += FileName; } @@ -327,7 +327,7 @@ // Save the response file in the appropriate encoding if (std::error_code EC = writeFileWithEncoding( - ResponseFile, RespContents, Creator.getResponseFileEncoding())) { + ResponseFile, RespContents, ResponseSupport.ResponseEncoding)) { if (ErrMsg) *ErrMsg = EC.message(); if (ExecutionFailed) @@ -354,10 +354,11 @@ } CC1Command::CC1Command(const Action &Source, const Tool &Creator, + ResponseFileSupport ResponseSupport, const char *Executable, const llvm::opt::ArgStringList &Arguments, ArrayRef Inputs) - : Command(Source, Creator, Executable, Arguments, Inputs) { + : Command(Source, Creator, ResponseSupport, Executable, Arguments, Inputs) { InProcess = true; } @@ -410,11 +411,13 @@ } FallbackCommand::FallbackCommand(const Action &Source_, const Tool &Creator_, + ResponseFileSupport ResponseSupport, const char *Executable_, const llvm::opt::ArgStringList &Arguments_, ArrayRef Inputs, std::unique_ptr Fallback_) - : Command(Source_, Creator_, Executable_, Arguments_, Inputs), + : Command(Source_, Creator_, ResponseSupport, Executable_, Arguments_, + Inputs), Fallback(std::move(Fallback_)) {} void FallbackCommand::Print(raw_ostream &OS, const char *Terminator, @@ -451,9 +454,11 @@ } ForceSuccessCommand::ForceSuccessCommand( - const Action &Source_, const Tool &Creator_, const char *Executable_, + const Action &Source_, const Tool &Creator_, + ResponseFileSupport ResponseSupport, const char *Executable_, const llvm::opt::ArgStringList &Arguments_, ArrayRef Inputs) - : Command(Source_, Creator_, Executable_, Arguments_, Inputs) {} + : Command(Source_, Creator_, ResponseSupport, Executable_, Arguments_, + Inputs) {} void ForceSuccessCommand::Print(raw_ostream &OS, const char *Terminator, bool Quote, CrashReportInfo *CrashInfo) const { diff --git a/clang/lib/Driver/Tool.cpp b/clang/lib/Driver/Tool.cpp --- a/clang/lib/Driver/Tool.cpp +++ b/clang/lib/Driver/Tool.cpp @@ -11,13 +11,8 @@ using namespace clang::driver; -Tool::Tool(const char *_Name, const char *_ShortName, const ToolChain &TC, - ResponseFileSupport _ResponseSupport, - llvm::sys::WindowsEncodingMethod _ResponseEncoding, - const char *_ResponseFlag) - : Name(_Name), ShortName(_ShortName), TheToolChain(TC), - ResponseSupport(_ResponseSupport), ResponseEncoding(_ResponseEncoding), - ResponseFlag(_ResponseFlag) {} +Tool::Tool(const char *_Name, const char *_ShortName, const ToolChain &TC) + : Name(_Name), ShortName(_ShortName), TheToolChain(TC) {} Tool::~Tool() { } diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp --- a/clang/lib/Driver/ToolChains/AIX.cpp +++ b/clang/lib/Driver/ToolChains/AIX.cpp @@ -73,7 +73,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } void aix::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -152,7 +153,8 @@ } const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } /// AIX - AIX tool chain which can call as(1) and ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/AMDGPU.h b/clang/lib/Driver/ToolChains/AMDGPU.h --- a/clang/lib/Driver/ToolChains/AMDGPU.h +++ b/clang/lib/Driver/ToolChains/AMDGPU.h @@ -25,9 +25,9 @@ namespace tools { namespace amdgpu { -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("amdgpu::Linker", "ld.lld", TC) {} + Linker(const ToolChain &TC) : Tool("amdgpu::Linker", "ld.lld", TC) {} bool isLinkJob() const override { return true; } bool hasIntegratedCPP() const override { return false; } void ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -251,8 +251,9 @@ CmdArgs.push_back("-shared"); CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Linker), - CmdArgs, Inputs)); + C.addCommand( + std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), + Args.MakeArgString(Linker), CmdArgs, Inputs)); } void amdgpu::getAMDGPUTargetFeatures(const Driver &D, diff --git a/clang/lib/Driver/ToolChains/AVR.h b/clang/lib/Driver/ToolChains/AVR.h --- a/clang/lib/Driver/ToolChains/AVR.h +++ b/clang/lib/Driver/ToolChains/AVR.h @@ -40,10 +40,10 @@ namespace tools { namespace AVR { -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: Linker(const llvm::Triple &Triple, const ToolChain &TC, bool LinkStdlib) - : GnuTool("AVR::Linker", "avr-ld", TC), Triple(Triple), + : Tool("AVR::Linker", "avr-ld", TC), Triple(Triple), LinkStdlib(LinkStdlib) {} bool hasIntegratedCPP() const override { return false; } diff --git a/clang/lib/Driver/ToolChains/AVR.cpp b/clang/lib/Driver/ToolChains/AVR.cpp --- a/clang/lib/Driver/ToolChains/AVR.cpp +++ b/clang/lib/Driver/ToolChains/AVR.cpp @@ -142,8 +142,9 @@ CmdArgs.push_back(Args.MakeArgString(std::string("-m") + *FamilyName)); } - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Linker), - CmdArgs, Inputs)); + C.addCommand( + std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), + Args.MakeArgString(Linker), CmdArgs, Inputs)); } llvm::Optional AVRToolChain::findAVRLibcInstallation() const { diff --git a/clang/lib/Driver/ToolChains/Ananas.h b/clang/lib/Driver/ToolChains/Ananas.h --- a/clang/lib/Driver/ToolChains/Ananas.h +++ b/clang/lib/Driver/ToolChains/Ananas.h @@ -19,10 +19,9 @@ /// ananas -- Directly call GNU Binutils assembler and linker namespace ananas { -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: - Assembler(const ToolChain &TC) - : GnuTool("ananas::Assembler", "assembler", TC) {} + Assembler(const ToolChain &TC) : Tool("ananas::Assembler", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -32,9 +31,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("ananas::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("ananas::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/Ananas.cpp b/clang/lib/Driver/ToolChains/Ananas.cpp --- a/clang/lib/Driver/ToolChains/Ananas.cpp +++ b/clang/lib/Driver/ToolChains/Ananas.cpp @@ -39,7 +39,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void ananas::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -123,7 +124,8 @@ } const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } // Ananas - Ananas tool chain which can call as(1) and ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp --- a/clang/lib/Driver/ToolChains/BareMetal.cpp +++ b/clang/lib/Driver/ToolChains/BareMetal.cpp @@ -191,7 +191,7 @@ CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique(JA, *this, - Args.MakeArgString(TC.GetLinkerPath()), - CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Args.MakeArgString(TC.GetLinkerPath()), + CmdArgs, Inputs)); } diff --git a/clang/lib/Driver/ToolChains/Clang.h b/clang/lib/Driver/ToolChains/Clang.h --- a/clang/lib/Driver/ToolChains/Clang.h +++ b/clang/lib/Driver/ToolChains/Clang.h @@ -121,7 +121,7 @@ class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool { public: ClangAs(const ToolChain &TC) - : Tool("clang::as", "clang integrated assembler", TC, RF_Full) {} + : Tool("clang::as", "clang integrated assembler", TC) {} void AddMIPSTargetArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const; void AddX86TargetArgs(const llvm::opt::ArgList &Args, diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4337,8 +4337,9 @@ II.getInputArg().renderAsInput(Args, CmdArgs); } - C.addCommand(std::make_unique(JA, *this, D.getClangProgramPath(), - CmdArgs, Inputs)); + C.addCommand( + std::make_unique(JA, *this, ResponseFileSupport::AtFileUTF8(), + D.getClangProgramPath(), CmdArgs, Inputs)); return; } @@ -6256,19 +6257,21 @@ auto CLCommand = getCLFallback()->GetCommand(C, JA, Output, Inputs, Args, LinkingOutput); C.addCommand(std::make_unique( - JA, *this, Exec, CmdArgs, Inputs, std::move(CLCommand))); + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs, + std::move(CLCommand))); } else if (Args.hasArg(options::OPT__SLASH_fallback) && isa(JA)) { // In /fallback builds, run the main compilation even if the pch generation // fails, so that the main compilation's fallback to cl.exe runs. - C.addCommand(std::make_unique(JA, *this, Exec, - CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } else if (D.CC1Main && !D.CCGenDiagnostics) { // Invoke the CC1 directly in this process - C.addCommand( - std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } else { - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } // Make the compile command echo its inputs for /showFilenames. @@ -6303,7 +6306,7 @@ // CAUTION! The first constructor argument ("clang") is not arbitrary, // as it is for other tools. Some operations on a Tool actually test // whether that tool is Clang based on the Tool's Name as a string. - : Tool("clang", "clang frontend", TC, RF_Full) {} + : Tool("clang", "clang frontend", TC) {} Clang::~Clang() {} @@ -7006,7 +7009,8 @@ CmdArgs.push_back(Input.getFilename()); const char *Exec = getToolChain().getDriver().getClangProgramPath(); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } // Begin OffloadBundler @@ -7090,7 +7094,7 @@ // All the inputs are encoded as commands. C.addCommand(std::make_unique( - JA, *this, + JA, *this, ResponseFileSupport::None(), TCArgs.MakeArgString(getToolChain().GetProgramPath(getShortName())), CmdArgs, None)); } @@ -7156,7 +7160,7 @@ // All the inputs are encoded as commands. C.addCommand(std::make_unique( - JA, *this, + JA, *this, ResponseFileSupport::None(), TCArgs.MakeArgString(getToolChain().GetProgramPath(getShortName())), CmdArgs, None)); } @@ -7186,7 +7190,7 @@ } C.addCommand(std::make_unique( - JA, *this, + JA, *this, ResponseFileSupport::None(), Args.MakeArgString(getToolChain().GetProgramPath(getShortName())), CmdArgs, Inputs)); } diff --git a/clang/lib/Driver/ToolChains/CloudABI.h b/clang/lib/Driver/ToolChains/CloudABI.h --- a/clang/lib/Driver/ToolChains/CloudABI.h +++ b/clang/lib/Driver/ToolChains/CloudABI.h @@ -19,9 +19,9 @@ /// cloudabi -- Directly call GNU Binutils linker namespace cloudabi { -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("cloudabi::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("cloudabi::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/CloudABI.cpp b/clang/lib/Driver/ToolChains/CloudABI.cpp --- a/clang/lib/Driver/ToolChains/CloudABI.cpp +++ b/clang/lib/Driver/ToolChains/CloudABI.cpp @@ -92,7 +92,8 @@ CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o"))); const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } // CloudABI - CloudABI tool chain which can call ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -864,10 +864,12 @@ InputInfo II(types::TY_Object, Output.getFilename(), Output.getFilename()); // First extract the dwo sections. - C.addCommand(std::make_unique(JA, T, Exec, ExtractArgs, II)); + C.addCommand(std::make_unique( + JA, T, ResponseFileSupport::AtFileCurCP(), Exec, ExtractArgs, II)); // Then remove them from the original .o file. - C.addCommand(std::make_unique(JA, T, Exec, StripArgs, II)); + C.addCommand(std::make_unique( + JA, T, ResponseFileSupport::AtFileCurCP(), Exec, StripArgs, II)); } // Claim options we don't want to warn if they are unused. We do this for diff --git a/clang/lib/Driver/ToolChains/CrossWindows.h b/clang/lib/Driver/ToolChains/CrossWindows.h --- a/clang/lib/Driver/ToolChains/CrossWindows.h +++ b/clang/lib/Driver/ToolChains/CrossWindows.h @@ -33,8 +33,7 @@ class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) - : Tool("CrossWindows::Linker", "ld", TC, RF_Full) {} + Linker(const ToolChain &TC) : Tool("CrossWindows::Linker", "ld", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/CrossWindows.cpp b/clang/lib/Driver/ToolChains/CrossWindows.cpp --- a/clang/lib/Driver/ToolChains/CrossWindows.cpp +++ b/clang/lib/Driver/ToolChains/CrossWindows.cpp @@ -57,7 +57,8 @@ const std::string Assembler = TC.GetProgramPath("as"); Exec = Args.MakeArgString(Assembler); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } void tools::CrossWindows::Linker::ConstructJob( @@ -202,7 +203,8 @@ Exec = Args.MakeArgString(TC.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } CrossWindowsToolChain::CrossWindowsToolChain(const Driver &D, diff --git a/clang/lib/Driver/ToolChains/Cuda.h b/clang/lib/Driver/ToolChains/Cuda.h --- a/clang/lib/Driver/ToolChains/Cuda.h +++ b/clang/lib/Driver/ToolChains/Cuda.h @@ -89,9 +89,7 @@ // Run ptxas, the NVPTX assembler. class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: - Assembler(const ToolChain &TC) - : Tool("NVPTX::Assembler", "ptxas", TC, RF_Full, llvm::sys::WEM_UTF8, - "--options-file") {} + Assembler(const ToolChain &TC) : Tool("NVPTX::Assembler", "ptxas", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -105,9 +103,7 @@ // assembly into a single output file. class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) - : Tool("NVPTX::Linker", "fatbinary", TC, RF_Full, llvm::sys::WEM_UTF8, - "--options-file") {} + Linker(const ToolChain &TC) : Tool("NVPTX::Linker", "fatbinary", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -120,8 +116,7 @@ class LLVM_LIBRARY_VISIBILITY OpenMPLinker : public Tool { public: OpenMPLinker(const ToolChain &TC) - : Tool("NVPTX::OpenMPLinker", "nvlink", TC, RF_Full, llvm::sys::WEM_UTF8, - "--options-file") {} + : Tool("NVPTX::OpenMPLinker", "nvlink", TC) {} bool hasIntegratedCPP() const override { return false; } diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp --- a/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/clang/lib/Driver/ToolChains/Cuda.cpp @@ -423,7 +423,11 @@ Exec = A->getValue(); else Exec = Args.MakeArgString(TC.GetProgramPath("ptxas")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, + ResponseFileSupport{ResponseFileSupport::RF_Full, llvm::sys::WEM_UTF8, + "--options-file"}, + Exec, CmdArgs, Inputs)); } static bool shouldIncludePTX(const ArgList &Args, const char *gpu_arch) { @@ -488,7 +492,11 @@ CmdArgs.push_back(Args.MakeArgString(A)); const char *Exec = Args.MakeArgString(TC.GetProgramPath("fatbinary")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, + ResponseFileSupport{ResponseFileSupport::RF_Full, llvm::sys::WEM_UTF8, + "--options-file"}, + Exec, CmdArgs, Inputs)); } void NVPTX::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA, @@ -565,7 +573,11 @@ const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("nvlink")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, + ResponseFileSupport{ResponseFileSupport::RF_Full, llvm::sys::WEM_UTF8, + "--options-file"}, + Exec, CmdArgs, Inputs)); } /// CUDA toolchain. Our assembler is ptxas, and our "linker" is fatbinary, 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 @@ -40,13 +40,8 @@ } public: - MachOTool( - const char *Name, const char *ShortName, const ToolChain &TC, - ResponseFileSupport ResponseSupport = RF_None, - llvm::sys::WindowsEncodingMethod ResponseEncoding = llvm::sys::WEM_UTF8, - const char *ResponseFlag = "@") - : Tool(Name, ShortName, TC, ResponseSupport, ResponseEncoding, - ResponseFlag) {} + MachOTool(const char *Name, const char *ShortName, const ToolChain &TC) + : Tool(Name, ShortName, TC) {} }; class LLVM_LIBRARY_VISIBILITY Assembler : public MachOTool { @@ -66,13 +61,10 @@ bool NeedsTempPath(const InputInfoList &Inputs) const; void AddLinkArgs(Compilation &C, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, - const InputInfoList &Inputs) const; + const InputInfoList &Inputs, unsigned Version[5]) const; public: - Linker(const ToolChain &TC, bool UseAtFile) - : MachOTool("darwin::Linker", "linker", TC, - UseAtFile ? RF_Full : RF_FileList, llvm::sys::WEM_UTF8, - UseAtFile ? "@" : "-filelist") {} + Linker(const ToolChain &TC) : MachOTool("darwin::Linker", "linker", TC) {} 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 @@ -148,7 +148,8 @@ // asm_final spec is empty. const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } void darwin::MachOTool::anchor() {} @@ -202,16 +203,11 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args, ArgStringList &CmdArgs, - const InputInfoList &Inputs) const { + const InputInfoList &Inputs, + unsigned Version[5]) const { const Driver &D = getToolChain().getDriver(); const toolchains::MachO &MachOTC = getMachOToolChain(); - unsigned Version[5] = {0, 0, 0, 0, 0}; - if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ)) { - if (!Driver::GetReleaseVersion(A->getValue(), Version)) - D.Diag(diag::err_drv_invalid_version_number) << A->getAsString(Args); - } - // Newer linkers support -demangle. Pass it if supported and not disabled by // the user. if (Version[0] >= 100 && !Args.hasArg(options::OPT_Z_Xlinker__no_demangle)) @@ -525,13 +521,21 @@ const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("touch")); CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, None)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::None(), Exec, CmdArgs, None)); return; } + unsigned Version[5] = {0, 0, 0, 0, 0}; + if (Arg *A = Args.getLastArg(options::OPT_mlinker_version_EQ)) { + if (!Driver::GetReleaseVersion(A->getValue(), Version)) + getToolChain().getDriver().Diag(diag::err_drv_invalid_version_number) + << A->getAsString(Args); + } + // I'm not sure why this particular decomposition exists in gcc, but // we follow suite for ease of comparison. - AddLinkArgs(C, Args, CmdArgs, Inputs); + AddLinkArgs(C, Args, CmdArgs, Inputs, Version); if (willEmitRemarks(Args) && checkRemarksOptions(getToolChain().getDriver(), Args, @@ -682,9 +686,16 @@ } } + ResponseFileSupport ResponseSupport = ResponseFileSupport::AtFileUTF8(); + if (Version[0] < 607) { + // For older versions of the linker, use the legacy filelist method instead. + ResponseSupport = {ResponseFileSupport::RF_FileList, llvm::sys::WEM_UTF8, + "-filelist"}; + } + const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath()); - std::unique_ptr Cmd = - std::make_unique(JA, *this, Exec, CmdArgs, Inputs); + std::unique_ptr Cmd = std::make_unique( + JA, *this, ResponseSupport, Exec, CmdArgs, Inputs); Cmd->setInputFileList(std::move(InputFileList)); C.addCommand(std::move(Cmd)); } @@ -708,7 +719,8 @@ } const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("lipo")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } void darwin::Dsymutil::ConstructJob(Compilation &C, const JobAction &JA, @@ -728,7 +740,8 @@ const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("dsymutil")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } void darwin::VerifyDebug::ConstructJob(Compilation &C, const JobAction &JA, @@ -751,7 +764,8 @@ const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("dwarfdump")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } MachO::MachO(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) @@ -929,22 +943,7 @@ } } -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::buildLinker() const { return new tools::darwin::Linker(*this); } Tool *MachO::buildAssembler() const { return new tools::darwin::Assembler(*this); diff --git a/clang/lib/Driver/ToolChains/DragonFly.h b/clang/lib/Driver/ToolChains/DragonFly.h --- a/clang/lib/Driver/ToolChains/DragonFly.h +++ b/clang/lib/Driver/ToolChains/DragonFly.h @@ -18,10 +18,10 @@ namespace tools { /// dragonfly -- Directly call GNU Binutils assembler and linker namespace dragonfly { -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: Assembler(const ToolChain &TC) - : GnuTool("dragonfly::Assembler", "assembler", TC) {} + : Tool("dragonfly::Assembler", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -31,9 +31,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("dragonfly::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("dragonfly::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/DragonFly.cpp b/clang/lib/Driver/ToolChains/DragonFly.cpp --- a/clang/lib/Driver/ToolChains/DragonFly.cpp +++ b/clang/lib/Driver/ToolChains/DragonFly.cpp @@ -45,7 +45,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void dragonfly::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -169,7 +170,8 @@ getToolChain().addProfileRTLibs(Args, CmdArgs); const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } /// DragonFly - DragonFly tool chain which can call as(1) and ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp --- a/clang/lib/Driver/ToolChains/Flang.cpp +++ b/clang/lib/Driver/ToolChains/Flang.cpp @@ -70,10 +70,10 @@ const auto& D = C.getDriver(); const char* Exec = Args.MakeArgString(D.GetProgramPath("flang", TC)); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } -Flang::Flang(const ToolChain &TC) - : Tool("flang", "flang frontend", TC, RF_Full) {} +Flang::Flang(const ToolChain &TC) : Tool("flang", "flang frontend", TC) {} Flang::~Flang() {} diff --git a/clang/lib/Driver/ToolChains/FreeBSD.h b/clang/lib/Driver/ToolChains/FreeBSD.h --- a/clang/lib/Driver/ToolChains/FreeBSD.h +++ b/clang/lib/Driver/ToolChains/FreeBSD.h @@ -19,10 +19,10 @@ /// freebsd -- Directly call GNU Binutils assembler and linker namespace freebsd { -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: Assembler(const ToolChain &TC) - : GnuTool("freebsd::Assembler", "assembler", TC) {} + : Tool("freebsd::Assembler", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -32,9 +32,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("freebsd::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("freebsd::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/FreeBSD.cpp b/clang/lib/Driver/ToolChains/FreeBSD.cpp --- a/clang/lib/Driver/ToolChains/FreeBSD.cpp +++ b/clang/lib/Driver/ToolChains/FreeBSD.cpp @@ -128,7 +128,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void freebsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -358,7 +359,8 @@ ToolChain.addProfileRTLibs(Args, CmdArgs); const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } /// FreeBSD - FreeBSD tool chain which can call as(1) and ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/Fuchsia.cpp b/clang/lib/Driver/ToolChains/Fuchsia.cpp --- a/clang/lib/Driver/ToolChains/Fuchsia.cpp +++ b/clang/lib/Driver/ToolChains/Fuchsia.cpp @@ -164,7 +164,8 @@ CmdArgs.push_back("-lc"); } - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } /// Fuchsia - Fuchsia tool chain which can call as(1) and ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/Gnu.h b/clang/lib/Driver/ToolChains/Gnu.h --- a/clang/lib/Driver/ToolChains/Gnu.h +++ b/clang/lib/Driver/ToolChains/Gnu.h @@ -36,21 +36,11 @@ namespace tools { -/// Base class for all GNU tools that provide the same behavior when -/// it comes to response files support -class LLVM_LIBRARY_VISIBILITY GnuTool : public Tool { - virtual void anchor(); - -public: - GnuTool(const char *Name, const char *ShortName, const ToolChain &TC) - : Tool(Name, ShortName, TC, RF_Full, llvm::sys::WEM_CurrentCodePage) {} -}; - /// Directly call GNU Binutils' assembler and linker. namespace gnutools { -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: - Assembler(const ToolChain &TC) : GnuTool("GNU::Assembler", "assembler", TC) {} + Assembler(const ToolChain &TC) : Tool("GNU::Assembler", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -60,9 +50,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("GNU::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("GNU::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } @@ -73,10 +63,10 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY StaticLibTool : public GnuTool { +class LLVM_LIBRARY_VISIBILITY StaticLibTool : public Tool { public: StaticLibTool(const ToolChain &TC) - : GnuTool("GNU::StaticLibTool", "static-lib-linker", TC) {} + : Tool("GNU::StaticLibTool", "static-lib-linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } @@ -90,10 +80,10 @@ /// gcc - Generic GCC tool implementations. namespace gcc { -class LLVM_LIBRARY_VISIBILITY Common : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Common : public Tool { public: Common(const char *Name, const char *ShortName, const ToolChain &TC) - : GnuTool(Name, ShortName, TC) {} + : Tool(Name, ShortName, TC) {} // A gcc tool has an "integrated" assembler that it will call to produce an // object. Let it use that assembler so that we don't have to deal with diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -37,8 +37,6 @@ using tools::addMultilibFlag; using tools::addPathIfExists; -void tools::GnuTool::anchor() {} - static bool forwardToGCC(const Option &O) { // Don't forward inputs from the original command line. They are added from // InputInfoList. @@ -190,7 +188,8 @@ GCCName = "gcc"; const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(GCCName)); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void tools::gcc::Preprocessor::RenderExtraToolArgs( @@ -377,7 +376,8 @@ } const char *Exec = Args.MakeArgString(getToolChain().GetStaticLibToolPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -673,7 +673,8 @@ Args.AddAllArgs(CmdArgs, options::OPT_T); const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void tools::gnutools::Assembler::ConstructJob(Compilation &C, @@ -940,7 +941,8 @@ const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(DefaultAssembler)); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); // Handle the debug info splitting at object creation time if we're // creating an object. diff --git a/clang/lib/Driver/ToolChains/HIP.cpp b/clang/lib/Driver/ToolChains/HIP.cpp --- a/clang/lib/Driver/ToolChains/HIP.cpp +++ b/clang/lib/Driver/ToolChains/HIP.cpp @@ -68,7 +68,8 @@ for (auto Input : Inputs) LldArgs.push_back(Input.getFilename()); const char *Lld = Args.MakeArgString(getToolChain().GetProgramPath("lld")); - C.addCommand(std::make_unique(JA, *this, Lld, LldArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Lld, LldArgs, Inputs)); } // Construct a clang-offload-bundler command to bundle code objects for @@ -101,7 +102,8 @@ const char *Bundler = Args.MakeArgString( T.getToolChain().GetProgramPath("clang-offload-bundler")); - C.addCommand(std::make_unique(JA, T, Bundler, BundlerArgs, Inputs)); + C.addCommand(std::make_unique(JA, T, ResponseFileSupport::None(), + Bundler, BundlerArgs, Inputs)); } /// Add Generated HIP Object File which has device images embedded into the @@ -171,7 +173,8 @@ "-o", Output.getFilename(), McinFile, "--filetype=obj"}; const char *Mc = Args.MakeArgString(TC.GetProgramPath("llvm-mc")); - C.addCommand(std::make_unique(JA, *this, Mc, McArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Mc, McArgs, Inputs)); } // For amdgcn the inputs of the linker job are device bitcode and output is diff --git a/clang/lib/Driver/ToolChains/Hexagon.h b/clang/lib/Driver/ToolChains/Hexagon.h --- a/clang/lib/Driver/ToolChains/Hexagon.h +++ b/clang/lib/Driver/ToolChains/Hexagon.h @@ -20,10 +20,10 @@ // For Hexagon, we do not need to instantiate tools for PreProcess, PreCompile // and Compile. // We simply use "clang -cc1" for those actions. -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: Assembler(const ToolChain &TC) - : GnuTool("hexagon::Assembler", "hexagon-as", TC) {} + : Tool("hexagon::Assembler", "hexagon-as", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -35,9 +35,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("hexagon::Linker", "hexagon-ld", TC) {} + Linker(const ToolChain &TC) : Tool("hexagon::Linker", "hexagon-ld", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp --- a/clang/lib/Driver/ToolChains/Hexagon.cpp +++ b/clang/lib/Driver/ToolChains/Hexagon.cpp @@ -189,7 +189,8 @@ } auto *Exec = Args.MakeArgString(HTC.GetProgramPath(AsName)); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void hexagon::Linker::RenderExtraToolArgs(const JobAction &JA, @@ -406,7 +407,8 @@ LinkingOutput); const char *Exec = Args.MakeArgString(HTC.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } // Hexagon tools end. diff --git a/clang/lib/Driver/ToolChains/InterfaceStubs.cpp b/clang/lib/Driver/ToolChains/InterfaceStubs.cpp --- a/clang/lib/Driver/ToolChains/InterfaceStubs.cpp +++ b/clang/lib/Driver/ToolChains/InterfaceStubs.cpp @@ -54,8 +54,9 @@ CmdArgs.push_back(Args.MakeArgString(InputFilename.c_str())); } - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Merger), - CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Args.MakeArgString(Merger), CmdArgs, + Inputs)); } } // namespace ifstool } // namespace tools diff --git a/clang/lib/Driver/ToolChains/MSP430.h b/clang/lib/Driver/ToolChains/MSP430.h --- a/clang/lib/Driver/ToolChains/MSP430.h +++ b/clang/lib/Driver/ToolChains/MSP430.h @@ -52,10 +52,9 @@ namespace tools { namespace msp430 { -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) - : GnuTool("MSP430::Linker", "msp430-elf-ld", TC) {} + Linker(const ToolChain &TC) : Tool("MSP430::Linker", "msp430-elf-ld", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } void ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/lib/Driver/ToolChains/MSP430.cpp b/clang/lib/Driver/ToolChains/MSP430.cpp --- a/clang/lib/Driver/ToolChains/MSP430.cpp +++ b/clang/lib/Driver/ToolChains/MSP430.cpp @@ -227,6 +227,7 @@ } CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Linker), - CmdArgs, Inputs)); + C.addCommand( + std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), + Args.MakeArgString(Linker), CmdArgs, Inputs)); } diff --git a/clang/lib/Driver/ToolChains/MSVC.h b/clang/lib/Driver/ToolChains/MSVC.h --- a/clang/lib/Driver/ToolChains/MSVC.h +++ b/clang/lib/Driver/ToolChains/MSVC.h @@ -24,9 +24,7 @@ namespace visualstudio { class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) - : Tool("visualstudio::Linker", "linker", TC, RF_Full, - llvm::sys::WEM_UTF16) {} + Linker(const ToolChain &TC) : Tool("visualstudio::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } @@ -40,8 +38,7 @@ class LLVM_LIBRARY_VISIBILITY Compiler : public Tool { public: Compiler(const ToolChain &TC) - : Tool("visualstudio::Compiler", "compiler", TC, RF_Full, - llvm::sys::WEM_UTF16) {} + : Tool("visualstudio::Compiler", "compiler", TC) {} bool hasIntegratedAssembler() const override { return true; } bool hasIntegratedCPP() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -592,8 +592,9 @@ linkPath = TC.GetProgramPath(Linker.str().c_str()); } - auto LinkCmd = std::make_unique( - JA, *this, Args.MakeArgString(linkPath), CmdArgs, Inputs); + auto LinkCmd = + std::make_unique(JA, *this, ResponseFileSupport::AtFileUTF16(), + Args.MakeArgString(linkPath), CmdArgs, Inputs); if (!Environment.empty()) LinkCmd->setEnvironment(Environment); C.addCommand(std::move(LinkCmd)); @@ -733,8 +734,9 @@ CmdArgs.push_back(Fo); std::string Exec = FindVisualStudioExecutable(getToolChain(), "cl.exe"); - return std::make_unique(JA, *this, Args.MakeArgString(Exec), - CmdArgs, Inputs); + return std::make_unique(JA, *this, + ResponseFileSupport::AtFileUTF16(), + Args.MakeArgString(Exec), CmdArgs, Inputs); } MSVCToolChain::MSVCToolChain(const Driver &D, const llvm::Triple &Triple, diff --git a/clang/lib/Driver/ToolChains/MinGW.h b/clang/lib/Driver/ToolChains/MinGW.h --- a/clang/lib/Driver/ToolChains/MinGW.h +++ b/clang/lib/Driver/ToolChains/MinGW.h @@ -13,6 +13,7 @@ #include "Gnu.h" #include "clang/Driver/Tool.h" #include "clang/Driver/ToolChain.h" +#include "llvm/Support/ErrorOr.h" namespace clang { namespace driver { @@ -34,8 +35,7 @@ class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) - : Tool("MinGW::Linker", "linker", TC, Tool::RF_Full) {} + Linker(const ToolChain &TC) : Tool("MinGW::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -50,7 +50,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); if (Args.hasArg(options::OPT_gsplit_dwarf)) SplitDebugInfo(getToolChain(), C, *this, JA, Args, Output, @@ -321,7 +322,8 @@ } } const char *Exec = Args.MakeArgString(TC.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } // Simplified from Generic_GCC::GCCInstallationDetector::ScanLibDirForGCCTriple. diff --git a/clang/lib/Driver/ToolChains/Minix.h b/clang/lib/Driver/ToolChains/Minix.h --- a/clang/lib/Driver/ToolChains/Minix.h +++ b/clang/lib/Driver/ToolChains/Minix.h @@ -18,10 +18,9 @@ namespace tools { /// minix -- Directly call GNU Binutils assembler and linker namespace minix { -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: - Assembler(const ToolChain &TC) - : GnuTool("minix::Assembler", "assembler", TC) {} + Assembler(const ToolChain &TC) : Tool("minix::Assembler", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -31,9 +30,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("minix::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("minix::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/Minix.cpp b/clang/lib/Driver/ToolChains/Minix.cpp --- a/clang/lib/Driver/ToolChains/Minix.cpp +++ b/clang/lib/Driver/ToolChains/Minix.cpp @@ -36,7 +36,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void tools::minix::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -88,7 +89,8 @@ } const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } /// Minix - Minix tool chain which can call as(1) and ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/Myriad.h b/clang/lib/Driver/ToolChains/Myriad.h --- a/clang/lib/Driver/ToolChains/Myriad.h +++ b/clang/lib/Driver/ToolChains/Myriad.h @@ -49,9 +49,9 @@ /// whereas the linker, which accepts code for a mixture of Sparc and SHAVE, /// is in the Myriad namespace. namespace Myriad { -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("shave::Linker", "ld", TC) {} + Linker(const ToolChain &TC) : Tool("shave::Linker", "ld", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } void ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/lib/Driver/ToolChains/Myriad.cpp b/clang/lib/Driver/ToolChains/Myriad.cpp --- a/clang/lib/Driver/ToolChains/Myriad.cpp +++ b/clang/lib/Driver/ToolChains/Myriad.cpp @@ -77,8 +77,9 @@ std::string Exec = Args.MakeArgString(getToolChain().GetProgramPath("moviCompile")); - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Exec), - CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Args.MakeArgString(Exec), CmdArgs, + Inputs)); } void tools::SHAVE::Assembler::ConstructJob(Compilation &C, const JobAction &JA, @@ -112,8 +113,9 @@ std::string Exec = Args.MakeArgString(getToolChain().GetProgramPath("moviAsm")); - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Exec), - CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Args.MakeArgString(Exec), CmdArgs, + Inputs)); } void tools::Myriad::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -198,8 +200,9 @@ std::string Exec = Args.MakeArgString(TC.GetProgramPath("sparc-myriad-rtems-ld")); - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Exec), - CmdArgs, Inputs)); + C.addCommand( + std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), + Args.MakeArgString(Exec), CmdArgs, Inputs)); } MyriadToolChain::MyriadToolChain(const Driver &D, const llvm::Triple &Triple, diff --git a/clang/lib/Driver/ToolChains/NaCl.h b/clang/lib/Driver/ToolChains/NaCl.h --- a/clang/lib/Driver/ToolChains/NaCl.h +++ b/clang/lib/Driver/ToolChains/NaCl.h @@ -27,9 +27,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("NaCl::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("NaCl::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/NaCl.cpp b/clang/lib/Driver/ToolChains/NaCl.cpp --- a/clang/lib/Driver/ToolChains/NaCl.cpp +++ b/clang/lib/Driver/ToolChains/NaCl.cpp @@ -193,7 +193,8 @@ } const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } /// NaCl Toolchain diff --git a/clang/lib/Driver/ToolChains/NetBSD.h b/clang/lib/Driver/ToolChains/NetBSD.h --- a/clang/lib/Driver/ToolChains/NetBSD.h +++ b/clang/lib/Driver/ToolChains/NetBSD.h @@ -19,10 +19,9 @@ /// netbsd -- Directly call GNU Binutils assembler and linker namespace netbsd { -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: - Assembler(const ToolChain &TC) - : GnuTool("netbsd::Assembler", "assembler", TC) {} + Assembler(const ToolChain &TC) : Tool("netbsd::Assembler", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -32,9 +31,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("netbsd::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("netbsd::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/NetBSD.cpp b/clang/lib/Driver/ToolChains/NetBSD.cpp --- a/clang/lib/Driver/ToolChains/NetBSD.cpp +++ b/clang/lib/Driver/ToolChains/NetBSD.cpp @@ -103,7 +103,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString((getToolChain().GetProgramPath("as"))); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -337,7 +338,8 @@ ToolChain.addProfileRTLibs(Args, CmdArgs); const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } /// NetBSD - NetBSD tool chain which can call as(1) and ld(1) directly. diff --git a/clang/lib/Driver/ToolChains/OpenBSD.h b/clang/lib/Driver/ToolChains/OpenBSD.h --- a/clang/lib/Driver/ToolChains/OpenBSD.h +++ b/clang/lib/Driver/ToolChains/OpenBSD.h @@ -19,10 +19,10 @@ /// openbsd -- Directly call GNU Binutils assembler and linker namespace openbsd { -class LLVM_LIBRARY_VISIBILITY Assembler : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Assembler : public Tool { public: Assembler(const ToolChain &TC) - : GnuTool("openbsd::Assembler", "assembler", TC) {} + : Tool("openbsd::Assembler", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -32,9 +32,9 @@ const char *LinkingOutput) const override; }; -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("openbsd::Linker", "linker", TC) {} + Linker(const ToolChain &TC) : Tool("openbsd::Linker", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/OpenBSD.cpp b/clang/lib/Driver/ToolChains/OpenBSD.cpp --- a/clang/lib/Driver/ToolChains/OpenBSD.cpp +++ b/clang/lib/Driver/ToolChains/OpenBSD.cpp @@ -89,7 +89,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } void openbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -227,7 +228,8 @@ } const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Exec, CmdArgs, Inputs)); } SanitizerMask OpenBSD::getSupportedSanitizers() const { diff --git a/clang/lib/Driver/ToolChains/PS4CPU.h b/clang/lib/Driver/ToolChains/PS4CPU.h --- a/clang/lib/Driver/ToolChains/PS4CPU.h +++ b/clang/lib/Driver/ToolChains/PS4CPU.h @@ -26,8 +26,7 @@ class LLVM_LIBRARY_VISIBILITY Assemble : public Tool { public: - Assemble(const ToolChain &TC) - : Tool("PS4cpu::Assemble", "assembler", TC, RF_Full) {} + Assemble(const ToolChain &TC) : Tool("PS4cpu::Assemble", "assembler", TC) {} bool hasIntegratedCPP() const override { return false; } @@ -40,7 +39,7 @@ class LLVM_LIBRARY_VISIBILITY Link : public Tool { public: - Link(const ToolChain &TC) : Tool("PS4cpu::Link", "linker", TC, RF_Full) {} + Link(const ToolChain &TC) : Tool("PS4cpu::Link", "linker", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp --- a/clang/lib/Driver/ToolChains/PS4CPU.cpp +++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp @@ -66,7 +66,8 @@ const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("orbis-as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } static void AddPS4SanitizerArgs(const ToolChain &TC, ArgStringList &CmdArgs) { @@ -151,7 +152,8 @@ const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("orbis-ld")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileUTF8(), Exec, CmdArgs, Inputs)); } toolchains::PS4CPU::PS4CPU(const Driver &D, const llvm::Triple &Triple, diff --git a/clang/lib/Driver/ToolChains/RISCVToolchain.h b/clang/lib/Driver/ToolChains/RISCVToolchain.h --- a/clang/lib/Driver/ToolChains/RISCVToolchain.h +++ b/clang/lib/Driver/ToolChains/RISCVToolchain.h @@ -46,9 +46,9 @@ namespace tools { namespace RISCV { -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - Linker(const ToolChain &TC) : GnuTool("RISCV::Linker", "ld", TC) {} + Linker(const ToolChain &TC) : Tool("RISCV::Linker", "ld", TC) {} bool hasIntegratedCPP() const override { return false; } bool isLinkJob() const override { return true; } void ConstructJob(Compilation &C, const JobAction &JA, diff --git a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp --- a/clang/lib/Driver/ToolChains/RISCVToolchain.cpp +++ b/clang/lib/Driver/ToolChains/RISCVToolchain.cpp @@ -191,7 +191,8 @@ CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique(JA, *this, Args.MakeArgString(Linker), - CmdArgs, Inputs)); + C.addCommand( + std::make_unique(JA, *this, ResponseFileSupport::AtFileCurCP(), + Args.MakeArgString(Linker), CmdArgs, Inputs)); } // RISCV tools end. diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp --- a/clang/lib/Driver/ToolChains/Solaris.cpp +++ b/clang/lib/Driver/ToolChains/Solaris.cpp @@ -41,7 +41,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("as")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } void solaris::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -150,7 +151,8 @@ getToolChain().addProfileRTLibs(Args, CmdArgs); const char *Exec = Args.MakeArgString(getToolChain().GetLinkerPath()); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } static StringRef getSolarisLibSuffix(const llvm::Triple &Triple) { diff --git a/clang/lib/Driver/ToolChains/WebAssembly.h b/clang/lib/Driver/ToolChains/WebAssembly.h --- a/clang/lib/Driver/ToolChains/WebAssembly.h +++ b/clang/lib/Driver/ToolChains/WebAssembly.h @@ -18,10 +18,9 @@ namespace tools { namespace wasm { -class LLVM_LIBRARY_VISIBILITY Linker : public GnuTool { +class LLVM_LIBRARY_VISIBILITY Linker : public Tool { public: - explicit Linker(const ToolChain &TC) - : GnuTool("wasm::Linker", "linker", TC) {} + explicit Linker(const ToolChain &TC) : Tool("wasm::Linker", "linker", TC) {} bool isLinkJob() const override { return true; } bool hasIntegratedCPP() const override { return false; } std::string getLinkerPath(const llvm::opt::ArgList &Args) const; diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp --- a/clang/lib/Driver/ToolChains/WebAssembly.cpp +++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp @@ -108,7 +108,8 @@ CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique(JA, *this, Linker, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), Linker, CmdArgs, Inputs)); // When optimizing, if wasm-opt is available, run it. if (Arg *A = Args.getLastArg(options::OPT_O_Group)) { @@ -130,7 +131,9 @@ CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt)); CmdArgs.push_back("-o"); CmdArgs.push_back(Output.getFilename()); - C.addCommand(std::make_unique(JA, *this, WasmOpt, CmdArgs, Inputs)); + C.addCommand(std::make_unique( + JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, CmdArgs, + Inputs)); } } } diff --git a/clang/lib/Driver/ToolChains/XCore.cpp b/clang/lib/Driver/ToolChains/XCore.cpp --- a/clang/lib/Driver/ToolChains/XCore.cpp +++ b/clang/lib/Driver/ToolChains/XCore.cpp @@ -52,7 +52,8 @@ CmdArgs.push_back(II.getFilename()); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } void tools::XCore::Linker::ConstructJob(Compilation &C, const JobAction &JA, @@ -80,7 +81,8 @@ AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA); const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath("xcc")); - C.addCommand(std::make_unique(JA, *this, Exec, CmdArgs, Inputs)); + C.addCommand(std::make_unique(JA, *this, ResponseFileSupport::None(), + Exec, CmdArgs, Inputs)); } /// XCore tool chain