Skip to content

Commit 4723739

Browse files
committed
[SYCL][Clang] Fix compilation with --offload-compress and missing zstd
When using a compiler built without zstd support, it's preferable for --offload-compress option to lead to a warning instead of an error.
1 parent 09fd1c1 commit 4723739

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,23 +1108,23 @@ class BinaryWrapper {
11081108
Fbin = *FBinOrErr;
11091109
} else {
11101110

1111-
// If '--offload-compress' option is specified and zstd is not
1112-
// available, throw an error.
1113-
if (OffloadCompressDevImgs && !llvm::compression::zstd::isAvailable()) {
1114-
return createStringError(
1115-
inconvertibleErrorCode(),
1116-
"'--offload-compress' option is specified but zstd "
1117-
"is not available. The device image will not be "
1118-
"compressed.");
1119-
}
1120-
11211111
// Don't compress if the user explicitly specifies the binary image
11221112
// format or if the image is smaller than OffloadCompressThreshold
1123-
// bytes.
1113+
// bytes, or if zstd is not available.
11241114
if (Kind != OffloadKind::SYCL || !OffloadCompressDevImgs ||
11251115
Img.Fmt != BinaryImageFormat::none ||
11261116
!llvm::compression::zstd::isAvailable() ||
11271117
static_cast<int>(Bin->getBufferSize()) < OffloadCompressThreshold) {
1118+
// If '--offload-compress' option is specified and zstd is not
1119+
// available, throw an error.
1120+
if (OffloadCompressDevImgs &&
1121+
!llvm::compression::zstd::isAvailable()) {
1122+
errs() << "'--offload-compress' option is specified but zstd "
1123+
"is not available. The device image will not be "
1124+
"compressed."
1125+
<< "\n";
1126+
}
1127+
11281128
Fbin = addDeviceImageToModule(
11291129
ArrayRef<char>(Bin->getBufferStart(), Bin->getBufferSize()),
11301130
Twine(OffloadKindTag) + Twine(ImgId) + Twine(".data"), Kind,
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// using --offload-compress without zstd should throw an error.
1+
// using --offload-compress without zstd should throw a warning.
22
// REQUIRES: !zstd
3-
// RUN: not %{build} %O0 -g --offload-compress %S/Inputs/single_kernel.cpp -o %t_compress.out 2>&1 | FileCheck %s
3+
// RUN: %{build} %O0 -g --offload-compress %S/Inputs/single_kernel.cpp -o %t_compress.out 2>&1 | FileCheck %s
44
// CHECK: '--offload-compress' option is specified but zstd is not available. The device image will not be compressed.

0 commit comments

Comments
 (0)