12#include "clang/Config/config.h"
19#include "llvm/ADT/StringExtras.h"
20#include "llvm/Config/llvm-config.h"
21#include "llvm/Option/ArgList.h"
22#include "llvm/Support/FileSystem.h"
23#include "llvm/Support/FormatAdapters.h"
24#include "llvm/Support/FormatVariadic.h"
25#include "llvm/Support/Path.h"
26#include "llvm/Support/Process.h"
27#include "llvm/Support/Program.h"
28#include "llvm/Support/VirtualFileSystem.h"
29#include "llvm/TargetParser/Host.h"
30#include "llvm/TargetParser/TargetParser.h"
31#include <system_error>
42 if (raw_version < 7050)
43 return CudaVersion::CUDA_70;
44 if (raw_version < 8000)
45 return CudaVersion::CUDA_75;
46 if (raw_version < 9000)
47 return CudaVersion::CUDA_80;
48 if (raw_version < 9010)
49 return CudaVersion::CUDA_90;
50 if (raw_version < 9020)
51 return CudaVersion::CUDA_91;
52 if (raw_version < 10000)
53 return CudaVersion::CUDA_92;
54 if (raw_version < 10010)
55 return CudaVersion::CUDA_100;
56 if (raw_version < 10020)
57 return CudaVersion::CUDA_101;
58 if (raw_version < 11000)
59 return CudaVersion::CUDA_102;
60 if (raw_version < 11010)
61 return CudaVersion::CUDA_110;
62 if (raw_version < 11020)
63 return CudaVersion::CUDA_111;
64 if (raw_version < 11030)
65 return CudaVersion::CUDA_112;
66 if (raw_version < 11040)
67 return CudaVersion::CUDA_113;
68 if (raw_version < 11050)
69 return CudaVersion::CUDA_114;
70 if (raw_version < 11060)
71 return CudaVersion::CUDA_115;
72 if (raw_version < 11070)
73 return CudaVersion::CUDA_116;
74 if (raw_version < 11080)
75 return CudaVersion::CUDA_117;
76 if (raw_version < 11090)
77 return CudaVersion::CUDA_118;
78 if (raw_version < 12010)
79 return CudaVersion::CUDA_120;
80 if (raw_version < 12020)
81 return CudaVersion::CUDA_121;
82 if (raw_version < 12030)
83 return CudaVersion::CUDA_122;
84 if (raw_version < 12040)
85 return CudaVersion::CUDA_123;
86 if (raw_version < 12050)
87 return CudaVersion::CUDA_124;
88 if (raw_version < 12060)
89 return CudaVersion::CUDA_125;
90 if (raw_version < 12070)
91 return CudaVersion::CUDA_126;
92 return CudaVersion::NEW;
98 auto StartsWithWords =
99 [](llvm::StringRef Line,
101 for (StringRef word : words) {
102 if (!Line.consume_front(word))
109 Input = Input.ltrim();
110 while (!Input.empty()) {
112 StartsWithWords(Input.ltrim(), {
"#",
"define",
"CUDA_VERSION"})) {
114 Line->consumeInteger(10, RawVersion);
115 return getCudaVersion(RawVersion);
118 Input = Input.drop_front(Input.find_first_of(
"\n\r")).ltrim();
120 return CudaVersion::UNKNOWN;
127 if (!VersionString.empty())
128 VersionString.insert(0,
" ");
129 D.
Diag(diag::warn_drv_new_cuda_version)
134 D.
Diag(diag::warn_drv_partially_supported_cuda_version)
139 const Driver &
D,
const llvm::Triple &HostTriple,
140 const llvm::opt::ArgList &Args)
146 Candidate(std::string
Path,
bool StrictChecking =
false)
147 :
Path(
Path), StrictChecking(StrictChecking) {}
152 std::initializer_list<const char *> Versions = {
"8.0",
"7.5",
"7.0"};
153 auto &FS =
D.getVFS();
155 if (Args.hasArg(clang::driver::options::OPT_cuda_path_EQ)) {
156 Candidates.emplace_back(
157 Args.getLastArgValue(clang::driver::options::OPT_cuda_path_EQ).str());
158 }
else if (HostTriple.isOSWindows()) {
159 for (
const char *Ver : Versions)
160 Candidates.emplace_back(
161 D.SysRoot +
"/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v" +
164 if (!Args.hasArg(clang::driver::options::OPT_cuda_path_ignore_env)) {
173 if (llvm::ErrorOr<std::string> ptxas =
174 llvm::sys::findProgramByName(
"ptxas")) {
176 llvm::sys::fs::real_path(*ptxas, ptxasAbsolutePath);
178 StringRef ptxasDir = llvm::sys::path::parent_path(ptxasAbsolutePath);
179 if (llvm::sys::path::filename(ptxasDir) ==
"bin")
180 Candidates.emplace_back(
181 std::string(llvm::sys::path::parent_path(ptxasDir)),
186 Candidates.emplace_back(
D.SysRoot +
"/usr/local/cuda");
187 for (
const char *Ver : Versions)
188 Candidates.emplace_back(
D.SysRoot +
"/usr/local/cuda-" + Ver);
190 Distro Dist(FS, llvm::Triple(llvm::sys::getProcessTriple()));
194 Candidates.emplace_back(
D.SysRoot +
"/usr/lib/cuda");
197 bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
199 for (
const auto &Candidate : Candidates) {
200 InstallPath = Candidate.Path;
201 if (InstallPath.empty() || !FS.exists(InstallPath))
204 BinPath = InstallPath +
"/bin";
205 IncludePath = InstallPath +
"/include";
206 LibDevicePath = InstallPath +
"/nvvm/libdevice";
208 if (!(FS.exists(IncludePath) && FS.exists(BinPath)))
210 bool CheckLibDevice = (!NoCudaLib || Candidate.StrictChecking);
211 if (CheckLibDevice && !FS.exists(LibDevicePath))
215 if (
auto CudaHFile = FS.getBufferForFile(InstallPath +
"/include/cuda.h"))
216 Version = parseCudaHFile((*CudaHFile)->getBuffer());
220 Version = FS.exists(LibDevicePath +
"/libdevice.10.bc")
227 std::string FilePath = LibDevicePath +
"/libdevice.10.bc";
228 if (FS.exists(FilePath)) {
235 LibDeviceMap[OffloadArchName] = FilePath;
240 for (llvm::vfs::directory_iterator LI = FS.dir_begin(LibDevicePath, EC),
242 !EC && LI != LE; LI = LI.increment(EC)) {
243 StringRef FilePath = LI->path();
244 StringRef
FileName = llvm::sys::path::filename(FilePath);
247 const StringRef LibDeviceName =
"libdevice.";
251 LibDeviceName.size(),
FileName.find(
'.', LibDeviceName.size()));
252 LibDeviceMap[GpuArch] = FilePath.str();
256 if (GpuArch ==
"compute_20") {
257 LibDeviceMap[
"sm_20"] = std::string(FilePath);
258 LibDeviceMap[
"sm_21"] = std::string(FilePath);
259 LibDeviceMap[
"sm_32"] = std::string(FilePath);
260 }
else if (GpuArch ==
"compute_30") {
261 LibDeviceMap[
"sm_30"] = std::string(FilePath);
263 LibDeviceMap[
"sm_50"] = std::string(FilePath);
264 LibDeviceMap[
"sm_52"] = std::string(FilePath);
265 LibDeviceMap[
"sm_53"] = std::string(FilePath);
267 LibDeviceMap[
"sm_60"] = std::string(FilePath);
268 LibDeviceMap[
"sm_61"] = std::string(FilePath);
269 LibDeviceMap[
"sm_62"] = std::string(FilePath);
270 }
else if (GpuArch ==
"compute_35") {
271 LibDeviceMap[
"sm_35"] = std::string(FilePath);
272 LibDeviceMap[
"sm_37"] = std::string(FilePath);
273 }
else if (GpuArch ==
"compute_50") {
275 LibDeviceMap[
"sm_50"] = std::string(FilePath);
276 LibDeviceMap[
"sm_52"] = std::string(FilePath);
277 LibDeviceMap[
"sm_53"] = std::string(FilePath);
285 if (LibDeviceMap.empty() && !NoCudaLib)
294 const ArgList &DriverArgs, ArgStringList &CC1Args)
const {
295 if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
299 llvm::sys::path::append(
P,
"include");
300 llvm::sys::path::append(
P,
"cuda_wrappers");
301 CC1Args.push_back(
"-internal-isystem");
302 CC1Args.push_back(DriverArgs.MakeArgString(
P));
305 if (DriverArgs.hasArg(options::OPT_nogpuinc))
309 D.
Diag(diag::err_drv_no_cuda_installation);
313 CC1Args.push_back(
"-include");
314 CC1Args.push_back(
"__clang_cuda_runtime_wrapper.h");
320 ArchsWithBadVersion[(
int)Arch])
325 if (Version < MinVersion || Version > MaxVersion) {
326 ArchsWithBadVersion[(
int)Arch] =
true;
327 D.
Diag(diag::err_drv_cuda_version_unsupported)
336 OS <<
"Found CUDA installation: " << InstallPath <<
", version "
346enum DeviceDebugInfoLevel {
349 EmitSameDebugInfoAsHost,
363 const Arg *A = Args.getLastArg(options::OPT_O_Group);
364 bool IsDebugEnabled = !A || A->getOption().matches(options::OPT_O0) ||
365 Args.hasFlag(options::OPT_cuda_noopt_device_debug,
366 options::OPT_no_cuda_noopt_device_debug,
368 if (
const Arg *A = Args.getLastArg(options::OPT_g_Group)) {
369 const Option &Opt = A->getOption();
370 if (Opt.matches(options::OPT_gN_Group)) {
371 if (Opt.matches(options::OPT_g0) || Opt.matches(options::OPT_ggdb0))
372 return DisableDebugInfo;
373 if (Opt.matches(options::OPT_gline_directives_only))
374 return DebugDirectivesOnly;
376 return IsDebugEnabled ? EmitSameDebugInfoAsHost : DebugDirectivesOnly;
385 const char *LinkingOutput)
const {
388 assert(TC.getTriple().isNVPTX() &&
"Wrong platform");
390 StringRef GPUArchName;
398 GPUArchName = Args.getLastArgValue(options::OPT_march_EQ);
399 if (GPUArchName.empty()) {
400 C.getDriver().Diag(diag::err_drv_offload_missing_gpu_arch)
401 << getToolChain().getArchName() << getShortName();
409 "Device action expected to have an architecture.");
412 if (!Args.hasArg(options::OPT_no_cuda_version_check)) {
413 TC.CudaInstallation.CheckCudaVersionSupportsArch(gpu_arch);
416 ArgStringList CmdArgs;
417 CmdArgs.push_back(TC.getTriple().isArch64Bit() ?
"-m64" :
"-m32");
419 if (DIKind == EmitSameDebugInfoAsHost) {
422 CmdArgs.push_back(
"-g");
423 CmdArgs.push_back(
"--dont-merge-basicblocks");
424 CmdArgs.push_back(
"--return-at-end");
425 }
else if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
433 StringRef OOpt =
"3";
434 if (A->getOption().matches(options::OPT_O4) ||
435 A->getOption().matches(options::OPT_Ofast))
437 else if (A->getOption().matches(options::OPT_O0))
439 else if (A->getOption().matches(options::OPT_O)) {
441 OOpt = llvm::StringSwitch<const char *>(A->getValue())
449 CmdArgs.push_back(Args.MakeArgString(llvm::Twine(
"-O") + OOpt));
453 CmdArgs.push_back(
"-O0");
455 if (DIKind == DebugDirectivesOnly)
456 CmdArgs.push_back(
"-lineinfo");
459 if (Args.hasArg(options::OPT_v))
460 CmdArgs.push_back(
"-v");
462 CmdArgs.push_back(
"--gpu-name");
464 CmdArgs.push_back(
"--output-file");
465 std::string OutputFileName = TC.getInputFilename(Output);
468 C.addTempFile(Args.MakeArgString(OutputFileName));
470 CmdArgs.push_back(Args.MakeArgString(OutputFileName));
471 for (
const auto &II : Inputs)
472 CmdArgs.push_back(Args.MakeArgString(II.getFilename()));
474 for (
const auto &A : Args.getAllArgValues(options::OPT_Xcuda_ptxas))
475 CmdArgs.push_back(Args.MakeArgString(A));
480 Relocatable = Args.hasFlag(options::OPT_fopenmp_relocatable_target,
481 options::OPT_fnoopenmp_relocatable_target,
485 Relocatable = Args.hasFlag(options::OPT_fgpu_rdc, options::OPT_fno_gpu_rdc,
492 CmdArgs.push_back(
"-c");
495 if (Arg *A = Args.getLastArg(options::OPT_ptxas_path_EQ))
496 Exec = A->getValue();
498 Exec = Args.MakeArgString(TC.GetProgramPath(
"ptxas"));
499 C.addCommand(std::make_unique<Command>(
503 Exec, CmdArgs, Inputs, Output));
508 bool includePTX = !Args.hasFlag(options::OPT_offload_new_driver,
509 options::OPT_no_offload_new_driver,
false);
510 for (Arg *A : Args.filtered(options::OPT_cuda_include_ptx_EQ,
511 options::OPT_no_cuda_include_ptx_EQ)) {
513 const StringRef ArchStr = A->getValue();
514 if (A->getOption().matches(options::OPT_cuda_include_ptx_EQ) &&
515 (ArchStr ==
"all" || ArchStr == InputArch))
517 else if (A->getOption().matches(options::OPT_no_cuda_include_ptx_EQ) &&
518 (ArchStr ==
"all" || ArchStr == InputArch))
531 const char *LinkingOutput)
const {
534 assert(TC.getTriple().isNVPTX() &&
"Wrong platform");
536 ArgStringList CmdArgs;
538 CmdArgs.push_back(
"--cuda");
539 CmdArgs.push_back(TC.getTriple().isArch64Bit() ?
"-64" :
"-32");
540 CmdArgs.push_back(Args.MakeArgString(
"--create"));
541 CmdArgs.push_back(Args.MakeArgString(Output.
getFilename()));
543 CmdArgs.push_back(
"-g");
545 for (
const auto &II : Inputs) {
546 auto *A = II.getAction();
547 assert(A->getInputs().size() == 1 &&
548 "Device offload action is expected to have a single input");
549 const char *gpu_arch_str = A->getOffloadingArch();
550 assert(gpu_arch_str &&
551 "Device action expected to have associated a GPU architecture!");
554 if (II.getType() == types::TY_PP_Asm &&
559 const char *Arch = (II.getType() == types::TY_PP_Asm)
563 Args.MakeArgString(llvm::Twine(
"--image=profile=") + Arch +
564 ",file=" + getToolChain().getInputFilename(II)));
567 for (
const auto &A : Args.getAllArgValues(options::OPT_Xcuda_fatbinary))
568 CmdArgs.push_back(Args.MakeArgString(A));
570 const char *Exec = Args.MakeArgString(TC.GetProgramPath(
"fatbinary"));
571 C.addCommand(std::make_unique<Command>(
575 Exec, CmdArgs, Inputs, Output));
582 const char *LinkingOutput)
const {
585 ArgStringList CmdArgs;
587 assert(TC.getTriple().isNVPTX() &&
"Wrong platform");
591 CmdArgs.push_back(
"-o");
596 CmdArgs.push_back(
"-g");
598 if (Args.hasArg(options::OPT_v))
599 CmdArgs.push_back(
"-v");
601 StringRef GPUArch = Args.getLastArgValue(options::OPT_march_EQ);
602 if (GPUArch.empty() && !
C.getDriver().isUsingLTO()) {
603 C.getDriver().Diag(diag::err_drv_offload_missing_gpu_arch)
604 << getToolChain().getArchName() << getShortName();
608 if (!GPUArch.empty()) {
609 CmdArgs.push_back(
"-arch");
610 CmdArgs.push_back(Args.MakeArgString(GPUArch));
613 if (Args.hasArg(options::OPT_ptxas_path_EQ))
614 CmdArgs.push_back(Args.MakeArgString(
615 "--pxtas-path=" + Args.getLastArgValue(options::OPT_ptxas_path_EQ)));
617 if (Args.hasArg(options::OPT_cuda_path_EQ))
618 CmdArgs.push_back(Args.MakeArgString(
619 "--cuda-path=" + Args.getLastArgValue(options::OPT_cuda_path_EQ)));
625 Args.AddAllArgs(CmdArgs, options::OPT_L);
626 getToolChain().AddFilePathLibArgs(Args, CmdArgs);
629 if (
C.getDriver().isUsingLTO())
630 addLTOOptions(getToolChain(), Args, CmdArgs, Output, Inputs[0],
634 std::vector<StringRef> Features;
638 Args.MakeArgString(
"--plugin-opt=-mattr=" + llvm::join(Features,
",")));
642 llvm::sys::path::parent_path(TC.getDriver().Dir);
643 llvm::sys::path::append(DefaultLibPath, CLANG_INSTALL_LIBDIR_BASENAME);
644 CmdArgs.push_back(Args.MakeArgString(Twine(
"-L") + DefaultLibPath));
646 if (Args.hasArg(options::OPT_stdlib))
647 CmdArgs.append({
"-lc",
"-lm"});
648 if (Args.hasArg(options::OPT_startfiles)) {
649 std::optional<std::string> IncludePath = getToolChain().getStdlibPath();
651 IncludePath =
"/lib";
653 llvm::sys::path::append(
P,
"crt1.o");
654 CmdArgs.push_back(Args.MakeArgString(
P));
657 C.addCommand(std::make_unique<Command>(
661 Args.MakeArgString(getToolChain().GetProgramPath(
"clang-nvlink-wrapper")),
662 CmdArgs, Inputs, Output));
666 const llvm::opt::ArgList &Args,
667 std::vector<StringRef> &Features) {
668 if (Args.hasArg(options::OPT_cuda_feature_EQ)) {
669 StringRef PtxFeature =
670 Args.getLastArgValue(options::OPT_cuda_feature_EQ,
"+ptx42");
671 Features.push_back(Args.MakeArgString(PtxFeature));
679 const char *PtxFeature =
nullptr;
680 switch (CudaInstallation.
version()) {
681#define CASE_CUDA_VERSION(CUDA_VER, PTX_VER) \
682 case CudaVersion::CUDA_##CUDA_VER: \
683 PtxFeature = "+ptx" #PTX_VER; \
707#undef CASE_CUDA_VERSION
710 PtxFeature =
"+ptx86";
713 PtxFeature =
"+ptx42";
715 Features.push_back(PtxFeature);
722 const llvm::Triple &HostTriple,
723 const ArgList &Args,
bool Freestanding =
false)
724 :
ToolChain(
D, Triple, Args), CudaInstallation(
D, HostTriple, Args),
725 Freestanding(Freestanding) {
726 if (CudaInstallation.isValid())
727 getProgramPaths().push_back(std::string(CudaInstallation.getBinPath()));
730 getProgramPaths().push_back(getDriver().Dir);
740llvm::opt::DerivedArgList *
746 DAL =
new DerivedArgList(Args.getBaseArgs());
748 const OptTable &Opts = getDriver().getOpts();
751 if (!llvm::is_contained(*DAL, A))
754 if (!DAL->hasArg(options::OPT_march_EQ) && OffloadKind !=
Action::OFK_None) {
755 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ),
757 }
else if (DAL->getLastArgValue(options::OPT_march_EQ) ==
"generic" &&
759 DAL->eraseArg(options::OPT_march_EQ);
760 }
else if (DAL->getLastArgValue(options::OPT_march_EQ) ==
"native") {
761 auto GPUsOrErr = getSystemGPUArchs(Args);
763 getDriver().Diag(diag::err_drv_undetermined_gpu_arch)
764 << getArchName() << llvm::toString(GPUsOrErr.takeError()) <<
"-march";
766 if (GPUsOrErr->size() > 1)
767 getDriver().Diag(diag::warn_drv_multi_gpu_arch)
768 << getArchName() << llvm::join(*GPUsOrErr,
", ") <<
"-march";
769 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ),
770 Args.MakeArgString(GPUsOrErr->front()));
778 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
784 CC1Args.append({
"-mllvm",
"--nvptx-lower-global-ctor-dtor"});
788 const Option &O = A->getOption();
789 return (O.matches(options::OPT_gN_Group) &&
790 !O.matches(options::OPT_gmodules)) ||
791 O.matches(options::OPT_g_Flag) ||
792 O.matches(options::OPT_ggdbN_Group) || O.matches(options::OPT_ggdb) ||
793 O.matches(options::OPT_gdwarf) || O.matches(options::OPT_gdwarf_2) ||
794 O.matches(options::OPT_gdwarf_3) || O.matches(options::OPT_gdwarf_4) ||
795 O.matches(options::OPT_gdwarf_5) ||
796 O.matches(options::OPT_gcolumn_info);
800 llvm::codegenoptions::DebugInfoKind &DebugInfoKind,
801 const ArgList &Args)
const {
803 case DisableDebugInfo:
804 DebugInfoKind = llvm::codegenoptions::NoDebugInfo;
806 case DebugDirectivesOnly:
807 DebugInfoKind = llvm::codegenoptions::DebugDirectivesOnly;
809 case EmitSameDebugInfoAsHost:
819 if (Arg *A = Args.getLastArg(options::OPT_nvptx_arch_tool_EQ))
820 Program = A->getValue();
822 Program = GetProgramPath(
"nvptx-arch");
824 auto StdoutOrErr = executeToolChainProgram(Program);
826 return StdoutOrErr.takeError();
829 for (StringRef Arch : llvm::split((*StdoutOrErr)->getBuffer(),
"\n"))
831 GPUArchs.push_back(Arch.str());
833 if (GPUArchs.empty())
834 return llvm::createStringError(std::error_code(),
835 "No NVIDIA GPU detected in the system");
837 return std::move(GPUArchs);
845 const ToolChain &HostTC,
const ArgList &Args)
846 :
NVPTXToolChain(
D, Triple, HostTC.getTriple(), Args), HostTC(HostTC) {}
849 const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
853 StringRef GpuArch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
856 "Only OpenMP or CUDA offloading kinds are supported for NVIDIA GPUs.");
858 CC1Args.append({
"-fcuda-is-device",
"-mllvm",
859 "-enable-memcpyopt-without-libcalls",
860 "-fno-threadsafe-statics"});
867 CC1Args.push_back(
"-fcuda-allow-variadic-functions");
869 if (DriverArgs.hasFlag(options::OPT_fcuda_short_ptr,
870 options::OPT_fno_cuda_short_ptr,
false))
871 CC1Args.append({
"-mllvm",
"--nvptx-short-ptr"});
873 if (DriverArgs.hasArg(options::OPT_nogpulib))
877 DriverArgs.hasArg(options::OPT_S))
881 if (LibDeviceFile.empty()) {
882 getDriver().
Diag(diag::err_drv_no_cuda_libdevice) << GpuArch;
886 CC1Args.push_back(
"-mlink-builtin-bitcode");
887 CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
892 if (DriverArgs.hasFlag(options::OPT_foffload_via_llvm,
893 options::OPT_fno_offload_via_llvm,
false))
900 DriverArgs.MakeArgString(Twine(
"-target-sdk-version=") +
906 diag::err_drv_omp_offload_target_cuda_version_not_support)
921 const llvm::opt::ArgList &DriverArgs,
const JobAction &JA,
922 const llvm::fltSemantics *FPType)
const {
924 if (FPType && FPType == &llvm::APFloat::IEEEsingle() &&
925 DriverArgs.hasFlag(options::OPT_fgpu_flush_denormals_to_zero,
926 options::OPT_fno_gpu_flush_denormals_to_zero,
false))
927 return llvm::DenormalMode::getPreserveSign();
931 return llvm::DenormalMode::getIEEE();
935 ArgStringList &CC1Args)
const {
937 if (!DriverArgs.hasArg(options::OPT_nogpuinc) &&
938 !DriverArgs.hasArg(options::OPT_no_cuda_version_check)) {
939 StringRef Arch = DriverArgs.getLastArgValue(options::OPT_march_EQ);
940 assert(!Arch.empty() &&
"Must have an explicit GPU arch.");
955llvm::opt::DerivedArgList *
959 DerivedArgList *DAL =
962 DAL =
new DerivedArgList(Args.getBaseArgs());
971 if (!llvm::is_contained(*DAL, A))
974 if (!DAL->hasArg(options::OPT_march_EQ)) {
975 StringRef Arch = BoundArch;
980 llvm::formatv(
"{0}", llvm::fmt_consume(ArchsOrErr.takeError()));
982 << llvm::Triple::getArchTypeName(
getArch()) << ErrMsg <<
"-march";
985 Arch = Args.MakeArgString(ArchsOrErr->front());
988 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ), Arch);
994 for (Arg *A : Args) {
996 if (!llvm::is_contained(*DAL, A)) {
1001 if (!BoundArch.empty()) {
1002 DAL->eraseArg(options::OPT_march_EQ);
1003 DAL->AddJoinedArg(
nullptr, Opts.getOption(options::OPT_march_EQ),
1035 ArgStringList &CC1Args)
const {
1040 {
"-internal-isystem",
1045 ArgStringList &CC1Args)
const {
1050 ArgStringList &CC1Args)
const {
1068 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.