Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-sycl-linker] Fix flaky failure and add REQUIRES (Try #2) #134130

Merged

Conversation

asudarsa
Copy link
Contributor

@asudarsa asudarsa commented Apr 2, 2025

This should fix failures caused by #133967
Attn: @sarnex
Thanks

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Apr 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 2, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Arvind Sudarsanam (asudarsa)

Changes

This should fix failures caused by #133967
Attn: @sarnex
Thanks


Full diff: https://github.com/llvm/llvm-project/pull/134130.diff

4 Files Affected:

  • (modified) clang/test/Driver/clang-sycl-linker-test.cpp (+2)
  • (modified) clang/test/Driver/link-device-code.test (+2)
  • (modified) clang/test/Driver/sycl-link-spirv-target.cpp (+2)
  • (modified) clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp (+3)
diff --git a/clang/test/Driver/clang-sycl-linker-test.cpp b/clang/test/Driver/clang-sycl-linker-test.cpp
index 2f860ae74e97d..c399689653784 100644
--- a/clang/test/Driver/clang-sycl-linker-test.cpp
+++ b/clang/test/Driver/clang-sycl-linker-test.cpp
@@ -1,5 +1,7 @@
 // Tests the clang-sycl-linker tool.
 //
+// REQUIRES: spirv-registered-target
+//
 // Test the dry run of a simple case to link two input files.
 // RUN: %clangxx -emit-llvm -c -target spirv64 %s -o %t_1.bc
 // RUN: %clangxx -emit-llvm -c -target spirv64 %s -o %t_2.bc
diff --git a/clang/test/Driver/link-device-code.test b/clang/test/Driver/link-device-code.test
index a5f52fdb7d9ae..231f02b6560e0 100644
--- a/clang/test/Driver/link-device-code.test
+++ b/clang/test/Driver/link-device-code.test
@@ -1,3 +1,5 @@
+# REQUIRES: spirv-registered-target
+
 # RUN: llvm-as %S/Inputs/SYCL/foo.ll -o %t.foo.bc
 # RUN: llvm-as %S/Inputs/SYCL/bar.ll -o %t.bar.bc
 # RUN: llvm-as %S/Inputs/SYCL/baz.ll -o %t.baz.bc
diff --git a/clang/test/Driver/sycl-link-spirv-target.cpp b/clang/test/Driver/sycl-link-spirv-target.cpp
index 586adae619165..24206e38ad0a7 100644
--- a/clang/test/Driver/sycl-link-spirv-target.cpp
+++ b/clang/test/Driver/sycl-link-spirv-target.cpp
@@ -1,6 +1,8 @@
 // Tests the driver when linking LLVM IR bitcode files and targeting SPIR-V
 // architecture.
 //
+// REQUIRES: spirv-registered-target
+//
 // Test that -Xlinker options are being passed to clang-sycl-linker.
 // RUN: touch %t.bc
 // RUN: %clangxx -### --target=spirv64 --sycl-link -Xlinker -triple=spirv64 -Xlinker --library-path=/tmp \
diff --git a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
index ab718c5a87c40..c640deddc9e74 100644
--- a/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
+++ b/clang/tools/clang-sycl-linker/ClangSYCLLinker.cpp
@@ -288,6 +288,9 @@ static Expected<StringRef> runSPIRVCodeGen(StringRef File, const ArgList &Args,
   if (!M)
     return createStringError(Err.getMessage());
 
+  if (Error Err = M->materializeAll())
+    return std::move(Err);
+
   Triple TargetTriple(Args.getLastArgValue(OPT_triple_EQ));
   M->setTargetTriple(TargetTriple);
 

@sarnex sarnex merged commit 32dff27 into llvm:main Apr 2, 2025
9 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants