12#include "clang/Config/config.h"
19#include "llvm/ADT/StringExtras.h"
20#include "llvm/Option/ArgList.h"
21#include "llvm/Support/FileSystem.h"
22#include "llvm/Support/FormatAdapters.h"
23#include "llvm/Support/FormatVariadic.h"
24#include "llvm/Support/Path.h"
25#include "llvm/Support/Process.h"
26#include "llvm/Support/Program.h"
27#include "llvm/Support/VirtualFileSystem.h"
28#include "llvm/TargetParser/Host.h"
29#include "llvm/TargetParser/TargetParser.h"
30#include <system_error>
41 if (raw_version < 7050)
42 return CudaVersion::CUDA_70;
43 if (raw_version < 8000)
44 return CudaVersion::CUDA_75;
45 if (raw_version < 9000)
46 return CudaVersion::CUDA_80;
47 if (raw_version < 9010)
48 return CudaVersion::CUDA_90;
49 if (raw_version < 9020)
50 return CudaVersion::CUDA_91;
51 if (raw_version < 10000)
52 return CudaVersion::CUDA_92;
53 if (raw_version < 10010)
54 return CudaVersion::CUDA_100;
55 if (raw_version < 10020)
56 return CudaVersion::CUDA_101;
57 if (raw_version < 11000)
58 return CudaVersion::CUDA_102;
59 if (raw_version < 11010)
60 return CudaVersion::CUDA_110;
61 if (raw_version < 11020)
62 return CudaVersion::CUDA_111;
63 if (raw_version < 11030)
64 return CudaVersion::CUDA_112;
65 if (raw_version < 11040)
66 return CudaVersion::CUDA_113;
67 if (raw_version < 11050)
68 return CudaVersion::CUDA_114;
69 if (raw_version < 11060)
70 return CudaVersion::CUDA_115;
71 if (raw_version < 11070)
72 return CudaVersion::CUDA_116;
73 if (raw_version < 11080)
74 return CudaVersion::CUDA_117;
75 if (raw_version < 11090)
76 return CudaVersion::CUDA_118;
77 if (raw_version < 12010)
78 return CudaVersion::CUDA_120;
79 if (raw_version < 12020)
80 return CudaVersion::CUDA_121;
81 if (raw_version < 12030)
82 return CudaVersion::CUDA_122;
83 if (raw_version < 12040)
84 return CudaVersion::CUDA_123;
85 if (raw_version < 12050)
86 return CudaVersion::CUDA_124;
87 if (raw_version < 12060)
88 return CudaVersion::CUDA_125;
89 return CudaVersion::NEW;
95 auto StartsWithWords =
96 [](llvm::StringRef Line,
98 for (StringRef word : words) {
99 if (!Line.consume_front(word))
106 Input = Input.ltrim();
107 while (!Input.empty()) {
109 StartsWithWords(Input.ltrim(), {
"#",
"define",
"CUDA_VERSION"})) {
111 Line->consumeInteger(10, RawVersion);
112 return getCudaVersion(RawVersion);
115 Input = Input.drop_front(Input.find_first_of(
"\n\r")).ltrim();
117 return CudaVersion::UNKNOWN;
124 if (!VersionString.empty())
125 VersionString.insert(0,
" ");
126 D.
Diag(diag::warn_drv_new_cuda_version)
131 D.
Diag(diag::warn_drv_partially_supported_cuda_version)
136 const Driver &
D,
const llvm::Triple &HostTriple,
137 const llvm::opt::ArgList &Args)
143 Candidate(std::string
Path,
bool StrictChecking =
false)
144 :
Path(
Path), StrictChecking(StrictChecking) {}
149 std::initializer_list<const char *> Versions = {
"8.0",
"7.5",
"7.0"};
150 auto &FS =
D.getVFS();
152 if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
153 Candidates.emplace_back(
154 Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str());
155 }
else if (HostTriple.isOSWindows()) {
156 for (
const char *Ver : Versions)
157 Candidates.emplace_back(
158 D.SysRoot +
"/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v" +
161 if (!Args.hasArg(clang::driver::options::OPT_cuda_path_ignore_env)) {
170 if (llvm::ErrorOr<std::string> ptxas =
171 llvm::sys::findProgramByName(
"ptxas")) {
173 llvm::sys::fs::real_path(*ptxas, ptxasAbsolutePath);
175 StringRef ptxasDir = llvm::sys::path::parent_path(ptxasAbsolutePath);
176 if (llvm::sys::path::filename(ptxasDir) ==
"bin")
177 Candidates.emplace_back(
178 std::string(llvm::sys::path::parent_path(ptxasDir)),
183 Candidates.emplace_back(
D.SysRoot +
"/usr/local/cuda");
184 for (
const char *Ver : Versions)
185 Candidates.emplace_back(
D.SysRoot +
"/usr/local/cuda-" + Ver);
187 Distro Dist(FS, llvm::Triple(llvm::sys::getProcessTriple()));
191 Candidates.emplace_back(
D.SysRoot +
"/usr/lib/cuda");
194 bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
196 for (
const auto &Candidate : Candidates) {
197 InstallPath = Candidate.Path;
198 if (InstallPath.empty() || !FS.exists(InstallPath))
201 BinPath = InstallPath +
"/bin";
202 IncludePath = InstallPath +
"/include";
203 LibDevicePath = InstallPath +
"/nvvm/libdevice";
205 if (!(FS.exists(IncludePath) && FS.exists(BinPath)))
207 bool CheckLibDevice = (!NoCudaLib || Candidate.StrictChecking);
208 if (CheckLibDevice && !FS.exists(LibDevicePath))
212 if (
auto CudaHFile = FS.getBufferForFile(InstallPath +
"/include/cuda.h"))
213 Version = parseCudaHFile((*CudaHFile)->getBuffer());
217 Version = FS.exists(LibDevicePath +
"/libdevice.10.bc")
224 std::string FilePath = LibDevicePath +
"/libdevice.10.bc";
225 if (FS.exists(FilePath)) {
232 LibDeviceMap[OffloadArchName] = FilePath;
237 for (llvm::vfs::directory_iterator LI = FS.dir_begin(LibDevicePath, EC),
239 !EC && LI != LE; LI = LI.increment(EC)) {
240 StringRef FilePath = LI->path();
241 StringRef
FileName = llvm::sys::path::filename(FilePath);
244 const StringRef LibDeviceName =
"libdevice.";
248 LibDeviceName.size(),
FileName.find(
'.', LibDeviceName.size()));
249 LibDeviceMap[GpuArch] = FilePath.str();
253 if (GpuArch ==
"compute_20") {
254 LibDeviceMap[
"sm_20"] = std::string(FilePath);
255 LibDeviceMap[
"sm_21"] = std::string(FilePath);
256 LibDeviceMap[
"sm_32"] = std::string(FilePath);
257 }
else if (GpuArch ==
"compute_30") {
258 LibDeviceMap[
"sm_30"] = std::string(FilePath);
260 LibDeviceMap[
"sm_50"] = std::string(FilePath);
261 LibDeviceMap[
"sm_52"] = std::string(FilePath);
262 LibDeviceMap[
"sm_53"] = std::string(FilePath);
264 LibDeviceMap[
"sm_60"] = std::string(FilePath);
265 LibDeviceMap[
"sm_61"] = std::string(FilePath);
266 LibDeviceMap[
"sm_62"] = std::string(FilePath);
267 }
else if (GpuArch ==
"compute_35") {
268 LibDeviceMap[
"sm_35"] = std::string(FilePath);
269 LibDeviceMap[
"sm_37"] = std::string(FilePath);
270 }
else if (GpuArch ==
"compute_50") {
272 LibDeviceMap[
"sm_50"] = std::string(FilePath);
273 LibDeviceMap[
"sm_52"] = std::string(FilePath);
274 LibDeviceMap[
"sm_53"] = std::string(FilePath);
282 if (LibDeviceMap.empty() && !NoCudaLib)
291 const ArgList &DriverArgs, ArgStringList &CC1Args)
const {
292 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
296 llvm::sys::path::append(
P,
"include");
297 llvm::sys::path::append(
P,
"cuda_wrappers");
298 CC1Args.push_back(
"-internal-isystem");
299 CC1Args.push_back(DriverArgs.MakeArgString(
P));
302 if (DriverArgs.hasArg(options::OPT_nogpuinc))
306 D.
Diag(diag::err_drv_no_cuda_installation);
310 CC1Args.push_back(
"-include");
311 CC1Args.push_back(
"__clang_cuda_runtime_wrapper.h");
317 ArchsWithBadVersion[(
int)Arch])
322 if (Version < MinVersion || Version > MaxVersion) {
323 ArchsWithBadVersion[(
int)Arch] =
true;
324 D.
Diag(diag::err_drv_cuda_version_unsupported)
333 OS <<
"Found CUDA installation: " << InstallPath <<
", version "
343enum DeviceDebugInfoLevel {
346 EmitSameDebugInfoAsHost,
360 const Arg *A = Args.getLastArg(options::OPT_O_Group);
361 bool IsDebugEnabled = !A || A->getOption().matches(options::OPT_O0) ||
362 Args.hasFlag(options::OPT_cuda_noopt_device_debug,
363 options::OPT_no_cuda_noopt_device_debug,
365 if (
const Arg *A = Args.getLastArg(options::OPT_g_Group)) {
366 const Option &Opt = A->getOption();
367 if (Opt.matches(options::OPT_gN_Group)) {
368 if (Opt.matches(options::OPT_g0) || Opt.matches(options::OPT_ggdb0))
369 return DisableDebugInfo;
370 if (Opt.matches(options::OPT_gline_directives_only))
371 return DebugDirectivesOnly;
373 return IsDebugEnabled ? EmitSameDebugInfoAsHost : DebugDirectivesOnly;
382 const char *LinkingOutput)
const {
385 assert(TC.getTriple().isNVPTX() &&
"Wrong platform");
387 StringRef GPUArchName;
395 GPUArchName = Args.getLastArgValue(options::OPT_march_EQ);
396 if (GPUArchName.empty()) {
397 C.getDriver().Diag(diag::err_drv_offload_missing_gpu_arch)
398 << getToolChain().getArchName() << getShortName();
406 "Device action expected to have an architecture.");
409 if (!Args.hasArg(options::OPT_no_cuda_version_check)) {
410 TC.CudaInstallation.CheckCudaVersionSupportsArch(gpu_arch);
413 ArgStringList CmdArgs;
414 CmdArgs.push_back(TC.getTriple().isArch64Bit() ?
"-m64" :
"-m32");
416 if (DIKind == EmitSameDebugInfoAsHost) {
419 CmdArgs.push_back(
"-g");
420 CmdArgs.push_back(
"--dont-merge-basicblocks");
421 CmdArgs.push_back(
"--return-at-end");
422 }
else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
430 StringRef OOpt =
"3";
431 if (A->getOption().matches(options::OPT_O4) ||
432 A->getOption().matches(options::OPT_Ofast))
434 else if (A->getOption().matches(options::OPT_O0))
436 else if (A->getOption().matches(options::OPT_O)) {
438 OOpt = llvm::StringSwitch<const char *>(A->getValue())
446 CmdArgs.push_back(Args.MakeArgString(llvm::Twine(
"-O") + OOpt));
450 CmdArgs.push_back(
"-O0");
452 if (DIKind == DebugDirectivesOnly)
453 CmdArgs.push_back(
"-lineinfo");
456 if (Args.hasArg(options::OPT_v))
457 CmdArgs.push_back(
"-v");
459 CmdArgs.push_back(
"--gpu-name");
461 CmdArgs.push_back(
"--output-file");
462 std::string OutputFileName = TC.getInputFilename(Output);
465 C.addTempFile(Args.MakeArgString(OutputFileName));
467 CmdArgs.push_back(Args.MakeArgString(OutputFileName));
468 for (
const auto &II : Inputs)
469 CmdArgs.push_back(Args.MakeArgString(II.getFilename()));
471 for (
const auto &A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
472 CmdArgs.push_back(Args.MakeArgString(A));
477 Relocatable = Args.hasFlag(options::OPT_fopenmp_relocatable_target,
478 options::OPT_fnoopenmp_relocatable_target,
482 Relocatable = Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
489 CmdArgs.push_back(
"-c");
492 if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
493 Exec = A->getValue();
495 Exec = Args.MakeArgString(TC.GetProgramPath(
"ptxas"));
496 C.addCommand(std::make_unique<Command>(
500 Exec, CmdArgs, Inputs, Output));
505 bool includePTX = !Args.hasFlag(options::OPT_offload_new_driver,
506 options::OPT_no_offload_new_driver,
false);
507 for (Arg *A : Args.filtered(options::OPT_cuda_include_ptx_EQ,
508 options::OPT_no_cuda_include_ptx_EQ)) {
510 const StringRef ArchStr = A->getValue();
511 if (A->getOption().matches(options::OPT_cuda_include_ptx_EQ) &&
512 (ArchStr ==
"all" || ArchStr == InputArch))
514 else if (A->getOption().matches(options::OPT_no_cuda_include_ptx_EQ) &&
515 (ArchStr ==
"all" || ArchStr == InputArch))
528 const char *LinkingOutput)
const {
531 assert(TC.getTriple().isNVPTX() &&
"Wrong platform");
533 ArgStringList CmdArgs;
535 CmdArgs.push_back(
"--cuda");
536 CmdArgs.push_back(TC.getTriple().isArch64Bit() ?
"-64" :
"-32");
537 CmdArgs.push_back(Args.MakeArgString(
"--create"));
538 CmdArgs.push_back(Args.MakeArgString(Output.
getFilename()));
540 CmdArgs.push_back(
"-g");
542 for (
const auto &II : Inputs) {
543 auto *A = II.getAction();
544 assert(A->getInputs().size() == 1 &&
545 "Device offload action is expected to have a single input");
546 const char *gpu_arch_str = A->getOffloadingArch();
547 assert(gpu_arch_str &&
548 "Device action expected to have associated a GPU architecture!");
551 if (II.getType() == types::TY_PP_Asm &&
556 const char *Arch = (II.getType() == types::TY_PP_Asm)
560 Args.MakeArgString(llvm::Twine(
"--image=profile=") + Arch +
561 ",file=" + getToolChain().getInputFilename(II)));
564 for (
const auto &A : Args.getAllArgValues(options::OPT_Xcuda_fatbinary))
565 CmdArgs.push_back(Args.MakeArgString(A));
567 const char *Exec = Args.MakeArgString(TC.GetProgramPath(
"fatbinary"));
568 C.addCommand(std::make_unique<Command>(
572 Exec, CmdArgs, Inputs, Output));
579 const char *LinkingOutput)
const {
582 ArgStringList CmdArgs;
584 assert(TC.getTriple().isNVPTX() &&
"Wrong platform");
588 CmdArgs.push_back(
"-o");
593 CmdArgs.push_back(
"-g");
595 if (Args.hasArg(options::OPT_v))
596 CmdArgs.push_back(
"-v");
598 StringRef GPUArch = Args.getLastArgValue(options::OPT_march_EQ);
599 if (GPUArch.empty() && !
C.getDriver().isUsingLTO()) {
600 C.getDriver().Diag(diag::err_drv_offload_missing_gpu_arch)
601 << getToolChain().getArchName() << getShortName();
605 if (!GPUArch.empty()) {
606 CmdArgs.push_back(
"-arch");
607 CmdArgs.push_back(Args.MakeArgString(GPUArch));
610 if (Args.hasArg(options::OPT_ptxas_path_EQ))
611 CmdArgs.push_back(Args.MakeArgString(
612 "--pxtas-path=" + Args.getLastArgValue(options::OPT_ptxas_path_EQ)));
614 if (Args.hasArg(options::OPT_cuda_path_EQ))
615 CmdArgs.push_back(Args.MakeArgString(
616 "--cuda-path=" + Args.getLastArgValue(options::OPT_cuda_path_EQ)));
622 Args.AddAllArgs(CmdArgs, options::OPT_L);
623 getToolChain().AddFilePathLibArgs(Args, CmdArgs);
626 if (
C.getDriver().isUsingLTO())
627 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
631 std::vector<StringRef> Features;
634 for (StringRef Feature : Features)
635 CmdArgs.append({
"--feature", Args.MakeArgString(Feature)});
641 llvm::sys::path::parent_path(TC.getDriver().Dir);
642 llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
643 CmdArgs.push_back(Args.MakeArgString(Twine(
"-L") + DefaultLibPath));
645 C.addCommand(std::make_unique<Command>(
649 Args.MakeArgString(getToolChain().GetProgramPath(
"clang-nvlink-wrapper")),
650 CmdArgs, Inputs, Output));
654 const llvm::opt::ArgList &Args,
655 std::vector<StringRef> &Features) {
656 if (Args.hasArg(options::OPT_cuda_feature_EQ)) {
657 StringRef PtxFeature =
658 Args.getLastArgValue(options::OPT_cuda_feature_EQ,
"+ptx42");
659 Features.push_back(Args.MakeArgString(PtxFeature));
667 const char *PtxFeature =
nullptr;
668 switch (CudaInstallation.
version()) {
669#define CASE_CUDA_VERSION(CUDA_VER, PTX_VER) \
670 case CudaVersion::CUDA_##CUDA_VER: \
671 PtxFeature = "+ptx" #PTX_VER; \
694#undef CASE_CUDA_VERSION
696 PtxFeature =
"+ptx42";
698 Features.push_back(PtxFeature);
705 const llvm::Triple &HostTriple,
706 const ArgList &Args,
bool Freestanding =
false)
707 :
ToolChain(
D, Triple, Args), CudaInstallation(
D, HostTriple, Args),
708 Freestanding(Freestanding) {
709 if (CudaInstallation.isValid())
710 getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
713 getProgramPaths().push_back(getDriver().Dir);
723llvm::opt::DerivedArgList *
729 DAL =
new DerivedArgList(Args.getBaseArgs());
731 const OptTable &Opts = getDriver().getOpts();
734 if (!llvm::is_contained(*DAL, A))
737 if (!DAL->hasArg(options::OPT_march_EQ) && OffloadKind !=
Action::OFK_None) {
738 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ),
740 }
else if (DAL->getLastArgValue(options::OPT_march_EQ) ==
"generic" &&
742 DAL->eraseArg(options::OPT_march_EQ);
743 }
else if (DAL->getLastArgValue(options::OPT_march_EQ) ==
"native") {
744 auto GPUsOrErr = getSystemGPUArchs(Args);
746 getDriver().Diag(diag::err_drv_undetermined_gpu_arch)
747 << getArchName() << llvm::toString(GPUsOrErr.takeError()) <<
"-march";
749 if (GPUsOrErr->size() > 1)
750 getDriver().Diag(diag::warn_drv_multi_gpu_arch)
751 << getArchName() << llvm::join(*GPUsOrErr,
", ") <<
"-march";
752 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ),
753 Args.MakeArgString(GPUsOrErr->front()));
761 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
767 CC1Args.append({
"-mllvm",
"--nvptx-lower-global-ctor-dtor"});
771 const Option &O = A->getOption();
772 return (O.matches(options::OPT_gN_Group) &&
773 !O.matches(options::OPT_gmodules)) ||
774 O.matches(options::OPT_g_Flag) ||
775 O.matches(options::OPT_ggdbN_Group) || O.matches(options::OPT_ggdb) ||
776 O.matches(options::OPT_gdwarf) || O.matches(options::OPT_gdwarf_2) ||
777 O.matches(options::OPT_gdwarf_3) || O.matches(options::OPT_gdwarf_4) ||
778 O.matches(options::OPT_gdwarf_5) ||
779 O.matches(options::OPT_gcolumn_info);
783 llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
784 const ArgList &Args)
const {
786 case DisableDebugInfo:
787 DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
789 case DebugDirectivesOnly:
790 DebugInfoKind = llvm::codegenoptions::DebugDirectivesOnly;
792 case EmitSameDebugInfoAsHost:
802 if (Arg *A = Args.getLastArg(options::OPT_nvptx_arch_tool_EQ))
803 Program = A->getValue();
805 Program = GetProgramPath(
"nvptx-arch");
807 auto StdoutOrErr = executeToolChainProgram(Program);
809 return StdoutOrErr.takeError();
812 for (StringRef Arch : llvm::split((*StdoutOrErr)->getBuffer(),
"\n"))
814 GPUArchs.push_back(Arch.str());
816 if (GPUArchs.empty())
817 return llvm::createStringError(std::error_code(),
818 "No NVIDIA GPU detected in the system");
820 return std::move(GPUArchs);
828 const ToolChain &HostTC,
const ArgList &Args)
829 :
NVPTXToolChain(
D, Triple, HostTC.getTriple(), Args), HostTC(HostTC) {}
832 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
836 StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
837 assert(!GpuArch.empty() &&
"Must have an explicit GPU arch.");
840 "Only OpenMP or CUDA offloading kinds are supported for NVIDIA GPUs.");
843 {
"-fcuda-is-device",
"-mllvm",
"-enable-memcpyopt-without-libcalls"});
850 CC1Args.push_back(
"-fcuda-allow-variadic-functions");
852 if (DriverArgs.hasArg(options::OPT_nogpulib))
856 DriverArgs.hasArg(options::OPT_S))
860 if (LibDeviceFile.empty()) {
861 getDriver().
Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
865 CC1Args.push_back(
"-mlink-builtin-bitcode");
866 CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
871 if (DriverArgs.hasFlag(options::OPT_foffload_via_llvm,
872 options::OPT_fno_offload_via_llvm,
false))
877 if (DriverArgs.hasFlag(options::OPT_fcuda_short_ptr,
878 options::OPT_fno_cuda_short_ptr,
false))
879 CC1Args.append({
"-mllvm",
"--nvptx-short-ptr"});
883 DriverArgs.MakeArgString(Twine(
"-target-sdk-version=") +
889 diag::err_drv_omp_offload_target_cuda_version_not_support)
904 const llvm::opt::ArgList &DriverArgs,
const JobAction &JA,
905 const llvm::fltSemantics *FPType)
const {
907 if (FPType && FPType == &llvm::APFloat::IEEEsingle() &&
908 DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
909 options::OPT_fno_gpu_flush_denormals_to_zero,
false))
910 return llvm::DenormalMode::getPreserveSign();
914 return llvm::DenormalMode::getIEEE();
918 ArgStringList &CC1Args)
const {
920 if (!DriverArgs.hasArg(options::OPT_nogpuinc) &&
921 !DriverArgs.hasArg(options::OPT_no_cuda_version_check)) {
922 StringRef Arch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
923 assert(!Arch.empty() &&
"Must have an explicit GPU arch.");
938llvm::opt::DerivedArgList *
942 DerivedArgList *DAL =
945 DAL =
new DerivedArgList(Args.getBaseArgs());
954 if (!llvm::is_contained(*DAL, A))
957 if (!DAL->hasArg(options::OPT_march_EQ)) {
958 StringRef Arch = BoundArch;
963 llvm::formatv(
"{0}", llvm::fmt_consume(ArchsOrErr.takeError()));
965 << llvm::Triple::getArchTypeName(
getArch()) << ErrMsg <<
"-march";
968 Arch = Args.MakeArgString(ArchsOrErr->front());
971 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ), Arch);
977 for (Arg *A : Args) {
979 if (!llvm::is_contained(*DAL, A)) {
984 if (!BoundArch.empty()) {
985 DAL->eraseArg(options::OPT_march_EQ);
986 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ),
1018 ArgStringList &CC1Args)
const {
1023 {
"-internal-isystem",
1028 ArgStringList &CC1Args)
const {
1033 ArgStringList &CC1Args)
const {
1051 const ArgList &Args)
const {
const char * getOffloadingArch() const
OffloadKind getOffloadingDeviceKind() const
bool isDeviceOffloading(OffloadKind OKind) const
bool isOffloading(OffloadKind OKind) const
Compilation - A set of tasks to perform for a single driver invocation.
A class to find a viable CUDA installation.
void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
CudaInstallationDetector(const Driver &D, const llvm::Triple &HostTriple, const llvm::opt::ArgList &Args)
void WarnIfUnsupportedVersion()
CudaVersion version() const
Get the detected Cuda install's version.
std::string getLibDeviceFile(StringRef Gpu) const
Get libdevice file for given architecture.
void CheckCudaVersionSupportsArch(OffloadArch Arch) const
Emit an error if Version does not support the given Arch.
void print(raw_ostream &OS) const
Print information about the detected CUDA installation.
StringRef getIncludePath() const
Get the detected Cuda Include path.
bool isValid() const
Check whether we detected a valid Cuda install.
Distro - Helper class for detecting and classifying Linux distributions.
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
DiagnosticBuilder Diag(unsigned DiagID) const
const llvm::opt::OptTable & getOpts() const
std::string ResourceDir
The path to the compiler resource directory.
bool willEmitRemarks(const llvm::opt::ArgList &Args)
The JSON file list parser is used to communicate input to InstallAPI.
CudaVersion MaxVersionForOffloadArch(OffloadArch A)
Get the latest CudaVersion that supports the given OffloadArch.
static bool IsNVIDIAOffloadArch(OffloadArch A)
const char * CudaVersionToString(CudaVersion V)
const char * OffloadArchToVirtualArchString(OffloadArch A)
OffloadArch StringToOffloadArch(llvm::StringRef S)
const char * OffloadArchToString(OffloadArch A)
CudaVersion MinVersionForOffloadArch(OffloadArch A)
Get the earliest CudaVersion that supports the given OffloadArch.
Diagnostic wrappers for TextAPI types for error reporting.