11#include "llvm/Support/Path.h"
12#include "llvm/Support/VirtualFileSystem.h"
21 const Driver &D,
const llvm::Triple &HostTriple,
22 const llvm::opt::ArgList &Args)
28 if (HostTriple.isWindowsMSVCEnvironment() ||
29 HostTriple.isWindowsItaniumEnvironment()) {
34 if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl,
false)) {
36 llvm::sys::path::append(LibDir,
"..",
"lib");
40 llvm::sys::path::append(SYCLLibPath,
"LLVMSYCL.lib");
42 if (D.getVFS().exists(SYCLLibPath))
43 SYCLRTLibPath = LibDir;
48 llvm::sys::path::append(LibPath,
"..",
"lib", HostTriple.str(),
53 llvm::sys::path::append(FlatLibPath,
"..",
"lib",
"libLLVMSYCL.so");
55 if (Args.hasFlag(options::OPT_fsycl, options::OPT_fno_sycl,
false)) {
57 if (D.getVFS().exists(LibPath))
58 llvm::sys::path::append(DriverDir,
"..",
"lib", HostTriple.str());
60 else if (D.getVFS().exists(FlatLibPath))
61 llvm::sys::path::append(DriverDir,
"..",
"lib");
66 SYCLRTLibPath = DriverDir;
72 const ArgList &DriverArgs, ArgStringList &CC1Args)
const {
73 if (DriverArgs.hasArg(options::OPT_nobuiltininc))
79 llvm::sys::path::append(IncludePath,
"..",
"include");
80 CC1Args.push_back(
"-internal-isystem");
81 CC1Args.push_back(DriverArgs.MakeArgString(IncludePath));
87 options::OPT_fsanitize_EQ,
88 options::OPT_fcf_protection_EQ,
89 options::OPT_fprofile_generate,
90 options::OPT_fprofile_generate_EQ,
91 options::OPT_fno_profile_generate,
92 options::OPT_ftest_coverage,
93 options::OPT_fno_test_coverage,
94 options::OPT_fcoverage_mapping,
95 options::OPT_fno_coverage_mapping,
96 options::OPT_coverage,
97 options::OPT_fprofile_instr_generate,
98 options::OPT_fprofile_instr_generate_EQ,
99 options::OPT_fno_profile_instr_generate,
100 options::OPT_fprofile_arcs,
101 options::OPT_fno_profile_arcs,
102 options::OPT_fcreate_profile,
103 options::OPT_fprofile_instr_use,
104 options::OPT_fprofile_instr_use_EQ,
105 options::OPT_fcs_profile_generate,
106 options::OPT_fcs_profile_generate_EQ,
108 return UnsupportedOpts;
112 const ToolChain &HostTC,
const ArgList &Args)
113 :
ToolChain(D, Triple, Args), HostTC(HostTC),
114 SYCLInstallation(D, Triple, Args) {
121 if (
const Arg *A = Args.getLastArg(Opt)) {
122 D.Diag(clang::diag::warn_drv_unsupported_option_for_target)
123 << A->getAsString(Args) <<
getTriple().str();
129 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
131 HostTC.addClangTargetOptions(DriverArgs, CC1Args, BA, DeviceOffloadingKind);
138 for (
const auto &BCFile :
140 CC1Args.push_back(BCFile.ShouldInternalize ?
"-mlink-builtin-bitcode"
141 :
"-mlink-bitcode-file");
142 CC1Args.push_back(DriverArgs.MakeArgStringRef(BCFile.Path));
146llvm::opt::DerivedArgList *
150 DerivedArgList *DAL = HostTC.TranslateArgs(Args, BA, DeviceOffloadKind);
152 bool IsNewDAL =
false;
154 DAL =
new DerivedArgList(Args.getBaseArgs());
158 for (Arg *A : Args) {
161 auto Opt(A->getOption());
162 bool Unsupported =
false;
164 if (Opt.matches(UnsupportedOpt)) {
165 if (Opt.getID() == options::OPT_fsanitize_EQ &&
166 A->getValues().size() == 1) {
167 std::string SanitizeVal = A->getValue();
168 if (SanitizeVal ==
"address") {
175 DAL->eraseArg(Opt.getID());
187 DAL->eraseArg(options::OPT_march_EQ);
188 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ),
195 HostTC.addClangWarningOptions(CC1Args);
205 return HostTC.GetCXXStdlibType(Args);
209 ArgStringList &CC1Args)
const {
210 SYCLInstallation.addSYCLIncludeArgs(DriverArgs, CC1Args);
214 ArgStringList &CC1Args)
const {
215 HostTC.AddClangSystemIncludeArgs(DriverArgs, CC1Args);
219 ArgStringList &CC1Args)
const {
220 HostTC.AddClangCXXStdlibIncludeArgs(Args, CC1Args);
224 const ArgList &Args)
const {
225 return HostTC.computeMSVCVersion(D, Args);
230 const llvm::opt::ArgList &DriverArgs,
BoundArch ,
234 if (!DriverArgs.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib,
240 llvm::sys::path::append(BCPath,
"libclang_rt.builtins.bc");
241 if (
getVFS().exists(BCPath))
242 return {{std::string(BCPath),
true}};
247 llvm::sys::path::append(BCPath,
"libclang_rt.builtins-spirv64.bc");
248 if (
getVFS().exists(BCPath))
249 return {{std::string(BCPath),
true}};
static ArrayRef< options::ID > getUnsupportedOpts()
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
const llvm::opt::OptTable & getOpts() const
SYCLInstallationDetector(const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args)
void addSYCLIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Top level wrappers for InstallAPI frontend operations.
Represents a bound architecture for offload / multiple architecture compilation.