Skip to content

Commit 60a8c03

Browse files
committed
Clear -march when -march=generic
1 parent b0ae86c commit 60a8c03

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

clang/lib/Driver/ToolChains/Cuda.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -750,11 +750,11 @@ NVPTXToolChain::TranslateArgs(const llvm::opt::DerivedArgList &Args,
750750
if (!llvm::is_contained(*DAL, A))
751751
DAL->append(A);
752752

753-
if ((!DAL->hasArg(options::OPT_march_EQ) &&
754-
OffloadKind != Action::OFK_None) ||
755-
(DAL->getLastArgValue(options::OPT_march_EQ) == "generic")) {
753+
if (!DAL->hasArg(options::OPT_march_EQ) && OffloadKind != Action::OFK_None) {
756754
DAL->AddJoinedArg(nullptr, Opts.getOption(options::OPT_march_EQ),
757755
CudaArchToString(CudaArch::CudaDefault));
756+
} else if (DAL->getLastArgValue(options::OPT_march_EQ) == "generic") {
757+
DAL->eraseArg(options::OPT_march_EQ);
758758
} else if (DAL->getLastArgValue(options::OPT_march_EQ) == "native") {
759759
auto GPUsOrErr = getSystemGPUArchs(Args);
760760
if (!GPUsOrErr) {

clang/test/Driver/cuda-cross-compiling.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,8 @@
8080
//
8181
// RUN: not %clang -target nvptx64-nvidia-cuda %s -### 2>&1 \
8282
// RUN: | FileCheck -check-prefix=MISSING %s
83+
// RUN: not %clang -target nvptx64-nvidia-cuda -march=generic %s -### 2>&1 \
84+
// RUN: | FileCheck -check-prefix=MISSING %s
8385

8486
// MISSING: error: Must pass in an explicit nvptx64 gpu architecture to 'ptxas'
8587
// MISSING: error: Must pass in an explicit nvptx64 gpu architecture to 'nvlink'

0 commit comments

Comments
 (0)