Skip to content

Commit fc9d62f

Browse files
authored
[SYCL][AMDGCN] Provide a more helpful --offload-arch error (#13078)
If multiple SYCL targets are provided, asking users to specify `-Xsycl-target-backend --offload-arch` will fail for another reason, which isn't a nice user experience. Instead, we can conditionally tweak the error message so it shows the most concise invocation required for it to work every time. This preserves the old form when only one SYCL target is used - mostly for consistency - but provides the more verbose form when it's required.
1 parent fffe9a1 commit fc9d62f

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

clang/include/clang/Basic/DiagnosticDriverKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def err_drv_fsycl_unsupported_with_opt
391391
def warn_drv_opt_requires_opt
392392
: Warning<"'%0' should be used only in conjunction with '%1'">, InGroup<UnusedCommandLineArgument>;
393393
def err_drv_sycl_missing_amdgpu_arch : Error<
394-
"missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend --offload-arch'">;
394+
"missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend%select{|=%1}0 --offload-arch=<arch-name>'">;
395395
def warn_drv_sycl_offload_target_duplicate : Warning<
396396
"SYCL offloading target '%0' is similar to target '%1' already specified; "
397397
"will be ignored">, InGroup<SyclTarget>;

clang/lib/Driver/Driver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6100,7 +6100,8 @@ class OffloadingActionBuilder final {
61006100
if (Triple.isAMDGCN() && llvm::none_of(GpuArchList, [&](auto &P) {
61016101
return P.first.isAMDGCN();
61026102
})) {
6103-
C.getDriver().Diag(clang::diag::err_drv_sycl_missing_amdgpu_arch);
6103+
C.getDriver().Diag(clang::diag::err_drv_sycl_missing_amdgpu_arch)
6104+
<< (SYCLTripleList.size() > 1) << Triple.str();
61046105
return true;
61056106
}
61066107
}

clang/test/Driver/sycl-offload-amdgcn.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@
77
// RUN: not %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \
88
// RUN: -fsycl-targets=amdgcn-amd-amdhsa %s 2>&1 \
99
// RUN: | FileCheck -check-prefix=CHK-ARCH %s
10-
// CHK-ARCH: error: missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend --offload-arch'
10+
// CHK-ARCH: error: missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend --offload-arch=<arch-name>'
11+
12+
// RUN: not %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \
13+
// RUN: -fsycl-targets=spir64,amdgcn-amd-amdhsa %s 2>&1 \
14+
// RUN: | FileCheck -check-prefix=CHK-MULTI-ARCH %s
15+
// CHK-MULTI-ARCH: error: missing AMDGPU architecture for SYCL offloading; specify it with '-Xsycl-target-backend=amdgcn-amd-amdhsa --offload-arch=<arch-name>'
1116

1217
/// Check action graph.
1318
// RUN: %clangxx -### -std=c++11 -target x86_64-unknown-linux-gnu -fsycl \

0 commit comments

Comments
 (0)