13#include "llvm/Option/ArgList.h"
14#include "llvm/Support/FileSystem.h"
15#include "llvm/Support/VirtualFileSystem.h"
16#include "llvm/Support/WithColor.h"
24using namespace llvm::sys;
32 ArgStringList &CC1Args,
36 if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation,
37 options::OPT_fno_aligned_allocation))
38 CC1Args.push_back(
"-faligned-alloc-unavailable");
40 if (DriverArgs.hasFlag(options::OPT_fxl_pragma_pack,
41 options::OPT_fno_xl_pragma_pack,
true))
42 CC1Args.push_back(
"-fxl-pragma-pack");
46 if (!DriverArgs.hasArgNoClaim(options::OPT_fsized_deallocation,
47 options::OPT_fno_sized_deallocation))
48 CC1Args.push_back(
"-fno-sized-deallocation");
55 const char *LinkingOutput)
const {
56 ArgStringList CmdArgs;
58 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
63 CmdArgs.push_back(
"-o");
70 if (Inputs.size() != 1)
71 llvm_unreachable(
"Invalid number of input files.");
77 const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(
"as"));
79 Exec, CmdArgs, Inputs));
82static std::string
getLEHLQ(
const ArgList &Args) {
83 if (Args.hasArg(options::OPT_mzos_hlq_le_EQ)) {
84 Arg *LEHLQArg = Args.getLastArg(options::OPT_mzos_hlq_le_EQ);
85 StringRef HLQ = LEHLQArg->getValue();
93 if (Args.hasArg(options::OPT_mzos_hlq_clang_EQ)) {
94 Arg *ClangHLQArg = Args.getLastArg(options::OPT_mzos_hlq_clang_EQ);
95 StringRef HLQ = ClangHLQArg->getValue();
103 if (Args.hasArg(options::OPT_mzos_hlq_csslib_EQ)) {
104 Arg *CsslibHLQArg = Args.getLastArg(options::OPT_mzos_hlq_csslib_EQ);
105 StringRef HLQ = CsslibHLQArg->getValue();
115 const char *LinkingOutput)
const {
117 ArgStringList CmdArgs;
119 const bool IsSharedLib =
120 Args.hasFlag(options::OPT_shared, options::OPT_static,
false);
124 CmdArgs.push_back(
"-o");
129 LinkerOptions =
"AMODE=";
130 LinkerOptions +=
"64";
131 LinkerOptions +=
",LIST";
132 LinkerOptions +=
",DYNAM=DLL";
133 LinkerOptions +=
",MSGLEVEL=4";
134 LinkerOptions +=
",CASE=MIXED";
135 LinkerOptions +=
",REUS=RENT";
137 CmdArgs.push_back(
"-b");
138 CmdArgs.push_back(Args.MakeArgString(LinkerOptions));
141 CmdArgs.push_back(
"-e");
142 CmdArgs.push_back(
"CELQSTRT");
144 CmdArgs.push_back(
"-O");
145 CmdArgs.push_back(
"CELQSTRT");
147 CmdArgs.push_back(
"-u");
148 CmdArgs.push_back(
"CELQMAIN");
156 size_t Suffix = OutputName.find_last_of(
'.');
157 const char *SideDeckName =
158 Args.MakeArgString(OutputName.substr(0, Suffix) +
".x");
159 CmdArgs.push_back(
"-x");
160 CmdArgs.push_back(SideDeckName);
165 CmdArgs.push_back(
"-x");
166 CmdArgs.push_back(
"/dev/null");
170 Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
184 StringRef ld_env_var = StringRef(getenv(
"_LD_SYSLIB")).trim();
185 if (ld_env_var.empty()) {
186 CmdArgs.push_back(
"-S");
187 CmdArgs.push_back(Args.MakeArgString(
"//'" + LEHLQ +
".SCEEBND2'"));
188 CmdArgs.push_back(
"-S");
189 CmdArgs.push_back(Args.MakeArgString(
"//'" + CsslibHLQ +
".CSSLIB'"));
192 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
193 ld_env_var = StringRef(getenv(
"_LD_SIDE_DECKS")).trim();
194 if (ld_env_var.empty()) {
196 Args.MakeArgString(
"//'" + LEHLQ +
".SCEELIB(CELQS001)'"));
198 Args.MakeArgString(
"//'" + LEHLQ +
".SCEELIB(CELQS003)'"));
201 ld_env_var.split(ld_side_deck,
":");
202 for (StringRef ld_loc : ld_side_deck) {
203 CmdArgs.push_back((ld_loc.str()).c_str());
213 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
218 Exec, CmdArgs, Inputs));
230 llvm::opt::ArgStringList &CmdArgs)
const {
233 llvm::report_fatal_error(
"linking libstdc++ is unimplemented on z/OS");
238 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXE)'"));
240 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXS)'"));
242 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXP)'"));
244 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXA)'"));
246 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQXLA)'"));
248 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQUNW)'"));
258 ArgStringList &CC1Args)
const {
259 if (DriverArgs.hasArg(options::OPT_nostdinc))
265 std::string ResourceDir(
D.ResourceDir);
270 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
272 path::append(
P,
"include",
"zos_wrappers");
277 path::append(P2,
"include");
282 if (Arg *SysIncludeArg =
283 DriverArgs.getLastArg(options::OPT_mzos_sys_include_EQ)) {
284 StringRef SysInclude = SysIncludeArg->getValue();
287 if (!SysInclude.empty()) {
291 StringRef PathLE(SysInclude);
292 size_t Colon = PathLE.find(
':');
293 if (Colon == StringRef::npos) {
298 while (Colon != StringRef::npos) {
301 PathLE = PathLE.substr(Colon + 1);
302 Colon = PathLE.find(
':');
315 const llvm::opt::ArgList &DriverArgs,
316 llvm::opt::ArgStringList &CC1Args)
const {
318 if (DriverArgs.hasArg(options::OPT_v))
319 WithColor::warning(errs(),
"Clang")
320 <<
"ignoring nonexistent directory \"" <<
Path <<
"\"\n";
321 if (!DriverArgs.hasArg(options::OPT__HASH_HASH_HASH))
328 const llvm::opt::ArgList &DriverArgs,
329 llvm::opt::ArgStringList &CC1Args)
const {
330 if (DriverArgs.hasArg(options::OPT_nostdinc) ||
331 DriverArgs.hasArg(options::OPT_nostdincxx) ||
332 DriverArgs.hasArg(options::OPT_nostdlibinc))
339 llvm::sys::path::append(InstallBin,
"..",
"include",
"c++",
"v1");
344 llvm::report_fatal_error(
345 "picking up libstdc++ headers is unimplemented on z/OS");
static std::string getClangHLQ(const ArgList &Args)
static std::string getLEHLQ(const ArgList &Args)
static std::string getCSSHLQ(const ArgList &Args)
Compilation - A set of tasks to perform for a single driver invocation.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
static constexpr ResponseFileSupport None()
Returns a ResponseFileSupport indicating that response files are not supported.