@@ -4723,6 +4723,12 @@ Driver::getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
4723
4723
}
4724
4724
4725
4725
llvm::DenseSet<StringRef> Archs;
4726
+
4727
+ if (!TC->getTargetID ().empty ()) {
4728
+ Archs.insert (TC->getTargetID ());
4729
+ return llvm::SmallVector<StringRef>();
4730
+ }
4731
+
4726
4732
for (auto *Arg : C.getArgsForToolChain (&TC, /* BoundArch=*/ " " , Kind)) {
4727
4733
// Add or remove the seen architectures in order of appearance. If an
4728
4734
// invalid architecture is given we simply exit.
@@ -4731,36 +4737,40 @@ Driver::getOffloadArchs(Compilation &C, const llvm::opt::DerivedArgList &Args,
4731
4737
if (Arch == " native" || Arch.empty ()) {
4732
4738
auto GPUsOrErr = TC.getSystemGPUArchs (Args);
4733
4739
if (!GPUsOrErr) {
4734
- TC.getDriver ().Diag (diag::err_drv_undetermined_gpu_arch)
4735
- << llvm::Triple::getArchTypeName (TC.getArch ())
4736
- << llvm::toString (GPUsOrErr.takeError ()) << " --offload-arch" ;
4740
+ if (!SpecificToolchain)
4741
+ llvm::consumeError (GPUsOrErr.takeError ());
4742
+ else
4743
+ TC.getDriver ().Diag (diag::err_drv_undetermined_gpu_arch)
4744
+ << llvm::Triple::getArchTypeName (TC.getArch ())
4745
+ << llvm::toString (GPUsOrErr.takeError ()) << " --offload-arch" ;
4737
4746
continue ;
4738
4747
}
4739
4748
4740
4749
for (auto ArchStr : *GPUsOrErr) {
4741
- StringRef CanonicalStr = getCanonicalArchString (
4742
- C, Args, Args.MakeArgString (ArchStr), TC.getTriple ());
4750
+ StringRef CanonicalStr =
4751
+ getCanonicalArchString (C, Args, Args.MakeArgString (ArchStr),
4752
+ TC.getTriple ());
4743
4753
if (!CanonicalStr.empty ())
4744
4754
Archs.insert (CanonicalStr);
4745
4755
else
4746
4756
return llvm::SmallVector<StringRef>();
4747
4757
}
4748
4758
} else {
4749
- StringRef CanonicalStr =
4750
- getCanonicalArchString ( C, Args, Arch, TC.getTriple ());
4759
+ StringRef CanonicalStr = getCanonicalArchString (
4760
+ C, Args, Arch, TC.getTriple ());
4751
4761
if (!CanonicalStr.empty ())
4752
4762
Archs.insert (CanonicalStr);
4753
4763
else
4754
4764
return llvm::SmallVector<StringRef>();
4755
4765
}
4756
4766
}
4757
4767
} else if (Arg->getOption ().matches (options::OPT_no_offload_arch_EQ)) {
4758
- for (StringRef Arch : Arg->getValues ()) {
4768
+ for (StringRef Arch : Arg->getValues ()) {
4759
4769
if (Arch == " all" ) {
4760
4770
Archs.clear ();
4761
4771
} else {
4762
- StringRef ArchStr =
4763
- getCanonicalArchString ( C, Args, Arch, TC.getTriple ());
4772
+ StringRef ArchStr = getCanonicalArchString (
4773
+ C, Args, Arch, TC.getTriple ());
4764
4774
Archs.erase (ArchStr);
4765
4775
}
4766
4776
}
0 commit comments