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");
42 if (!DriverArgs.hasArgNoClaim(options::OPT_fsized_deallocation,
43 options::OPT_fno_sized_deallocation))
44 CC1Args.push_back(
"-fno-sized-deallocation");
51 const char *LinkingOutput)
const {
52 ArgStringList CmdArgs;
54 Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);
59 CmdArgs.push_back(
"-o");
66 if (Inputs.size() != 1)
67 llvm_unreachable(
"Invalid number of input files.");
73 const char *Exec = Args.MakeArgString(getToolChain().GetProgramPath(
"as"));
75 Exec, CmdArgs, Inputs));
78static std::string
getLEHLQ(
const ArgList &Args) {
79 if (Args.hasArg(options::OPT_mzos_hlq_le_EQ)) {
80 Arg *LEHLQArg = Args.getLastArg(options::OPT_mzos_hlq_le_EQ);
81 StringRef HLQ = LEHLQArg->getValue();
89 if (Args.hasArg(options::OPT_mzos_hlq_clang_EQ)) {
90 Arg *ClangHLQArg = Args.getLastArg(options::OPT_mzos_hlq_clang_EQ);
91 StringRef HLQ = ClangHLQArg->getValue();
99 if (Args.hasArg(options::OPT_mzos_hlq_csslib_EQ)) {
100 Arg *CsslibHLQArg = Args.getLastArg(options::OPT_mzos_hlq_csslib_EQ);
101 StringRef HLQ = CsslibHLQArg->getValue();
111 const char *LinkingOutput)
const {
113 ArgStringList CmdArgs;
115 const bool IsSharedLib =
116 Args.hasFlag(options::OPT_shared, options::OPT_static,
false);
120 CmdArgs.push_back(
"-o");
125 LinkerOptions =
"AMODE=";
126 LinkerOptions +=
"64";
127 LinkerOptions +=
",LIST";
128 LinkerOptions +=
",DYNAM=DLL";
129 LinkerOptions +=
",MSGLEVEL=4";
130 LinkerOptions +=
",CASE=MIXED";
131 LinkerOptions +=
",REUS=RENT";
133 CmdArgs.push_back(
"-b");
134 CmdArgs.push_back(Args.MakeArgString(LinkerOptions));
137 CmdArgs.push_back(
"-e");
138 CmdArgs.push_back(
"CELQSTRT");
140 CmdArgs.push_back(
"-O");
141 CmdArgs.push_back(
"CELQSTRT");
143 CmdArgs.push_back(
"-u");
144 CmdArgs.push_back(
"CELQMAIN");
152 size_t Suffix = OutputName.find_last_of(
'.');
153 const char *SideDeckName =
154 Args.MakeArgString(OutputName.substr(0, Suffix) +
".x");
155 CmdArgs.push_back(
"-x");
156 CmdArgs.push_back(SideDeckName);
161 CmdArgs.push_back(
"-x");
162 CmdArgs.push_back(
"/dev/null");
166 Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_u});
180 StringRef ld_env_var = StringRef(getenv(
"_LD_SYSLIB")).trim();
181 if (ld_env_var.empty()) {
182 CmdArgs.push_back(
"-S");
183 CmdArgs.push_back(Args.MakeArgString(
"//'" + LEHLQ +
".SCEEBND2'"));
184 CmdArgs.push_back(
"-S");
185 CmdArgs.push_back(Args.MakeArgString(
"//'" + CsslibHLQ +
".CSSLIB'"));
188 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
189 ld_env_var = StringRef(getenv(
"_LD_SIDE_DECKS")).trim();
190 if (ld_env_var.empty()) {
192 Args.MakeArgString(
"//'" + LEHLQ +
".SCEELIB(CELQS001)'"));
194 Args.MakeArgString(
"//'" + LEHLQ +
".SCEELIB(CELQS003)'"));
197 ld_env_var.split(ld_side_deck,
":");
198 for (StringRef ld_loc : ld_side_deck) {
199 CmdArgs.push_back((ld_loc.str()).c_str());
209 if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
214 Exec, CmdArgs, Inputs));
226 llvm::opt::ArgStringList &CmdArgs)
const {
229 llvm::report_fatal_error(
"linking libstdc++ is unimplemented on z/OS");
234 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXE)'"));
236 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXS)'"));
238 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXP)'"));
240 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQCXA)'"));
242 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQXLA)'"));
244 Args.MakeArgString(
"//'" + ClangHLQ +
".SCEELIB(CRTDQUNW)'"));
254 ArgStringList &CC1Args)
const {
255 if (DriverArgs.hasArg(options::OPT_nostdinc))
261 std::string ResourceDir(
D.ResourceDir);
266 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
268 path::append(
P,
"include",
"zos_wrappers");
273 path::append(P2,
"include");
278 if (Arg *SysIncludeArg =
279 DriverArgs.getLastArg(options::OPT_mzos_sys_include_EQ)) {
280 StringRef SysInclude = SysIncludeArg->getValue();
283 if (!SysInclude.empty()) {
287 StringRef PathLE(SysInclude);
288 size_t Colon = PathLE.find(
':');
289 if (Colon == StringRef::npos) {
294 while (Colon != StringRef::npos) {
297 PathLE = PathLE.substr(Colon + 1);
298 Colon = PathLE.find(
':');
311 const llvm::opt::ArgList &DriverArgs,
312 llvm::opt::ArgStringList &CC1Args)
const {
314 if (DriverArgs.hasArg(options::OPT_v))
315 WithColor::warning(errs(),
"Clang")
316 <<
"ignoring nonexistent directory \"" <<
Path <<
"\"\n";
317 if (!DriverArgs.hasArg(options::OPT__HASH_HASH_HASH))
324 const llvm::opt::ArgList &DriverArgs,
325 llvm::opt::ArgStringList &CC1Args)
const {
326 if (DriverArgs.hasArg(options::OPT_nostdinc) ||
327 DriverArgs.hasArg(options::OPT_nostdincxx) ||
328 DriverArgs.hasArg(options::OPT_nostdlibinc))
335 llvm::sys::path::append(InstallBin,
"..",
"include",
"c++",
"v1");
340 llvm::report_fatal_error(
341 "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.