Skip to content

[Clang][SYCL] Introduce clang-sycl-linker to link SYCL offloading device code (Part 1 of many) #112245

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

Merged
merged 12 commits into from
Oct 31, 2024

Conversation

asudarsa
Copy link
Contributor

@asudarsa asudarsa commented Oct 14, 2024

This PR is one of the many PRs in the SYCL upstreaming effort focusing on device code linking during the SYCL offload compilation process. RFC: https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device code linking for SYCL offload kind. It accepts SYCL device objects in LLVM IR bitcode format and will generate a fully linked device object that can then be wrapped and linked into the host object.

A primary use case for this tool is to perform device code linking for objects with SYCL offload kind inside the clang-linker-wrapper. It can also be invoked via clang driver as follows:

clang --target=spirv64 --sycl-link input.bc

Device code linking for SYCL offloading kind has a number of known quirks that makes it difficult to use in a unified offloading setting. Two of the primary issues are:

  1. Several finalization steps are required to be run on the fully-linked LLVM IR bitcode to gaurantee conformance to SYCL standards. This step is unique to SYCL offloading compilation flow.
  2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR code generation cannot be done as part of LTO. This limitation will be lifted once SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform SYCL device linking.

Co-Author: Michael Toguchi
Thanks

…ng device code

This PR is one of the many PRs in the SYCL upstreaming effort focusing on
device code linking during the SYCL offload compilation process.
RFC: https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device code
linking for SYCL offload kind. It accepts SYCL device objects in LLVM IR bitcode
format and will generate a fully linked device object that can then be wrapped
and linked into the host object.

A primary use case for this tool is to perform device code linking for objects
with SYCL offload kind inside the clang-linker-wrapper.
It can also be invoked via clang driver as follows:

`clang --target=spirv64 --sycl-link input.bc`

Device code linking for SYCL offloading kind has a number of known quirks that
makes it difficult to use in a unified offloading setting.
Two of the primary issues are:
1. Several finalization steps are required to be run on the fully-linked LLVM
IR bitcode to gaurantee conformance to SYCL standards. This step is unique to
SYCL offloading compilation flow.
2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR code
generation cannot be done as part of LTO. This limitation will be lifted once
SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform SYCL
device linking.

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' backend:SPIR-V labels Oct 14, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2024

@llvm/pr-subscribers-backend-spir-v

Author: Arvind Sudarsanam (asudarsa)

Changes

This PR is one of the many PRs in the SYCL upstreaming effort focusing on device code linking during the SYCL offload compilation process. RFC: https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device code linking for SYCL offload kind. It accepts SYCL device objects in LLVM IR bitcode format and will generate a fully linked device object that can then be wrapped and linked into the host object.

A primary use case for this tool is to perform device code linking for objects with SYCL offload kind inside the clang-linker-wrapper. It can also be invoked via clang driver as follows:

clang --target=spirv64 --sycl-link input.bc

Device code linking for SYCL offloading kind has a number of known quirks that makes it difficult to use in a unified offloading setting. Two of the primary issues are:

  1. Several finalization steps are required to be run on the fully-linked LLVM IR bitcode to gaurantee conformance to SYCL standards. This step is unique to SYCL offloading compilation flow.
  2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR code generation cannot be done as part of LTO. This limitation will be lifted once SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform SYCL device linking.

Thanks


Patch is 32.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/112245.diff

14 Files Affected:

  • (added) clang/docs/ClangSYCLLinkWrapper.rst (+80)
  • (modified) clang/docs/index.rst (+1)
  • (modified) clang/include/clang/Driver/Options.td (+4-1)
  • (modified) clang/lib/Driver/Driver.cpp (+5)
  • (modified) clang/lib/Driver/ToolChains/SPIRV.cpp (+12)
  • (modified) clang/lib/Driver/ToolChains/SPIRV.h (+3-2)
  • (added) clang/test/Driver/Inputs/libsycl-complex.bc ()
  • (added) clang/test/Driver/Inputs/libsycl-crt.bc ()
  • (added) clang/test/Driver/clang-sycl-link-wrapper-test.cpp (+9)
  • (added) clang/test/Driver/sycl-link-spirv-target.cpp (+7)
  • (modified) clang/tools/CMakeLists.txt (+1)
  • (added) clang/tools/clang-sycl-link-wrapper/CMakeLists.txt (+28)
  • (added) clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp (+530)
  • (added) clang/tools/clang-sycl-link-wrapper/SYCLLinkOpts.td (+47)
diff --git a/clang/docs/ClangSYCLLinkWrapper.rst b/clang/docs/ClangSYCLLinkWrapper.rst
new file mode 100644
index 00000000000000..8ceb17f6af9d86
--- /dev/null
+++ b/clang/docs/ClangSYCLLinkWrapper.rst
@@ -0,0 +1,80 @@
+=======================
+Clang SYCL Link Wrapper
+=======================
+
+.. contents::
+   :local:
+
+.. _clang-sycl-link-wrapper:
+
+Introduction
+============
+
+This tool works as a wrapper around the SYCL device code linking process.
+The purpose of this wrapper is to provide an interface to link SYCL device
+bitcode in LLVM IR format, SYCL device bitcode in SPIR-V IR format, and native
+binary objects, and then use the SPIR-V LLVM Translator tool on fully linked
+device objects to produce the final output.
+After the linking stage, the fully linked device code in LLVM IR format may
+undergo several SYCL-specific finalization steps before the SPIR-V code
+generation step.
+The wrapper will also support the Ahead-Of-Time (AOT) compilation flow. AOT
+compilation is the process of invoking the back-end at compile time to produce
+the final binary, as opposed to just-in-time (JIT) compilation when final code
+generation is deferred until application runtime.
+
+Device code linking for SYCL offloading has several known quirks that
+make it difficult to use in a unified offloading setting. Two of the primary
+issues are:
+1. Several finalization steps are required to be run on the fully linked LLVM
+IR bitcode to guarantee conformance to SYCL standards. This step is unique to
+the SYCL offloading compilation flow.
+2. The SPIR-V LLVM Translator tool is an external tool and hence SPIR-V IR code
+generation cannot be done as part of LTO. This limitation can be lifted once
+the SPIR-V backend is available as a viable LLVM backend.
+
+This tool has been proposed to work around these issues.
+
+Usage
+=====
+
+This tool can be used with the following options. Several of these options will
+be passed down to downstream tools like 'llvm-link', 'llvm-spirv', etc.
+
+.. code-block:: console
+
+  OVERVIEW: A utility that wraps around the SYCL device code linking process.
+  This enables linking and code generation for SPIR-V JIT targets and AOT
+  targets.
+
+  USAGE: clang-sycl-link-wrapper [options]
+
+  OPTIONS:
+    --arch <value>                Specify the name of the target architecture.
+    --dry-run                     Print generated commands without running.
+    -g                            Specify that this was a debug compile.
+    -help-hidden                  Display all available options
+    -help                         Display available options (--help-hidden for more)
+    --library-path=<dir>          Set the library path for SYCL device libraries
+    -o <path>                     Path to file to write output
+    --save-temps                  Save intermediate results
+    --triple <value>              Specify the target triple.
+    --version                     Display the version number and exit
+    -v                            Print verbose information
+    -spirv-dump-device-code=<dir> Directory to dump SPIR-V IR code into
+    -is-windows-msvc-env          Specify if we are compiling under windows environment
+    -llvm-spirv-options=<value>   Pass options to llvm-spirv tool
+
+Example
+=======
+
+This tool is intended to be invoked when targeting any of the target offloading
+toolchains. When the --sycl-link option is passed to the clang driver, the
+driver will invoke the linking job of the target offloading toolchain, which in
+turn will invoke this tool. This tool can be used to create one or more fully
+linked device images that are ready to be wrapped and linked with host code to
+generate the final executable.
+
+.. code-block:: console
+
+  clang-sycl-link-wrapper --triple spirv64 --arch native input.bc
diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4a497f4d9bcc3c..ccdc16d3e07699 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -97,6 +97,7 @@ Using Clang Tools
    ClangOffloadBundler
    ClangOffloadPackager
    ClangRepl
+   ClangSYCLLinkWrapper
 
 Design Documents
 ================
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 3f4d1a328b4c27..245af5a539a4fa 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6728,7 +6728,10 @@ def fsycl : Flag<["-"], "fsycl">,
 def fno_sycl : Flag<["-"], "fno-sycl">,
   Visibility<[ClangOption, CLOption]>,
   Group<sycl_Group>, HelpText<"Disables SYCL kernels compilation for device">;
-
+def sycl_link : Flag<["--"], "sycl-link">, Flags<[HelpHidden]>,
+  Visibility<[ClangOption, CLOption]>,
+  Group<sycl_Group>, HelpText<"Perform link through clang-sycl-link-wrapper via the target "
+  "offloading toolchain.">;
 // OS-specific options
 let Flags = [TargetSpecific] in {
 defm android_pad_segment : BooleanFFlag<"android-pad-segment">, Group<f_Group>;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d0c8bdba0ede95..184eafa137b178 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4780,6 +4780,11 @@ Action *Driver::ConstructPhaseAction(
   if (Phase == phases::Assemble && Input->getType() != types::TY_PP_Asm)
     return Input;
 
+  // Use of --sycl-link will only allow for the link phase to occur. This is
+  // for all input files.
+  if (Args.hasArg(options::OPT_sycl_link) && Phase != phases::Link)
+    return Input;
+
   // Build the appropriate action.
   switch (Phase) {
   case phases::Link:
diff --git a/clang/lib/Driver/ToolChains/SPIRV.cpp b/clang/lib/Driver/ToolChains/SPIRV.cpp
index ce900600cbee51..860fd932a58718 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRV.cpp
@@ -95,7 +95,19 @@ void SPIRV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  // Use of --sycl-link will call the clang-sycl-link-wrapper instead of
+  // the default linker (spirv-link).
+  if (Args.hasArg(options::OPT_sycl_link))
+    Linker = ToolChain.GetProgramPath("clang-sycl-link-wrapper");
   C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
                                          Args.MakeArgString(Linker), CmdArgs,
                                          Inputs, Output));
 }
+
+SPIRVToolChain::SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
+                               const ArgList &Args)
+    : ToolChain(D, Triple, Args) {
+  NativeLLVMSupport = Args.hasArg(options::OPT_sycl_link);
+}
+
+bool SPIRVToolChain::HasNativeLLVMSupport() const { return NativeLLVMSupport; }
diff --git a/clang/lib/Driver/ToolChains/SPIRV.h b/clang/lib/Driver/ToolChains/SPIRV.h
index d4247ee0557f4b..d59a8c76ed4737 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.h
+++ b/clang/lib/Driver/ToolChains/SPIRV.h
@@ -57,8 +57,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
 
 public:
   SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
-                 const llvm::opt::ArgList &Args)
-      : ToolChain(D, Triple, Args) {}
+                 const llvm::opt::ArgList &Args);
 
   bool useIntegratedAs() const override { return true; }
 
@@ -72,6 +71,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
   }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
+  bool HasNativeLLVMSupport() const override;
 
   clang::driver::Tool *SelectTool(const JobAction &JA) const override;
 
@@ -81,6 +81,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
 
 private:
   clang::driver::Tool *getTranslator() const;
+  bool NativeLLVMSupport;
 };
 
 } // namespace toolchains
diff --git a/clang/test/Driver/Inputs/libsycl-complex.bc b/clang/test/Driver/Inputs/libsycl-complex.bc
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/libsycl-crt.bc b/clang/test/Driver/Inputs/libsycl-crt.bc
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/clang-sycl-link-wrapper-test.cpp b/clang/test/Driver/clang-sycl-link-wrapper-test.cpp
new file mode 100644
index 00000000000000..5004725536e98a
--- /dev/null
+++ b/clang/test/Driver/clang-sycl-link-wrapper-test.cpp
@@ -0,0 +1,9 @@
+// Tests the clang-sycl-link-wrapper tool
+//
+// Test a simple case without arguments
+// RUN: %clangxx -fsycl -emit-llvm -c %s -o %t.bc
+// RUN: clang-sycl-link-wrapper --dry-run -triple spirv64 %t.bc --library-path=%S/Inputs -o a.spv 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CMDS
+// CMDS: "{{.*}}llvm-link{{.*}}" {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
+// CMDS-NEXT: "{{.*}}llvm-link{{.*}}" -only-needed [[FIRSTLLVMLINKOUT]].bc {{.*}}libsycl-crt.bc {{.*}}libsycl-complex.bc -o [[SECONDLLVMLINKOUT:.*]].bc --suppress-warnings
+// CMDS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
diff --git a/clang/test/Driver/sycl-link-spirv-target.cpp b/clang/test/Driver/sycl-link-spirv-target.cpp
new file mode 100644
index 00000000000000..550d40aac5499d
--- /dev/null
+++ b/clang/test/Driver/sycl-link-spirv-target.cpp
@@ -0,0 +1,7 @@
+// Tests the driver when linking LLVM IR bitcode files and targeting SPIR-V
+// architecture.
+//
+// RUN: touch %t.bc
+// RUN: %clangxx --target=spirv64 --sycl-link -### %t.bc 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=LINK
+// LINK: "{{.*}}clang-sycl-link-wrapper{{.*}}" "{{.*}}.bc" "-o" "a.out"
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 88e29412e54350..d704ca5c62c97b 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -12,6 +12,7 @@ add_clang_subdirectory(clang-nvlink-wrapper)
 add_clang_subdirectory(clang-offload-packager)
 add_clang_subdirectory(clang-offload-bundler)
 add_clang_subdirectory(clang-scan-deps)
+add_clang_subdirectory(clang-sycl-link-wrapper)
 add_clang_subdirectory(clang-installapi)
 if(HAVE_CLANG_REPL_SUPPORT)
   add_clang_subdirectory(clang-repl)
diff --git a/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt b/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt
new file mode 100644
index 00000000000000..c51f6f977dddd7
--- /dev/null
+++ b/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt
@@ -0,0 +1,28 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Option
+  )
+
+set(LLVM_TARGET_DEFINITIONS SYCLLinkOpts.td)
+tablegen(LLVM SYCLLinkOpts.inc -gen-opt-parser-defs)
+add_public_tablegen_target(SYCLLinkWrapperOpts)
+
+if(NOT CLANG_BUILT_STANDALONE)
+  set(tablegen_deps intrinsics_gen SYCLLinkWrapperOpts)
+endif()
+
+add_clang_tool(clang-sycl-link-wrapper
+  ClangSYCLLinkWrapper.cpp
+
+  DEPENDS
+  ${tablegen_deps}
+  )
+
+set(CLANG_SYCL_LINK_WRAPPER_LIB_DEPS
+  clangBasic
+  )
+
+target_link_libraries(clang-sycl-link-wrapper
+  PRIVATE
+  ${CLANG_SYCL_LINK_WRAPPER_LIB_DEPS}
+  )
diff --git a/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp b/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp
new file mode 100644
index 00000000000000..31afa26c46518d
--- /dev/null
+++ b/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp
@@ -0,0 +1,530 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===---------------------------------------------------------------------===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector<SmallString<128>> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)                                                    \
+  static constexpr StringLiteral NAME##_init[] = VALUE;                        \
+  static constexpr ArrayRef<StringLiteral> NAME(NAME##_init,                   \
+                                                std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {
+#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+#undef OPTION
+};
+
+class WrapperOptTable : public opt::GenericOptTable {
+public:
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
+};
+
+const OptTable &getOptTable() {
+  static const WrapperOptTable *Table = []() {
+    auto Result = std::make_unique<WrapperOptTable>();
+    return Result.release();
+  }();
+  return *Table;
+}
+
+[[noreturn]] void reportError(Error E) {
+  outs().flush();
+  logAllUnhandledErrors(std::move(E), WithColor::error(errs(), Executable));
+  exit(EXIT_FAILURE);
+}
+
+std::string getMainExecutable(const char *Name) {
+  void *Ptr = (void *)(intptr_t)&getMainExecutable;
+  auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+  return sys::path::parent_path(COWPath).str();
+}
+
+Expected<StringRef> createTempFile(const ArgList &Args, const Twine &Prefix,
+                                   StringRef Extension) {
+  SmallString<128> OutputFile;
+  if (Args.hasArg(OPT_save_temps)) {
+    // Generate a unique path name without creating a file
+    sys::fs::createUniquePath(Prefix + "-%%%%%%." + Extension, OutputFile,
+                              /*MakeAbsolute=*/false);
+  } else {
+    if (std::error_code EC =
+            sys::fs::createTemporaryFile(Prefix, Extension, OutputFile))
+      return createFileError(OutputFile, EC);
+  }
+
+  TempFiles.emplace_back(std::move(OutputFile));
+  return TempFiles.back();
+}
+
+Expected<std::string> findProgram(const ArgList &Args, StringRef Name,
+                                  ArrayRef<StringRef> Paths) {
+  if (Args.hasArg(OPT_dry_run))
+    return Name.str();
+  ErrorOr<std::string> Path = sys::findProgramByName(Name, Paths);
+  if (!Path)
+    Path = sys::findProgramByName(Name);
+  if (!Path)
+    return createStringError(Path.getError(),
+                             "Unable to find '" + Name + "' in path");
+  return *Path;
+}
+
+std::optional<std::string> findFile(StringRef Dir, StringRef Root,
+                                    const Twine &Name) {
+  SmallString<128> Path;
+  if (Dir.starts_with("="))
+    sys::path::append(Path, Root, Dir.substr(1), Name);
+  else
+    sys::path::append(Path, Dir, Name);
+
+  if (sys::fs::exists(Path))
+    return static_cast<std::string>(Path);
+  return std::nullopt;
+}
+
+void printCommands(ArrayRef<StringRef> CmdArgs) {
+  if (CmdArgs.empty())
+    return;
+
+  llvm::errs() << " \"" << CmdArgs.front() << "\" ";
+  llvm::errs() << llvm::join(std::next(CmdArgs.begin()), CmdArgs.end(), " ")
+               << "\n";
+}
+
+/// Execute the command \p ExecutablePath with the arguments \p Args.
+Error executeCommands(StringRef ExecutablePath, ArrayRef<StringRef> Args) {
+  if (Verbose || DryRun)
+    printCommands(Args);
+
+  if (!DryRun)
+    if (sys::ExecuteAndWait(ExecutablePath, Args))
+      return createStringError(
+          "'%s' failed", sys::path::filename(ExecutablePath).str().c_str());
+  return Error::success();
+}
+
+Expected<SmallVector<std::string>> getInput(const ArgList &Args) {
+  // Collect all input bitcode files to be passed to llvm-link.
+  SmallVector<std::string> BitcodeFiles;
+  for (const opt::Arg *Arg : Args.filtered(OPT_INPUT)) {
+    std::optional<std::string> Filename = std::string(Arg->getValue());
+    if (!Filename || !sys::fs::exists(*Filename) ||
+        sys::fs::is_directory(*Filename))
+      continue;
+    file_magic Magic;
+    if (auto EC = identify_magic(*Filename, Magic))
+      return createStringError("Failed to open file " + *Filename);
+    if (Magic != file_magic::bitcode)
+      return createStringError("Unsupported file type");
+    BitcodeFiles.push_back(*Filename);
+  }
+  return BitcodeFiles;
+}
+
+/// Link all SYCL device input files into one before adding device library
+/// files. Device linking is performed using llvm-link tool.
+/// 'InputFiles' is the list of all LLVM IR device input files.
+/// 'Args' encompasses all arguments required for linking and wrapping device
+/// code and will be parsed to generate options required to be passed into the
+/// llvm-link tool.
+Expected<StringRef> linkDeviceInputFiles(ArrayRef<std::string> InputFiles,
+                                         const ArgList &Args) {
+  llvm::TimeTraceScope TimeScope("SYCL LinkDeviceInputFiles");
+  Expected<std::string> LLVMLinkPath =
+      findProgram(Args, "llvm-link", {getMainExecutable("llvm-link")});
+  if (!LLVMLinkPath)
+    return LLVMLinkPath.takeError();
+
+  SmallVector<StringRef> CmdArgs;
+  CmdArgs.push_back(*LLVMLinkPath);
+  for (auto &File : InputFiles)
+    CmdArgs.push_back(File);
+  // Create a new file to write the linked device file to.
+  auto OutFileOrErr =
+      createTempFile(Args, sys::path::filename(OutputFile), "bc");
+  if (!OutFileOrErr)
+    return OutFileOrErr.takeError();
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(*OutFileOrErr);
+  CmdArgs.push_back("--suppress-warnings");
+  if (Error Err = executeCommands(*LLVMLinkPath, CmdArgs))
+    return std::move(Err);
+  return *OutFileOrErr;
+}
+
+const SmallVector<std::string> SYCLDeviceLibNames = {
+    "libsycl-crt.bc",
+    "libsycl-complex.bc",
+    "libsycl-complex-fp64.bc",
+    "libsycl-cmath.bc",
+    "libsycl-cmath-fp64.bc",
+    "libsycl-imf.bc",
+    "libsycl-imf-fp64.bc",
+    "libsycl-imf-bf16.bc",
+    "libsycl-fallback-cassert.bc",
+    "libsycl-fallback-cstring.bc",
+    "libsycl-fallback-complex.bc",
+    "libsycl-fallback-complex-fp64.bc",
+    "libsycl-fallback-cmath.bc",
+    "libsycl-fallback-cmath-fp64.bc",
+    "libsycl-fallback-imf.bc",
+    "libsy...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2024

@llvm/pr-subscribers-clang-driver

Author: Arvind Sudarsanam (asudarsa)

Changes

This PR is one of the many PRs in the SYCL upstreaming effort focusing on device code linking during the SYCL offload compilation process. RFC: https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device code linking for SYCL offload kind. It accepts SYCL device objects in LLVM IR bitcode format and will generate a fully linked device object that can then be wrapped and linked into the host object.

A primary use case for this tool is to perform device code linking for objects with SYCL offload kind inside the clang-linker-wrapper. It can also be invoked via clang driver as follows:

clang --target=spirv64 --sycl-link input.bc

Device code linking for SYCL offloading kind has a number of known quirks that makes it difficult to use in a unified offloading setting. Two of the primary issues are:

  1. Several finalization steps are required to be run on the fully-linked LLVM IR bitcode to gaurantee conformance to SYCL standards. This step is unique to SYCL offloading compilation flow.
  2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR code generation cannot be done as part of LTO. This limitation will be lifted once SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform SYCL device linking.

Thanks


Patch is 32.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/112245.diff

14 Files Affected:

  • (added) clang/docs/ClangSYCLLinkWrapper.rst (+80)
  • (modified) clang/docs/index.rst (+1)
  • (modified) clang/include/clang/Driver/Options.td (+4-1)
  • (modified) clang/lib/Driver/Driver.cpp (+5)
  • (modified) clang/lib/Driver/ToolChains/SPIRV.cpp (+12)
  • (modified) clang/lib/Driver/ToolChains/SPIRV.h (+3-2)
  • (added) clang/test/Driver/Inputs/libsycl-complex.bc ()
  • (added) clang/test/Driver/Inputs/libsycl-crt.bc ()
  • (added) clang/test/Driver/clang-sycl-link-wrapper-test.cpp (+9)
  • (added) clang/test/Driver/sycl-link-spirv-target.cpp (+7)
  • (modified) clang/tools/CMakeLists.txt (+1)
  • (added) clang/tools/clang-sycl-link-wrapper/CMakeLists.txt (+28)
  • (added) clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp (+530)
  • (added) clang/tools/clang-sycl-link-wrapper/SYCLLinkOpts.td (+47)
diff --git a/clang/docs/ClangSYCLLinkWrapper.rst b/clang/docs/ClangSYCLLinkWrapper.rst
new file mode 100644
index 00000000000000..8ceb17f6af9d86
--- /dev/null
+++ b/clang/docs/ClangSYCLLinkWrapper.rst
@@ -0,0 +1,80 @@
+=======================
+Clang SYCL Link Wrapper
+=======================
+
+.. contents::
+   :local:
+
+.. _clang-sycl-link-wrapper:
+
+Introduction
+============
+
+This tool works as a wrapper around the SYCL device code linking process.
+The purpose of this wrapper is to provide an interface to link SYCL device
+bitcode in LLVM IR format, SYCL device bitcode in SPIR-V IR format, and native
+binary objects, and then use the SPIR-V LLVM Translator tool on fully linked
+device objects to produce the final output.
+After the linking stage, the fully linked device code in LLVM IR format may
+undergo several SYCL-specific finalization steps before the SPIR-V code
+generation step.
+The wrapper will also support the Ahead-Of-Time (AOT) compilation flow. AOT
+compilation is the process of invoking the back-end at compile time to produce
+the final binary, as opposed to just-in-time (JIT) compilation when final code
+generation is deferred until application runtime.
+
+Device code linking for SYCL offloading has several known quirks that
+make it difficult to use in a unified offloading setting. Two of the primary
+issues are:
+1. Several finalization steps are required to be run on the fully linked LLVM
+IR bitcode to guarantee conformance to SYCL standards. This step is unique to
+the SYCL offloading compilation flow.
+2. The SPIR-V LLVM Translator tool is an external tool and hence SPIR-V IR code
+generation cannot be done as part of LTO. This limitation can be lifted once
+the SPIR-V backend is available as a viable LLVM backend.
+
+This tool has been proposed to work around these issues.
+
+Usage
+=====
+
+This tool can be used with the following options. Several of these options will
+be passed down to downstream tools like 'llvm-link', 'llvm-spirv', etc.
+
+.. code-block:: console
+
+  OVERVIEW: A utility that wraps around the SYCL device code linking process.
+  This enables linking and code generation for SPIR-V JIT targets and AOT
+  targets.
+
+  USAGE: clang-sycl-link-wrapper [options]
+
+  OPTIONS:
+    --arch <value>                Specify the name of the target architecture.
+    --dry-run                     Print generated commands without running.
+    -g                            Specify that this was a debug compile.
+    -help-hidden                  Display all available options
+    -help                         Display available options (--help-hidden for more)
+    --library-path=<dir>          Set the library path for SYCL device libraries
+    -o <path>                     Path to file to write output
+    --save-temps                  Save intermediate results
+    --triple <value>              Specify the target triple.
+    --version                     Display the version number and exit
+    -v                            Print verbose information
+    -spirv-dump-device-code=<dir> Directory to dump SPIR-V IR code into
+    -is-windows-msvc-env          Specify if we are compiling under windows environment
+    -llvm-spirv-options=<value>   Pass options to llvm-spirv tool
+
+Example
+=======
+
+This tool is intended to be invoked when targeting any of the target offloading
+toolchains. When the --sycl-link option is passed to the clang driver, the
+driver will invoke the linking job of the target offloading toolchain, which in
+turn will invoke this tool. This tool can be used to create one or more fully
+linked device images that are ready to be wrapped and linked with host code to
+generate the final executable.
+
+.. code-block:: console
+
+  clang-sycl-link-wrapper --triple spirv64 --arch native input.bc
diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4a497f4d9bcc3c..ccdc16d3e07699 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -97,6 +97,7 @@ Using Clang Tools
    ClangOffloadBundler
    ClangOffloadPackager
    ClangRepl
+   ClangSYCLLinkWrapper
 
 Design Documents
 ================
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 3f4d1a328b4c27..245af5a539a4fa 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6728,7 +6728,10 @@ def fsycl : Flag<["-"], "fsycl">,
 def fno_sycl : Flag<["-"], "fno-sycl">,
   Visibility<[ClangOption, CLOption]>,
   Group<sycl_Group>, HelpText<"Disables SYCL kernels compilation for device">;
-
+def sycl_link : Flag<["--"], "sycl-link">, Flags<[HelpHidden]>,
+  Visibility<[ClangOption, CLOption]>,
+  Group<sycl_Group>, HelpText<"Perform link through clang-sycl-link-wrapper via the target "
+  "offloading toolchain.">;
 // OS-specific options
 let Flags = [TargetSpecific] in {
 defm android_pad_segment : BooleanFFlag<"android-pad-segment">, Group<f_Group>;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d0c8bdba0ede95..184eafa137b178 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4780,6 +4780,11 @@ Action *Driver::ConstructPhaseAction(
   if (Phase == phases::Assemble && Input->getType() != types::TY_PP_Asm)
     return Input;
 
+  // Use of --sycl-link will only allow for the link phase to occur. This is
+  // for all input files.
+  if (Args.hasArg(options::OPT_sycl_link) && Phase != phases::Link)
+    return Input;
+
   // Build the appropriate action.
   switch (Phase) {
   case phases::Link:
diff --git a/clang/lib/Driver/ToolChains/SPIRV.cpp b/clang/lib/Driver/ToolChains/SPIRV.cpp
index ce900600cbee51..860fd932a58718 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRV.cpp
@@ -95,7 +95,19 @@ void SPIRV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  // Use of --sycl-link will call the clang-sycl-link-wrapper instead of
+  // the default linker (spirv-link).
+  if (Args.hasArg(options::OPT_sycl_link))
+    Linker = ToolChain.GetProgramPath("clang-sycl-link-wrapper");
   C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
                                          Args.MakeArgString(Linker), CmdArgs,
                                          Inputs, Output));
 }
+
+SPIRVToolChain::SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
+                               const ArgList &Args)
+    : ToolChain(D, Triple, Args) {
+  NativeLLVMSupport = Args.hasArg(options::OPT_sycl_link);
+}
+
+bool SPIRVToolChain::HasNativeLLVMSupport() const { return NativeLLVMSupport; }
diff --git a/clang/lib/Driver/ToolChains/SPIRV.h b/clang/lib/Driver/ToolChains/SPIRV.h
index d4247ee0557f4b..d59a8c76ed4737 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.h
+++ b/clang/lib/Driver/ToolChains/SPIRV.h
@@ -57,8 +57,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
 
 public:
   SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
-                 const llvm::opt::ArgList &Args)
-      : ToolChain(D, Triple, Args) {}
+                 const llvm::opt::ArgList &Args);
 
   bool useIntegratedAs() const override { return true; }
 
@@ -72,6 +71,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
   }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
+  bool HasNativeLLVMSupport() const override;
 
   clang::driver::Tool *SelectTool(const JobAction &JA) const override;
 
@@ -81,6 +81,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
 
 private:
   clang::driver::Tool *getTranslator() const;
+  bool NativeLLVMSupport;
 };
 
 } // namespace toolchains
diff --git a/clang/test/Driver/Inputs/libsycl-complex.bc b/clang/test/Driver/Inputs/libsycl-complex.bc
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/libsycl-crt.bc b/clang/test/Driver/Inputs/libsycl-crt.bc
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/clang-sycl-link-wrapper-test.cpp b/clang/test/Driver/clang-sycl-link-wrapper-test.cpp
new file mode 100644
index 00000000000000..5004725536e98a
--- /dev/null
+++ b/clang/test/Driver/clang-sycl-link-wrapper-test.cpp
@@ -0,0 +1,9 @@
+// Tests the clang-sycl-link-wrapper tool
+//
+// Test a simple case without arguments
+// RUN: %clangxx -fsycl -emit-llvm -c %s -o %t.bc
+// RUN: clang-sycl-link-wrapper --dry-run -triple spirv64 %t.bc --library-path=%S/Inputs -o a.spv 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CMDS
+// CMDS: "{{.*}}llvm-link{{.*}}" {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
+// CMDS-NEXT: "{{.*}}llvm-link{{.*}}" -only-needed [[FIRSTLLVMLINKOUT]].bc {{.*}}libsycl-crt.bc {{.*}}libsycl-complex.bc -o [[SECONDLLVMLINKOUT:.*]].bc --suppress-warnings
+// CMDS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
diff --git a/clang/test/Driver/sycl-link-spirv-target.cpp b/clang/test/Driver/sycl-link-spirv-target.cpp
new file mode 100644
index 00000000000000..550d40aac5499d
--- /dev/null
+++ b/clang/test/Driver/sycl-link-spirv-target.cpp
@@ -0,0 +1,7 @@
+// Tests the driver when linking LLVM IR bitcode files and targeting SPIR-V
+// architecture.
+//
+// RUN: touch %t.bc
+// RUN: %clangxx --target=spirv64 --sycl-link -### %t.bc 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=LINK
+// LINK: "{{.*}}clang-sycl-link-wrapper{{.*}}" "{{.*}}.bc" "-o" "a.out"
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 88e29412e54350..d704ca5c62c97b 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -12,6 +12,7 @@ add_clang_subdirectory(clang-nvlink-wrapper)
 add_clang_subdirectory(clang-offload-packager)
 add_clang_subdirectory(clang-offload-bundler)
 add_clang_subdirectory(clang-scan-deps)
+add_clang_subdirectory(clang-sycl-link-wrapper)
 add_clang_subdirectory(clang-installapi)
 if(HAVE_CLANG_REPL_SUPPORT)
   add_clang_subdirectory(clang-repl)
diff --git a/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt b/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt
new file mode 100644
index 00000000000000..c51f6f977dddd7
--- /dev/null
+++ b/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt
@@ -0,0 +1,28 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Option
+  )
+
+set(LLVM_TARGET_DEFINITIONS SYCLLinkOpts.td)
+tablegen(LLVM SYCLLinkOpts.inc -gen-opt-parser-defs)
+add_public_tablegen_target(SYCLLinkWrapperOpts)
+
+if(NOT CLANG_BUILT_STANDALONE)
+  set(tablegen_deps intrinsics_gen SYCLLinkWrapperOpts)
+endif()
+
+add_clang_tool(clang-sycl-link-wrapper
+  ClangSYCLLinkWrapper.cpp
+
+  DEPENDS
+  ${tablegen_deps}
+  )
+
+set(CLANG_SYCL_LINK_WRAPPER_LIB_DEPS
+  clangBasic
+  )
+
+target_link_libraries(clang-sycl-link-wrapper
+  PRIVATE
+  ${CLANG_SYCL_LINK_WRAPPER_LIB_DEPS}
+  )
diff --git a/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp b/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp
new file mode 100644
index 00000000000000..31afa26c46518d
--- /dev/null
+++ b/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp
@@ -0,0 +1,530 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===---------------------------------------------------------------------===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector<SmallString<128>> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)                                                    \
+  static constexpr StringLiteral NAME##_init[] = VALUE;                        \
+  static constexpr ArrayRef<StringLiteral> NAME(NAME##_init,                   \
+                                                std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {
+#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+#undef OPTION
+};
+
+class WrapperOptTable : public opt::GenericOptTable {
+public:
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
+};
+
+const OptTable &getOptTable() {
+  static const WrapperOptTable *Table = []() {
+    auto Result = std::make_unique<WrapperOptTable>();
+    return Result.release();
+  }();
+  return *Table;
+}
+
+[[noreturn]] void reportError(Error E) {
+  outs().flush();
+  logAllUnhandledErrors(std::move(E), WithColor::error(errs(), Executable));
+  exit(EXIT_FAILURE);
+}
+
+std::string getMainExecutable(const char *Name) {
+  void *Ptr = (void *)(intptr_t)&getMainExecutable;
+  auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+  return sys::path::parent_path(COWPath).str();
+}
+
+Expected<StringRef> createTempFile(const ArgList &Args, const Twine &Prefix,
+                                   StringRef Extension) {
+  SmallString<128> OutputFile;
+  if (Args.hasArg(OPT_save_temps)) {
+    // Generate a unique path name without creating a file
+    sys::fs::createUniquePath(Prefix + "-%%%%%%." + Extension, OutputFile,
+                              /*MakeAbsolute=*/false);
+  } else {
+    if (std::error_code EC =
+            sys::fs::createTemporaryFile(Prefix, Extension, OutputFile))
+      return createFileError(OutputFile, EC);
+  }
+
+  TempFiles.emplace_back(std::move(OutputFile));
+  return TempFiles.back();
+}
+
+Expected<std::string> findProgram(const ArgList &Args, StringRef Name,
+                                  ArrayRef<StringRef> Paths) {
+  if (Args.hasArg(OPT_dry_run))
+    return Name.str();
+  ErrorOr<std::string> Path = sys::findProgramByName(Name, Paths);
+  if (!Path)
+    Path = sys::findProgramByName(Name);
+  if (!Path)
+    return createStringError(Path.getError(),
+                             "Unable to find '" + Name + "' in path");
+  return *Path;
+}
+
+std::optional<std::string> findFile(StringRef Dir, StringRef Root,
+                                    const Twine &Name) {
+  SmallString<128> Path;
+  if (Dir.starts_with("="))
+    sys::path::append(Path, Root, Dir.substr(1), Name);
+  else
+    sys::path::append(Path, Dir, Name);
+
+  if (sys::fs::exists(Path))
+    return static_cast<std::string>(Path);
+  return std::nullopt;
+}
+
+void printCommands(ArrayRef<StringRef> CmdArgs) {
+  if (CmdArgs.empty())
+    return;
+
+  llvm::errs() << " \"" << CmdArgs.front() << "\" ";
+  llvm::errs() << llvm::join(std::next(CmdArgs.begin()), CmdArgs.end(), " ")
+               << "\n";
+}
+
+/// Execute the command \p ExecutablePath with the arguments \p Args.
+Error executeCommands(StringRef ExecutablePath, ArrayRef<StringRef> Args) {
+  if (Verbose || DryRun)
+    printCommands(Args);
+
+  if (!DryRun)
+    if (sys::ExecuteAndWait(ExecutablePath, Args))
+      return createStringError(
+          "'%s' failed", sys::path::filename(ExecutablePath).str().c_str());
+  return Error::success();
+}
+
+Expected<SmallVector<std::string>> getInput(const ArgList &Args) {
+  // Collect all input bitcode files to be passed to llvm-link.
+  SmallVector<std::string> BitcodeFiles;
+  for (const opt::Arg *Arg : Args.filtered(OPT_INPUT)) {
+    std::optional<std::string> Filename = std::string(Arg->getValue());
+    if (!Filename || !sys::fs::exists(*Filename) ||
+        sys::fs::is_directory(*Filename))
+      continue;
+    file_magic Magic;
+    if (auto EC = identify_magic(*Filename, Magic))
+      return createStringError("Failed to open file " + *Filename);
+    if (Magic != file_magic::bitcode)
+      return createStringError("Unsupported file type");
+    BitcodeFiles.push_back(*Filename);
+  }
+  return BitcodeFiles;
+}
+
+/// Link all SYCL device input files into one before adding device library
+/// files. Device linking is performed using llvm-link tool.
+/// 'InputFiles' is the list of all LLVM IR device input files.
+/// 'Args' encompasses all arguments required for linking and wrapping device
+/// code and will be parsed to generate options required to be passed into the
+/// llvm-link tool.
+Expected<StringRef> linkDeviceInputFiles(ArrayRef<std::string> InputFiles,
+                                         const ArgList &Args) {
+  llvm::TimeTraceScope TimeScope("SYCL LinkDeviceInputFiles");
+  Expected<std::string> LLVMLinkPath =
+      findProgram(Args, "llvm-link", {getMainExecutable("llvm-link")});
+  if (!LLVMLinkPath)
+    return LLVMLinkPath.takeError();
+
+  SmallVector<StringRef> CmdArgs;
+  CmdArgs.push_back(*LLVMLinkPath);
+  for (auto &File : InputFiles)
+    CmdArgs.push_back(File);
+  // Create a new file to write the linked device file to.
+  auto OutFileOrErr =
+      createTempFile(Args, sys::path::filename(OutputFile), "bc");
+  if (!OutFileOrErr)
+    return OutFileOrErr.takeError();
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(*OutFileOrErr);
+  CmdArgs.push_back("--suppress-warnings");
+  if (Error Err = executeCommands(*LLVMLinkPath, CmdArgs))
+    return std::move(Err);
+  return *OutFileOrErr;
+}
+
+const SmallVector<std::string> SYCLDeviceLibNames = {
+    "libsycl-crt.bc",
+    "libsycl-complex.bc",
+    "libsycl-complex-fp64.bc",
+    "libsycl-cmath.bc",
+    "libsycl-cmath-fp64.bc",
+    "libsycl-imf.bc",
+    "libsycl-imf-fp64.bc",
+    "libsycl-imf-bf16.bc",
+    "libsycl-fallback-cassert.bc",
+    "libsycl-fallback-cstring.bc",
+    "libsycl-fallback-complex.bc",
+    "libsycl-fallback-complex-fp64.bc",
+    "libsycl-fallback-cmath.bc",
+    "libsycl-fallback-cmath-fp64.bc",
+    "libsycl-fallback-imf.bc",
+    "libsy...
[truncated]

@llvmbot
Copy link
Member

llvmbot commented Oct 14, 2024

@llvm/pr-subscribers-clang

Author: Arvind Sudarsanam (asudarsa)

Changes

This PR is one of the many PRs in the SYCL upstreaming effort focusing on device code linking during the SYCL offload compilation process. RFC: https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device code linking for SYCL offload kind. It accepts SYCL device objects in LLVM IR bitcode format and will generate a fully linked device object that can then be wrapped and linked into the host object.

A primary use case for this tool is to perform device code linking for objects with SYCL offload kind inside the clang-linker-wrapper. It can also be invoked via clang driver as follows:

clang --target=spirv64 --sycl-link input.bc

Device code linking for SYCL offloading kind has a number of known quirks that makes it difficult to use in a unified offloading setting. Two of the primary issues are:

  1. Several finalization steps are required to be run on the fully-linked LLVM IR bitcode to gaurantee conformance to SYCL standards. This step is unique to SYCL offloading compilation flow.
  2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR code generation cannot be done as part of LTO. This limitation will be lifted once SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform SYCL device linking.

Thanks


Patch is 32.39 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/112245.diff

14 Files Affected:

  • (added) clang/docs/ClangSYCLLinkWrapper.rst (+80)
  • (modified) clang/docs/index.rst (+1)
  • (modified) clang/include/clang/Driver/Options.td (+4-1)
  • (modified) clang/lib/Driver/Driver.cpp (+5)
  • (modified) clang/lib/Driver/ToolChains/SPIRV.cpp (+12)
  • (modified) clang/lib/Driver/ToolChains/SPIRV.h (+3-2)
  • (added) clang/test/Driver/Inputs/libsycl-complex.bc ()
  • (added) clang/test/Driver/Inputs/libsycl-crt.bc ()
  • (added) clang/test/Driver/clang-sycl-link-wrapper-test.cpp (+9)
  • (added) clang/test/Driver/sycl-link-spirv-target.cpp (+7)
  • (modified) clang/tools/CMakeLists.txt (+1)
  • (added) clang/tools/clang-sycl-link-wrapper/CMakeLists.txt (+28)
  • (added) clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp (+530)
  • (added) clang/tools/clang-sycl-link-wrapper/SYCLLinkOpts.td (+47)
diff --git a/clang/docs/ClangSYCLLinkWrapper.rst b/clang/docs/ClangSYCLLinkWrapper.rst
new file mode 100644
index 00000000000000..8ceb17f6af9d86
--- /dev/null
+++ b/clang/docs/ClangSYCLLinkWrapper.rst
@@ -0,0 +1,80 @@
+=======================
+Clang SYCL Link Wrapper
+=======================
+
+.. contents::
+   :local:
+
+.. _clang-sycl-link-wrapper:
+
+Introduction
+============
+
+This tool works as a wrapper around the SYCL device code linking process.
+The purpose of this wrapper is to provide an interface to link SYCL device
+bitcode in LLVM IR format, SYCL device bitcode in SPIR-V IR format, and native
+binary objects, and then use the SPIR-V LLVM Translator tool on fully linked
+device objects to produce the final output.
+After the linking stage, the fully linked device code in LLVM IR format may
+undergo several SYCL-specific finalization steps before the SPIR-V code
+generation step.
+The wrapper will also support the Ahead-Of-Time (AOT) compilation flow. AOT
+compilation is the process of invoking the back-end at compile time to produce
+the final binary, as opposed to just-in-time (JIT) compilation when final code
+generation is deferred until application runtime.
+
+Device code linking for SYCL offloading has several known quirks that
+make it difficult to use in a unified offloading setting. Two of the primary
+issues are:
+1. Several finalization steps are required to be run on the fully linked LLVM
+IR bitcode to guarantee conformance to SYCL standards. This step is unique to
+the SYCL offloading compilation flow.
+2. The SPIR-V LLVM Translator tool is an external tool and hence SPIR-V IR code
+generation cannot be done as part of LTO. This limitation can be lifted once
+the SPIR-V backend is available as a viable LLVM backend.
+
+This tool has been proposed to work around these issues.
+
+Usage
+=====
+
+This tool can be used with the following options. Several of these options will
+be passed down to downstream tools like 'llvm-link', 'llvm-spirv', etc.
+
+.. code-block:: console
+
+  OVERVIEW: A utility that wraps around the SYCL device code linking process.
+  This enables linking and code generation for SPIR-V JIT targets and AOT
+  targets.
+
+  USAGE: clang-sycl-link-wrapper [options]
+
+  OPTIONS:
+    --arch <value>                Specify the name of the target architecture.
+    --dry-run                     Print generated commands without running.
+    -g                            Specify that this was a debug compile.
+    -help-hidden                  Display all available options
+    -help                         Display available options (--help-hidden for more)
+    --library-path=<dir>          Set the library path for SYCL device libraries
+    -o <path>                     Path to file to write output
+    --save-temps                  Save intermediate results
+    --triple <value>              Specify the target triple.
+    --version                     Display the version number and exit
+    -v                            Print verbose information
+    -spirv-dump-device-code=<dir> Directory to dump SPIR-V IR code into
+    -is-windows-msvc-env          Specify if we are compiling under windows environment
+    -llvm-spirv-options=<value>   Pass options to llvm-spirv tool
+
+Example
+=======
+
+This tool is intended to be invoked when targeting any of the target offloading
+toolchains. When the --sycl-link option is passed to the clang driver, the
+driver will invoke the linking job of the target offloading toolchain, which in
+turn will invoke this tool. This tool can be used to create one or more fully
+linked device images that are ready to be wrapped and linked with host code to
+generate the final executable.
+
+.. code-block:: console
+
+  clang-sycl-link-wrapper --triple spirv64 --arch native input.bc
diff --git a/clang/docs/index.rst b/clang/docs/index.rst
index 4a497f4d9bcc3c..ccdc16d3e07699 100644
--- a/clang/docs/index.rst
+++ b/clang/docs/index.rst
@@ -97,6 +97,7 @@ Using Clang Tools
    ClangOffloadBundler
    ClangOffloadPackager
    ClangRepl
+   ClangSYCLLinkWrapper
 
 Design Documents
 ================
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 3f4d1a328b4c27..245af5a539a4fa 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -6728,7 +6728,10 @@ def fsycl : Flag<["-"], "fsycl">,
 def fno_sycl : Flag<["-"], "fno-sycl">,
   Visibility<[ClangOption, CLOption]>,
   Group<sycl_Group>, HelpText<"Disables SYCL kernels compilation for device">;
-
+def sycl_link : Flag<["--"], "sycl-link">, Flags<[HelpHidden]>,
+  Visibility<[ClangOption, CLOption]>,
+  Group<sycl_Group>, HelpText<"Perform link through clang-sycl-link-wrapper via the target "
+  "offloading toolchain.">;
 // OS-specific options
 let Flags = [TargetSpecific] in {
 defm android_pad_segment : BooleanFFlag<"android-pad-segment">, Group<f_Group>;
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d0c8bdba0ede95..184eafa137b178 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4780,6 +4780,11 @@ Action *Driver::ConstructPhaseAction(
   if (Phase == phases::Assemble && Input->getType() != types::TY_PP_Asm)
     return Input;
 
+  // Use of --sycl-link will only allow for the link phase to occur. This is
+  // for all input files.
+  if (Args.hasArg(options::OPT_sycl_link) && Phase != phases::Link)
+    return Input;
+
   // Build the appropriate action.
   switch (Phase) {
   case phases::Link:
diff --git a/clang/lib/Driver/ToolChains/SPIRV.cpp b/clang/lib/Driver/ToolChains/SPIRV.cpp
index ce900600cbee51..860fd932a58718 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRV.cpp
@@ -95,7 +95,19 @@ void SPIRV::Linker::ConstructJob(Compilation &C, const JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
+  // Use of --sycl-link will call the clang-sycl-link-wrapper instead of
+  // the default linker (spirv-link).
+  if (Args.hasArg(options::OPT_sycl_link))
+    Linker = ToolChain.GetProgramPath("clang-sycl-link-wrapper");
   C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
                                          Args.MakeArgString(Linker), CmdArgs,
                                          Inputs, Output));
 }
+
+SPIRVToolChain::SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
+                               const ArgList &Args)
+    : ToolChain(D, Triple, Args) {
+  NativeLLVMSupport = Args.hasArg(options::OPT_sycl_link);
+}
+
+bool SPIRVToolChain::HasNativeLLVMSupport() const { return NativeLLVMSupport; }
diff --git a/clang/lib/Driver/ToolChains/SPIRV.h b/clang/lib/Driver/ToolChains/SPIRV.h
index d4247ee0557f4b..d59a8c76ed4737 100644
--- a/clang/lib/Driver/ToolChains/SPIRV.h
+++ b/clang/lib/Driver/ToolChains/SPIRV.h
@@ -57,8 +57,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
 
 public:
   SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
-                 const llvm::opt::ArgList &Args)
-      : ToolChain(D, Triple, Args) {}
+                 const llvm::opt::ArgList &Args);
 
   bool useIntegratedAs() const override { return true; }
 
@@ -72,6 +71,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
   }
   bool isPICDefaultForced() const override { return false; }
   bool SupportsProfiling() const override { return false; }
+  bool HasNativeLLVMSupport() const override;
 
   clang::driver::Tool *SelectTool(const JobAction &JA) const override;
 
@@ -81,6 +81,7 @@ class LLVM_LIBRARY_VISIBILITY SPIRVToolChain final : public ToolChain {
 
 private:
   clang::driver::Tool *getTranslator() const;
+  bool NativeLLVMSupport;
 };
 
 } // namespace toolchains
diff --git a/clang/test/Driver/Inputs/libsycl-complex.bc b/clang/test/Driver/Inputs/libsycl-complex.bc
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/Inputs/libsycl-crt.bc b/clang/test/Driver/Inputs/libsycl-crt.bc
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/clang/test/Driver/clang-sycl-link-wrapper-test.cpp b/clang/test/Driver/clang-sycl-link-wrapper-test.cpp
new file mode 100644
index 00000000000000..5004725536e98a
--- /dev/null
+++ b/clang/test/Driver/clang-sycl-link-wrapper-test.cpp
@@ -0,0 +1,9 @@
+// Tests the clang-sycl-link-wrapper tool
+//
+// Test a simple case without arguments
+// RUN: %clangxx -fsycl -emit-llvm -c %s -o %t.bc
+// RUN: clang-sycl-link-wrapper --dry-run -triple spirv64 %t.bc --library-path=%S/Inputs -o a.spv 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CMDS
+// CMDS: "{{.*}}llvm-link{{.*}}" {{.*}}.bc -o [[FIRSTLLVMLINKOUT:.*]].bc --suppress-warnings
+// CMDS-NEXT: "{{.*}}llvm-link{{.*}}" -only-needed [[FIRSTLLVMLINKOUT]].bc {{.*}}libsycl-crt.bc {{.*}}libsycl-complex.bc -o [[SECONDLLVMLINKOUT:.*]].bc --suppress-warnings
+// CMDS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
diff --git a/clang/test/Driver/sycl-link-spirv-target.cpp b/clang/test/Driver/sycl-link-spirv-target.cpp
new file mode 100644
index 00000000000000..550d40aac5499d
--- /dev/null
+++ b/clang/test/Driver/sycl-link-spirv-target.cpp
@@ -0,0 +1,7 @@
+// Tests the driver when linking LLVM IR bitcode files and targeting SPIR-V
+// architecture.
+//
+// RUN: touch %t.bc
+// RUN: %clangxx --target=spirv64 --sycl-link -### %t.bc 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=LINK
+// LINK: "{{.*}}clang-sycl-link-wrapper{{.*}}" "{{.*}}.bc" "-o" "a.out"
diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt
index 88e29412e54350..d704ca5c62c97b 100644
--- a/clang/tools/CMakeLists.txt
+++ b/clang/tools/CMakeLists.txt
@@ -12,6 +12,7 @@ add_clang_subdirectory(clang-nvlink-wrapper)
 add_clang_subdirectory(clang-offload-packager)
 add_clang_subdirectory(clang-offload-bundler)
 add_clang_subdirectory(clang-scan-deps)
+add_clang_subdirectory(clang-sycl-link-wrapper)
 add_clang_subdirectory(clang-installapi)
 if(HAVE_CLANG_REPL_SUPPORT)
   add_clang_subdirectory(clang-repl)
diff --git a/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt b/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt
new file mode 100644
index 00000000000000..c51f6f977dddd7
--- /dev/null
+++ b/clang/tools/clang-sycl-link-wrapper/CMakeLists.txt
@@ -0,0 +1,28 @@
+set(LLVM_LINK_COMPONENTS
+  ${LLVM_TARGETS_TO_BUILD}
+  Option
+  )
+
+set(LLVM_TARGET_DEFINITIONS SYCLLinkOpts.td)
+tablegen(LLVM SYCLLinkOpts.inc -gen-opt-parser-defs)
+add_public_tablegen_target(SYCLLinkWrapperOpts)
+
+if(NOT CLANG_BUILT_STANDALONE)
+  set(tablegen_deps intrinsics_gen SYCLLinkWrapperOpts)
+endif()
+
+add_clang_tool(clang-sycl-link-wrapper
+  ClangSYCLLinkWrapper.cpp
+
+  DEPENDS
+  ${tablegen_deps}
+  )
+
+set(CLANG_SYCL_LINK_WRAPPER_LIB_DEPS
+  clangBasic
+  )
+
+target_link_libraries(clang-sycl-link-wrapper
+  PRIVATE
+  ${CLANG_SYCL_LINK_WRAPPER_LIB_DEPS}
+  )
diff --git a/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp b/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp
new file mode 100644
index 00000000000000..31afa26c46518d
--- /dev/null
+++ b/clang/tools/clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp
@@ -0,0 +1,530 @@
+//=-- clang-sycl-link-wrapper/ClangSYCLLinkWrapper.cpp - SYCL linker util --=//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===---------------------------------------------------------------------===//
+//
+// This tool wraps around the sequence of steps required to link device code in
+// SYCL fat objects. SYCL device code linking requires a complex sequence of
+// steps that include linking of llvm bitcode files, linking device library
+// files with the fully linked source bitcode file(s), running several SYCL
+// specific post-link steps on the fully linked bitcode file(s), and finally
+// generating target-specific device code. This tool can be removed once SYCL
+// linking is ported to `ld.lld`.
+//
+//===---------------------------------------------------------------------===//
+
+#include "clang/Basic/Version.h"
+
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/BinaryFormat/Magic.h"
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/CodeGen/CommandFlags.h"
+#include "llvm/IR/DiagnosticPrinter.h"
+#include "llvm/IRReader/IRReader.h"
+#include "llvm/LTO/LTO.h"
+#include "llvm/Object/Archive.h"
+#include "llvm/Object/ArchiveWriter.h"
+#include "llvm/Object/Binary.h"
+#include "llvm/Object/ELFObjectFile.h"
+#include "llvm/Object/IRObjectFile.h"
+#include "llvm/Object/ObjectFile.h"
+#include "llvm/Object/OffloadBinary.h"
+#include "llvm/Option/ArgList.h"
+#include "llvm/Option/OptTable.h"
+#include "llvm/Option/Option.h"
+#include "llvm/Remarks/HotnessThresholdParser.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/InitLLVM.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/Program.h"
+#include "llvm/Support/Signals.h"
+#include "llvm/Support/StringSaver.h"
+#include "llvm/Support/TargetSelect.h"
+#include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/WithColor.h"
+
+using namespace llvm;
+using namespace llvm::opt;
+using namespace llvm::object;
+
+/// Save intermediary results.
+static bool SaveTemps = false;
+
+/// Print arguments without executing.
+static bool DryRun = false;
+
+/// Print verbose output.
+static bool Verbose = false;
+
+/// Filename of the output being created.
+static StringRef OutputFile;
+
+/// Directory to dump SPIR-V IR if requested by user.
+static SmallString<128> SPIRVDumpDir;
+
+static void printVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-sycl-link-wrapper") << '\n';
+}
+
+/// The value of `argv[0]` when run.
+static const char *Executable;
+
+/// Temporary files to be cleaned up.
+static SmallVector<SmallString<128>> TempFiles;
+
+namespace {
+// Must not overlap with llvm::opt::DriverFlag.
+enum WrapperFlags { WrapperOnlyOption = (1 << 4) };
+
+enum ID {
+  OPT_INVALID = 0, // This is not an option ID.
+#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+  LastOption
+#undef OPTION
+};
+
+#define PREFIX(NAME, VALUE)                                                    \
+  static constexpr StringLiteral NAME##_init[] = VALUE;                        \
+  static constexpr ArrayRef<StringLiteral> NAME(NAME##_init,                   \
+                                                std::size(NAME##_init) - 1);
+#include "SYCLLinkOpts.inc"
+#undef PREFIX
+
+static constexpr OptTable::Info InfoTable[] = {
+#define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
+#include "SYCLLinkOpts.inc"
+#undef OPTION
+};
+
+class WrapperOptTable : public opt::GenericOptTable {
+public:
+  WrapperOptTable() : opt::GenericOptTable(InfoTable) {}
+};
+
+const OptTable &getOptTable() {
+  static const WrapperOptTable *Table = []() {
+    auto Result = std::make_unique<WrapperOptTable>();
+    return Result.release();
+  }();
+  return *Table;
+}
+
+[[noreturn]] void reportError(Error E) {
+  outs().flush();
+  logAllUnhandledErrors(std::move(E), WithColor::error(errs(), Executable));
+  exit(EXIT_FAILURE);
+}
+
+std::string getMainExecutable(const char *Name) {
+  void *Ptr = (void *)(intptr_t)&getMainExecutable;
+  auto COWPath = sys::fs::getMainExecutable(Name, Ptr);
+  return sys::path::parent_path(COWPath).str();
+}
+
+Expected<StringRef> createTempFile(const ArgList &Args, const Twine &Prefix,
+                                   StringRef Extension) {
+  SmallString<128> OutputFile;
+  if (Args.hasArg(OPT_save_temps)) {
+    // Generate a unique path name without creating a file
+    sys::fs::createUniquePath(Prefix + "-%%%%%%." + Extension, OutputFile,
+                              /*MakeAbsolute=*/false);
+  } else {
+    if (std::error_code EC =
+            sys::fs::createTemporaryFile(Prefix, Extension, OutputFile))
+      return createFileError(OutputFile, EC);
+  }
+
+  TempFiles.emplace_back(std::move(OutputFile));
+  return TempFiles.back();
+}
+
+Expected<std::string> findProgram(const ArgList &Args, StringRef Name,
+                                  ArrayRef<StringRef> Paths) {
+  if (Args.hasArg(OPT_dry_run))
+    return Name.str();
+  ErrorOr<std::string> Path = sys::findProgramByName(Name, Paths);
+  if (!Path)
+    Path = sys::findProgramByName(Name);
+  if (!Path)
+    return createStringError(Path.getError(),
+                             "Unable to find '" + Name + "' in path");
+  return *Path;
+}
+
+std::optional<std::string> findFile(StringRef Dir, StringRef Root,
+                                    const Twine &Name) {
+  SmallString<128> Path;
+  if (Dir.starts_with("="))
+    sys::path::append(Path, Root, Dir.substr(1), Name);
+  else
+    sys::path::append(Path, Dir, Name);
+
+  if (sys::fs::exists(Path))
+    return static_cast<std::string>(Path);
+  return std::nullopt;
+}
+
+void printCommands(ArrayRef<StringRef> CmdArgs) {
+  if (CmdArgs.empty())
+    return;
+
+  llvm::errs() << " \"" << CmdArgs.front() << "\" ";
+  llvm::errs() << llvm::join(std::next(CmdArgs.begin()), CmdArgs.end(), " ")
+               << "\n";
+}
+
+/// Execute the command \p ExecutablePath with the arguments \p Args.
+Error executeCommands(StringRef ExecutablePath, ArrayRef<StringRef> Args) {
+  if (Verbose || DryRun)
+    printCommands(Args);
+
+  if (!DryRun)
+    if (sys::ExecuteAndWait(ExecutablePath, Args))
+      return createStringError(
+          "'%s' failed", sys::path::filename(ExecutablePath).str().c_str());
+  return Error::success();
+}
+
+Expected<SmallVector<std::string>> getInput(const ArgList &Args) {
+  // Collect all input bitcode files to be passed to llvm-link.
+  SmallVector<std::string> BitcodeFiles;
+  for (const opt::Arg *Arg : Args.filtered(OPT_INPUT)) {
+    std::optional<std::string> Filename = std::string(Arg->getValue());
+    if (!Filename || !sys::fs::exists(*Filename) ||
+        sys::fs::is_directory(*Filename))
+      continue;
+    file_magic Magic;
+    if (auto EC = identify_magic(*Filename, Magic))
+      return createStringError("Failed to open file " + *Filename);
+    if (Magic != file_magic::bitcode)
+      return createStringError("Unsupported file type");
+    BitcodeFiles.push_back(*Filename);
+  }
+  return BitcodeFiles;
+}
+
+/// Link all SYCL device input files into one before adding device library
+/// files. Device linking is performed using llvm-link tool.
+/// 'InputFiles' is the list of all LLVM IR device input files.
+/// 'Args' encompasses all arguments required for linking and wrapping device
+/// code and will be parsed to generate options required to be passed into the
+/// llvm-link tool.
+Expected<StringRef> linkDeviceInputFiles(ArrayRef<std::string> InputFiles,
+                                         const ArgList &Args) {
+  llvm::TimeTraceScope TimeScope("SYCL LinkDeviceInputFiles");
+  Expected<std::string> LLVMLinkPath =
+      findProgram(Args, "llvm-link", {getMainExecutable("llvm-link")});
+  if (!LLVMLinkPath)
+    return LLVMLinkPath.takeError();
+
+  SmallVector<StringRef> CmdArgs;
+  CmdArgs.push_back(*LLVMLinkPath);
+  for (auto &File : InputFiles)
+    CmdArgs.push_back(File);
+  // Create a new file to write the linked device file to.
+  auto OutFileOrErr =
+      createTempFile(Args, sys::path::filename(OutputFile), "bc");
+  if (!OutFileOrErr)
+    return OutFileOrErr.takeError();
+  CmdArgs.push_back("-o");
+  CmdArgs.push_back(*OutFileOrErr);
+  CmdArgs.push_back("--suppress-warnings");
+  if (Error Err = executeCommands(*LLVMLinkPath, CmdArgs))
+    return std::move(Err);
+  return *OutFileOrErr;
+}
+
+const SmallVector<std::string> SYCLDeviceLibNames = {
+    "libsycl-crt.bc",
+    "libsycl-complex.bc",
+    "libsycl-complex-fp64.bc",
+    "libsycl-cmath.bc",
+    "libsycl-cmath-fp64.bc",
+    "libsycl-imf.bc",
+    "libsycl-imf-fp64.bc",
+    "libsycl-imf-bf16.bc",
+    "libsycl-fallback-cassert.bc",
+    "libsycl-fallback-cstring.bc",
+    "libsycl-fallback-complex.bc",
+    "libsycl-fallback-complex-fp64.bc",
+    "libsycl-fallback-cmath.bc",
+    "libsycl-fallback-cmath-fp64.bc",
+    "libsycl-fallback-imf.bc",
+    "libsy...
[truncated]

@asudarsa asudarsa changed the title [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloadi… [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code Oct 14, 2024
@asudarsa asudarsa changed the title [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code [Clang][SYCL] Introduce clang-sycl-link-wrapper to link SYCL offloading device code (Part 1 of many) Oct 14, 2024
@asudarsa
Copy link
Contributor Author

This PR is the first in the list of multiple PRs that will be submitted to add SYCL offloading support using the new offloading model. Upcoming PRs include:

  1. SYCL finalization steps that will run after llvm-link will be added to the linking clow inside clang-sycl-link-wrapper. One of the finalization steps is device code splitting.
  2. Changes to clang-linker-wrapper to invoke the clang-sycl-link-wrapper (via the clang driver call) for SYCL offloading case.
  3. AOT compilation support for Intel, AMD and NVidia GPUs

Thanks
Sincerely

@asudarsa
Copy link
Contributor Author

@jhuber6

Can you please take a look at this PR when convenient? Thanks for all your inputs in getting this PR ready.

Sincerely

#include "SYCLLinkOpts.inc"
#undef PREFIX

static constexpr OptTable::Info InfoTable[] = {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of the 'helper' routines getOptTable, createTempFile, etc are routines that have been borrowed from clang-linker-wrapper and clang-nvlink-wrapper. In an upcoming effort, we can try to create a single space for these routines to exist.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing that's special about this case is that it forwards arguments it doesn't understand via a flag. We could possibly make a utility for that.


TranslatorArgs.push_back(Args.MakeArgString(UnknownIntrinsics));

// Disable all the extensions by default
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

List of SPIR-V extensions is 'fluid' and will be updated in an upcoming commit.

Thanks

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass, I like the approach overall.

@@ -6728,7 +6728,10 @@ def fsycl : Flag<["-"], "fsycl">,
def fno_sycl : Flag<["-"], "fno-sycl">,
Visibility<[ClangOption, CLOption]>,
Group<sycl_Group>, HelpText<"Disables SYCL kernels compilation for device">;

def sycl_link : Flag<["--"], "sycl-link">, Flags<[HelpHidden]>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this necessary? Shouldn't it do this automatically if we pass in .o files or use -Xlinker foo.c?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use this option to select between spirv-linker which is the standard linking tool for spir-v IR (but not mature enough for us to use it in our pipeline) and the clang-sycl-linker.

Thanks

SPIRVToolChain::SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: ToolChain(D, Triple, Args) {
NativeLLVMSupport = Args.hasArg(options::OPT_sycl_link);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay I'm guessing this is to separate this from an existing SPIR-V link step? We could possibly put that in a different toolchain.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can eventually move this to SYCL toolchain when it is available upstream.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, we can put that as a TODO then.

#include "SYCLLinkOpts.inc"
#undef PREFIX

static constexpr OptTable::Info InfoTable[] = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing that's special about this case is that it forwards arguments it doesn't understand via a flag. We could possibly make a utility for that.

/// 'Args' encompasses all arguments required for linking and wrapping device
/// code and will be parsed to generate options required to be passed into the
/// llvm-spirv tool.
static Expected<StringRef> runLLVMToSPIRVTranslation(StringRef File,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If any of these are external, we should also pass a path in from clang like how we handle CUDA / ROCm. If these are internal tools then don't worry about it since we just search next to clang.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a new option to pass the llvm-spirv path to the clang-sycl-linker tool.

Thanks

@asudarsa
Copy link
Contributor Author

Hi @jhuber6

Thanks much for providing your feedback. I will address all your comments in an upcoming commit.

Sincerely

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
@asudarsa
Copy link
Contributor Author

Earlier test fail due to lack of new tool in clang/test/lit.cfg.py.
Added it now.

Thanks

@asudarsa
Copy link
Contributor Author

Hi @jhuber6

I have addressed all the concerns to my best ability. Thanks very much for your guidance and feedback thus far.

Thanks
Sincerely

@asudarsa asudarsa requested a review from jhuber6 October 15, 2024 18:12
SPIRVToolChain::SPIRVToolChain(const Driver &D, const llvm::Triple &Triple,
const ArgList &Args)
: ToolChain(D, Triple, Args) {
NativeLLVMSupport = Args.hasArg(options::OPT_sycl_link);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, we can put that as a TODO then.

-help-hidden Display all available options
-help Display available options (--help-hidden for more)
--library-path=<dir> Set the library path for SYCL device libraries
--device-libs=<value> A comma separated list of device libraries that are linked during the device link
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are device libs and regular input distinct?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regular inputs for SYCL offloading are linked using default settings whereas SYCL device libs are linked with the '--only-needed' flag.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's kind of the behavior of static libraries, and LTO could just optimize them out if they're unused. But I suppose it's not terribly important to get it perfect on the first pass.

…of changes missed out from earlier commit.

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
Copy link
Contributor

@jhuber6 jhuber6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems reasonable, more work can be done in follow ups. Please wait until the CI is green before merging anything.

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a clang-based tool? Other than using clang/Basic to get the clang version (which could also be retrieved from LLVM), this doesn't seem to have any dependencies on Clang.

As I'm seeing the SYCL patches coming in I'm getting concerned that the architecture of the SYCL compiler doesn't align with LLVM and Clang's design.

Copy link
Collaborator

@llvm-beanz llvm-beanz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd really like to understand why this is a clang-level tool and get feedback from @AaronBallman before this goes further.

Comment on lines 11 to 12
// RUN: echo ' ' > %T/lib1.bc
// RUN: echo ' ' > %T/lib2.bc
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// RUN: echo ' ' > %T/lib1.bc
// RUN: echo ' ' > %T/lib2.bc
// RUN: touch %T/lib1.bc
// RUN: touch %T/lib2.bc

Can we leave these files empty?

/// be parsed to generate options required to be passed into llvm-link.
Expected<StringRef> linkDeviceInputFiles(ArrayRef<std::string> InputFiles,
const ArgList &Args) {
llvm::TimeTraceScope TimeScope("SYCL LinkDeviceInputFiles");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should add a check for the InputFiles container size. If the size is < 2, we should exit w/o invoking llvm-link.

// DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
//
// Test a simple case with .o (fat object) as input.
// TODO: Remove this test once fat object support is added.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is clang-sycl-linker supposed to support fat objects? According to my understanding, this tool links the device code only. Some other tool (e.g. clang-linker-wrapper) is supposed to extract device code from fat objects and invoke clang-sycl-linker tool to link the device code. I think this tool is supposed to handle object files, but only 'lean'. @jhuber6, did I get it right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's correct. Currently trying to make the linker wrapper a bit leaner, but the expected flow should be

fatbin.o -> dev1.o, dev2.o
  - clang --target=TRIPLE -o image dev1.o dev2.o

My general assertion is that every target should have a way to get a usable image via a clang --target invocation, which should be equipped to handle normal linker stuff.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, the flow is this. clang-inker-wrapper reads the fat object and extracts bitcode files. These bitcode files are then fed to clang++ as inputs.
We may eventually want to pass the fat object as is and let the clang-sycl-linker extract the bitcode file.

Thanks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may eventually want to pass the fat object as is and let the clang-sycl-linker extract the bitcode file.

We don't want that. We want to link object files with the code for a single target (i.e. offload device target). We don't want clang-sycl-linker tool to handle fat objects - only regular objects.

I suggest we update the comment by replacing "fat object" to just "object".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the idea is that the device toolchain should work in the same way that clang --target=aarch64 gives you a functioning Arm executable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adjusted comment. Thanks

Comment on lines +163 to +165
llvm::errs() << " \"" << CmdArgs.front() << "\" ";
llvm::errs() << llvm::join(std::next(CmdArgs.begin()), CmdArgs.end(), " ")
<< "\n";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jhuber6, I see that @asudarsa is copying the logic from similar clang tools you wrote, so my question is for you.
What is the reason to use the error stream instead of output stream (i.e. llvm::outs())?

One of problems I see is that tests redirect the error stream to the output stream to pass the test in LIT environment. If some LLVM libraries report errors to the error stream, they will be ignored.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered this debugging and AFAIK LLVM uses errs() for debugging messages.

// DEVLIBSERR1: Number of device library files cannot be zero
// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs=lib3.bc -o a.spv 2>&1 \
// RUN: | FileCheck %s --check-prefix=DEVLIBSERR2
// DEVLIBSERR2: SYCL device library file is not found
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// DEVLIBSERR2: SYCL device library file is not found
// DEVLIBSERR2: lib3.bc SYCL device library file is not found

Please, check that error message contains the name of the library file, we can't find.

// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs= -o a.spv 2>&1 \
// RUN: | FileCheck %s --check-prefix=DEVLIBSERR1
// DEVLIBSERR1: Number of device library files cannot be zero
// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs=lib3.bc -o a.spv 2>&1 \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs=lib3.bc -o a.spv 2>&1 \
// RUN: not clang-sycl-linker --dry-run -triple spirv64 %t.bc --library-path=%T --device-libs=lib1.bc,lib2.bc,lib3.bc -o a.spv 2>&1 \

#undef OPTION
};

class WrapperOptTable : public opt::GenericOptTable {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
class WrapperOptTable : public opt::GenericOptTable {
class LinkerOptTable : public opt::GenericOptTable {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will change this. Thanks. Also. I will change WrapperOnlyOption to LinkerOnlyOption.

Thanks

… when only one input is present

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
@asudarsa
Copy link
Contributor Author

Hi @bader

Thanks very much for your feedback. I have addressed the concerns in the latest commit.
Thanks to @jhuber6 for some responses as well.

Sincerely

@asudarsa asudarsa requested a review from bader October 29, 2024 21:30
Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except a couple of minor nits.

… some comments

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
Comment on lines +25 to +26
// Test a simple case with .o (fat object) as input.
// TODO: Remove this test once fat object support is added.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Test a simple case with .o (fat object) as input.
// TODO: Remove this test once fat object support is added.
// Test a simple case with .o (object) as input.
// TODO: Remove this test once object support is added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I please update this in one of the upcoming PRs? I do not want to trigger another round of testing here.

Thanks

@llvm-beanz llvm-beanz dismissed their stale review October 30, 2024 15:18

I'd prefer we have SYCL linking run through LLD rather than the linker-wrapper tool approach, but I don't feel strongly enough to block this.

@jhuber6
Copy link
Contributor

jhuber6 commented Oct 30, 2024

I'd prefer we have SYCL linking run through LLD rather than the linker-wrapper tool approach, but I don't feel strongly enough to block this.

I see this as a temporary hack around not having a proper SPIR-V linker / backend in LLVM yet. It's less of a linker-wrapper tool and more of my assertions that every single target should be able to be targeted directly via clang --target=... which then lets the linker wrapper just do the part where it extracts GPU code from fat binaries, invokes clang on each to get an executable, then wraps that in the runtime's registration code.

@jhuber6 jhuber6 merged commit eeee5a4 into llvm:main Oct 31, 2024
9 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder flang-aarch64-libcxx running on linaro-flang-aarch64-libcxx while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/89/builds/9528

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
98.786 [213/17/7020] Creating library symlink lib/libFortranEvaluate.so
98.987 [212/17/7021] Linking CXX shared library lib/libFIRTestAnalysis.so.20.0git
98.995 [211/17/7022] Creating library symlink lib/libFIRTestAnalysis.so
99.169 [211/16/7023] Building CXX object tools/clang/tools/clang-check/CMakeFiles/clang-check.dir/ClangCheck.cpp.o
99.301 [211/15/7024] Linking CXX shared library lib/libHLFIRTransforms.so.20.0git
99.309 [210/15/7025] Creating library symlink lib/libHLFIRTransforms.so
99.814 [208/16/7026] Linking CXX shared library lib/libflangPasses.so.20.0git
99.823 [207/16/7027] Creating library symlink lib/libflangPasses.so
100.028 [206/16/7028] Building CXX object tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o
100.109 [205/16/7029] Linking CXX executable bin/clang-sycl-linker
FAILED: bin/clang-sycl-linker 
: && /usr/local/bin/c++ -stdlib=libc++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -stdlib=libc++     -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/./lib  -Wl,--gc-sections tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o -o bin/clang-sycl-linker  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/lib:"  lib/libLLVMAArch64CodeGen.so.20.0git  lib/libLLVMAArch64AsmParser.so.20.0git  lib/libLLVMAArch64Disassembler.so.20.0git  lib/libLLVMOption.so.20.0git  lib/libclangBasic.so.20.0git  lib/libLLVMAArch64Desc.so.20.0git  lib/libLLVMAArch64Info.so.20.0git  lib/libLLVMAArch64Utils.so.20.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/lib && :
/usr/bin/ld: tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o: undefined reference to symbol '_ZN4llvm6TripleC1ERKNS_5TwineE'
/usr/bin/ld: /home/tcwg-buildbot/worker/flang-aarch64-libcxx/build/./lib/libLLVMTargetParser.so.20.0git: error adding symbols: DSO missing from command line
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
100.125 [205/15/7030] Building CXX object tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Tooling.cpp.o
100.231 [205/14/7031] Linking CXX executable bin/fir-opt
100.252 [205/13/7032] Building CXX object tools/clang/lib/Tooling/DependencyScanning/CMakeFiles/obj.clangDependencyScanning.dir/DependencyScanningWorker.cpp.o
100.343 [205/12/7033] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/InterpreterUtils.cpp.o
100.656 [205/11/7034] Linking CXX executable bin/tco
102.148 [205/10/7035] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/InterpreterValuePrinter.cpp.o
103.320 [205/9/7036] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/ClangInstallAPI.cpp.o
103.328 [205/8/7037] Linking CXX shared library lib/libFortranSemantics.so.20.0git
105.292 [205/7/7038] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
107.840 [205/6/7039] Building CXX object tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/Interpreter.cpp.o
109.174 [205/5/7040] Building CXX object tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/ClangScanDeps.cpp.o
137.751 [205/4/7041] Building CXX object tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CompilerInvocation.cpp.o
138.943 [205/3/7042] Building CXX object tools/flang/tools/flang-driver/CMakeFiles/flang.dir/driver.cpp.o
150.946 [205/2/7043] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o
153.118 [205/1/7044] Building CXX object tools/flang/lib/FrontendTool/CMakeFiles/flangFrontendTool.dir/ExecuteCompilerInvocation.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder polly-x86_64-linux-shared running on polly-x86_64-gce2 while building clang at step 5 "build".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/97/builds/2753

Here is the relevant piece of the build log for the reference
Step 5 (build) failure: 'ninja' (failure)
...
[3546/4239] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
[3547/4239] Building CXX object tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/clang-scan-deps-driver.cpp.o
[3548/4239] Building SYCLLinkOpts.inc...
[3549/4239] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/cc1_main.cpp.o
[3550/4239] Building CXX object tools/clang/tools/clang-repl/CMakeFiles/clang-repl.dir/ClangRepl.cpp.o
[3551/4239] Building CXX object tools/clang/tools/c-index-test/CMakeFiles/c-index-test.dir/core_main.cpp.o
[3552/4239] Building InstallAPIOpts.inc...
[3553/4239] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/clang-installapi-driver.cpp.o
[3554/4239] Building CXX object tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o
[3555/4239] Linking CXX executable bin/clang-sycl-linker
FAILED: bin/clang-sycl-linker 
: && /usr/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG -fuse-ld=lld -Wl,--color-diagnostics     -Wl,--gc-sections tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o -o bin/clang-sycl-linker  -Wl,-rpath,"\$ORIGIN/../lib:/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib:"  lib/libLLVMX86CodeGen.so.20.0git  lib/libLLVMX86AsmParser.so.20.0git  lib/libLLVMX86Desc.so.20.0git  lib/libLLVMX86Disassembler.so.20.0git  lib/libLLVMX86Info.so.20.0git  lib/libLLVMNVPTXCodeGen.so.20.0git  lib/libLLVMNVPTXDesc.so.20.0git  lib/libLLVMNVPTXInfo.so.20.0git  lib/libLLVMOption.so.20.0git  lib/libclangBasic.so.20.0git  -Wl,-rpath-link,/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib && :
ld.lld: error: undefined symbol: vtable for llvm::support::detail::format_adapter
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::StringRef&>::~provider_format_adapter())
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<int>::~provider_format_adapter())
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::SmallString<128u>&>::~provider_format_adapter())
>>> referenced 3 more times
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)

ld.lld: error: undefined symbol: llvm::SmallVectorBase<unsigned long>::grow_pod(void*, unsigned long, unsigned long)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::SmallVectorImpl<char>::operator=(llvm::SmallVectorImpl<char>&&) (.isra.0))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::SmallVectorImpl<char>::operator=(llvm::SmallVectorImpl<char> const&) (.isra.0))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(void llvm::SmallVectorImpl<char>::append<char const*, void>(char const*, char const*))
>>> referenced 2 more times

ld.lld: error: undefined symbol: llvm::getAsUnsignedInteger(llvm::StringRef, unsigned int, unsigned long long&)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::StringRef&>::format(llvm::raw_ostream&, llvm::StringRef))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::SmallString<128u>&>::format(llvm::raw_ostream&, llvm::StringRef))

ld.lld: error: undefined symbol: llvm::raw_ostream::write(char const*, unsigned long)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::StringRef&>::format(llvm::raw_ostream&, llvm::StringRef))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::SmallString<128u>&>::format(llvm::raw_ostream&, llvm::StringRef))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::raw_ostream::operator<<(char const*))
>>> referenced 3 more times

ld.lld: error: undefined symbol: llvm::sys::fs::getMainExecutable[abi:cxx11](char const*, void*)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:((anonymous namespace)::getMainExecutable(char const*))

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder flang-aarch64-sharedlibs running on linaro-flang-aarch64-sharedlibs while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/80/builds/5662

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
770.201 [1161/12/6289] Generating ../../../../libexec/intercept-c++
770.201 [1161/11/6290] Generating ../../../../lib/libscanbuild/resources/selectable.js
770.202 [1161/10/6291] Generating ../../../../lib/libscanbuild/shell.py
770.207 [1161/9/6292] Generating ../../../../libexec/intercept-cc
770.220 [1161/8/6293] Generating ../../../../lib/libscanbuild/resources/scanview.css
770.278 [1161/7/6294] Generating ../../../../lib/libscanbuild/resources/sorttable.js
770.342 [1161/6/6295] Linking CXX shared library lib/libclangParse.so.20.0git
770.357 [1159/7/6296] Creating library symlink lib/libclangParse.so
770.364 [1159/6/6297] Generating ../../../../bin/scan-view
770.394 [1156/8/6298] Linking CXX executable bin/clang-sycl-linker
FAILED: bin/clang-sycl-linker 
: && /usr/local/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/./lib  -Wl,--gc-sections tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o -o bin/clang-sycl-linker  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/lib:"  lib/libLLVMAArch64CodeGen.so.20.0git  lib/libLLVMAArch64AsmParser.so.20.0git  lib/libLLVMAArch64Disassembler.so.20.0git  lib/libLLVMOption.so.20.0git  lib/libclangBasic.so.20.0git  lib/libLLVMAArch64Desc.so.20.0git  lib/libLLVMAArch64Info.so.20.0git  lib/libLLVMAArch64Utils.so.20.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/lib && :
/usr/bin/ld: tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o: undefined reference to symbol '_ZN4llvm6TripleC1ERKNS_5TwineE'
/usr/bin/ld: /home/tcwg-buildbot/worker/flang-aarch64-sharedlibs/build/./lib/libLLVMTargetParser.so.20.0git: error adding symbols: DSO missing from command line
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
770.409 [1156/7/6299] Generating ../../../../share/scan-view/Reporter.py
770.413 [1156/6/6300] Linking CXX shared library lib/libclangSerialization.so.20.0git
770.421 [1156/5/6301] Generating ../../../../share/scan-view/bugcatcher.ico
770.422 [1156/4/6302] Generating ../../../../share/scan-view/ScanView.py
770.565 [1156/3/6303] Building CXX object tools/clang/tools/arcmt-test/CMakeFiles/arcmt-test.dir/arcmt-test.cpp.o
770.661 [1156/2/6304] Building CXX object tools/clang/tools/clang-check/CMakeFiles/clang-check.dir/ClangCheck.cpp.o
778.026 [1156/1/6305] Linking CXX shared library lib/libclang-cpp.so.20.0git
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder flang-aarch64-latest-gcc running on linaro-flang-aarch64-latest-gcc while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/130/builds/5578

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
../llvm-project/llvm/include/llvm/Transforms/IPO/FunctionImport.h:273:33: warning: member ‘llvm::FunctionImporter::ImportListsTy::ImportIDs’ is used uninitialized [-Wuninitialized]
  273 |     ImportListsTy() : EmptyList(ImportIDs) {}
      |                                 ^~~~~~~~~
../llvm-project/llvm/include/llvm/Transforms/IPO/FunctionImport.h: In constructor ‘llvm::FunctionImporter::ImportListsTy::ImportListsTy(size_t)’:
../llvm-project/llvm/include/llvm/Transforms/IPO/FunctionImport.h:274:44: warning: member ‘llvm::FunctionImporter::ImportListsTy::ImportIDs’ is used uninitialized [-Wuninitialized]
  274 |     ImportListsTy(size_t Size) : EmptyList(ImportIDs), ListsImpl(Size) {}
      |                                            ^~~~~~~~~
897.122 [1049/12/6205] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/clang-installapi-driver.cpp.o
897.123 [1049/11/6206] Building CXX object tools/clang/tools/clang-shlib/CMakeFiles/clang-cpp.dir/clang-shlib.cpp.o
897.136 [1049/10/6207] Linking CXX executable bin/clang-sycl-linker
FAILED: bin/clang-sycl-linker 
: && /usr/local/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/./lib  -Wl,--gc-sections tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o -o bin/clang-sycl-linker  -Wl,-rpath,"\$ORIGIN/../lib:/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/lib:"  lib/libLLVMAArch64CodeGen.so.20.0git  lib/libLLVMAArch64AsmParser.so.20.0git  lib/libLLVMAArch64Disassembler.so.20.0git  lib/libLLVMOption.so.20.0git  lib/libclangBasic.so.20.0git  lib/libLLVMAArch64Desc.so.20.0git  lib/libLLVMAArch64Info.so.20.0git  lib/libLLVMAArch64Utils.so.20.0git  -Wl,-rpath-link,/home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/lib && :
/usr/bin/ld: tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o: undefined reference to symbol '_ZN4llvm3sys4path8filenameENS_9StringRefENS1_5StyleE'
/usr/bin/ld: /home/tcwg-buildbot/worker/flang-aarch64-latest-gcc/build/./lib/libLLVMSupport.so.20.0git: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
897.195 [1049/9/6208] Building CXX object tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/TestSupport.cpp.o
897.252 [1049/8/6209] Generating ../../../../lib/libscanbuild/compilation.py
897.263 [1049/7/6210] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/ARCMigrate.cpp.o
897.836 [1049/6/6211] Building CXX object tools/clang/tools/clang-extdef-mapping/CMakeFiles/clang-extdef-mapping.dir/ClangExtDefMapGen.cpp.o
897.864 [1049/5/6212] Building CXX object tools/clang/tools/arcmt-test/CMakeFiles/arcmt-test.dir/arcmt-test.cpp.o
907.573 [1049/4/6213] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/Options.cpp.o
907.874 [1049/3/6214] Building CXX object tools/clang/tools/clang-check/CMakeFiles/clang-check.dir/ClangCheck.cpp.o
914.342 [1049/2/6215] Building CXX object tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/ClangScanDeps.cpp.o
914.789 [1049/1/6216] Building CXX object tools/clang/tools/clang-installapi/CMakeFiles/clang-installapi.dir/ClangInstallAPI.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder polly-x86_64-linux-shared-plugin running on polly-x86_64-gce2 while building clang at step 5 "build".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/118/builds/2728

Here is the relevant piece of the build log for the reference
Step 5 (build) failure: 'ninja' (failure)
...
[3563/4239] Building CXX object tools/clang/tools/clang-offload-bundler/CMakeFiles/clang-offload-bundler.dir/ClangOffloadBundler.cpp.o
[3564/4239] Linking CXX executable bin/clang-offload-packager
[3565/4239] Building Opts.inc...
[3566/4239] Building CXX object tools/clang/tools/clang-scan-deps/CMakeFiles/clang-scan-deps.dir/clang-scan-deps-driver.cpp.o
[3567/4239] Linking CXX executable bin/clang-offload-bundler
[3568/4239] Building SYCLLinkOpts.inc...
[3569/4239] Building CXX object tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
[3570/4239] Linking CXX executable bin/clang-import-test
[3571/4239] Building CXX object tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o
[3572/4239] Linking CXX executable bin/clang-sycl-linker
FAILED: bin/clang-sycl-linker 
: && /usr/bin/c++ -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG -fuse-ld=lld -Wl,--color-diagnostics     -Wl,--gc-sections tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o -o bin/clang-sycl-linker  -Wl,-rpath,"\$ORIGIN/../lib:/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib:"  lib/libLLVMX86CodeGen.so.20.0git  lib/libLLVMX86AsmParser.so.20.0git  lib/libLLVMX86Desc.so.20.0git  lib/libLLVMX86Disassembler.so.20.0git  lib/libLLVMX86Info.so.20.0git  lib/libLLVMNVPTXCodeGen.so.20.0git  lib/libLLVMNVPTXDesc.so.20.0git  lib/libLLVMNVPTXInfo.so.20.0git  lib/libLLVMOption.so.20.0git  lib/libclangBasic.so.20.0git  -Wl,-rpath-link,/home/worker/buildbot-workers/polly-x86_64-gce2/rundir/llvm.obj/lib && :
ld.lld: error: undefined symbol: vtable for llvm::support::detail::format_adapter
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::StringRef&>::~provider_format_adapter())
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<int>::~provider_format_adapter())
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::SmallString<128u>&>::~provider_format_adapter())
>>> referenced 3 more times
>>> the vtable symbol may be undefined because the class is missing its key function (see https://lld.llvm.org/missingkeyfunction)

ld.lld: error: undefined symbol: llvm::SmallVectorBase<unsigned long>::grow_pod(void*, unsigned long, unsigned long)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::SmallVectorImpl<char>::operator=(llvm::SmallVectorImpl<char>&&) (.isra.0))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::SmallVectorImpl<char>::operator=(llvm::SmallVectorImpl<char> const&) (.isra.0))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(void llvm::SmallVectorImpl<char>::append<char const*, void>(char const*, char const*))
>>> referenced 2 more times

ld.lld: error: undefined symbol: llvm::getAsUnsignedInteger(llvm::StringRef, unsigned int, unsigned long long&)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::StringRef&>::format(llvm::raw_ostream&, llvm::StringRef))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::SmallString<128u>&>::format(llvm::raw_ostream&, llvm::StringRef))

ld.lld: error: undefined symbol: llvm::raw_ostream::write(char const*, unsigned long)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::StringRef&>::format(llvm::raw_ostream&, llvm::StringRef))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::support::detail::provider_format_adapter<llvm::SmallString<128u>&>::format(llvm::raw_ostream&, llvm::StringRef))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::raw_ostream::operator<<(char const*))
>>> referenced 3 more times

ld.lld: error: undefined symbol: llvm::sys::fs::getMainExecutable[abi:cxx11](char const*, void*)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:((anonymous namespace)::getMainExecutable(char const*))

@asudarsa
Copy link
Contributor Author

All the failures seem to be related to missing dependencies. I am working on a fix. Thanks

@jhuber6
Copy link
Contributor

jhuber6 commented Oct 31, 2024

Should be fixed in 0d499f9

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-fast running on sanitizer-buildbot4 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/169/builds/4835

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86759 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: Clang :: Driver/clang-sycl-linker-test.cpp (86734 of 86759)
******************** TEST 'Clang :: Driver/clang-sycl-linker-test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
RUN: at line 5: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
RUN: at line 6: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
RUN: at line 12: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv
RUN: at line 17: touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
+ touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
RUN: at line 18: touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
+ touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
RUN: at line 19: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp:23:18: error: DEVLIBS-NEXT: expected string not found in input
// DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
                 ^
<stdin>:2:319: note: scanning from here
 "llvm-link" -only-needed /tmp/lit-tmp-erq7on31/a.spv-a6cf48.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-erq7on31/a.spv-258b53.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x711000000000, 305)
                                                                                                                                                                                                                                                                                                                              ^
<stdin>:2:319: note: with "SECONDLLVMLINKOUT" equal to "/tmp/lit-tmp-erq7on31/a\\.spv-258b53"
 "llvm-link" -only-needed /tmp/lit-tmp-erq7on31/a.spv-a6cf48.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-erq7on31/a.spv-258b53.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x711000000000, 305)
                                                                                                                                                                                                                                                                                                                              ^
<stdin>:4:136: note: possible intended match here
 #0 0x574bd341371a in llvm::raw_fd_ostream::write_impl(char const*, unsigned long) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/raw_ostream.cpp:766:19
                                                                                                                                       ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp

Step 13 (stage2/msan check) failure: stage2/msan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86759 tests, 88 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
FAIL: Clang :: Driver/clang-sycl-linker-test.cpp (86734 of 86759)
******************** TEST 'Clang :: Driver/clang-sycl-linker-test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
RUN: at line 5: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
RUN: at line 6: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
RUN: at line 12: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv
RUN: at line 17: touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
+ touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
RUN: at line 18: touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
+ touch /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
RUN: at line 19: /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
/home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp:23:18: error: DEVLIBS-NEXT: expected string not found in input
// DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
                 ^
<stdin>:2:319: note: scanning from here
 "llvm-link" -only-needed /tmp/lit-tmp-erq7on31/a.spv-a6cf48.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-erq7on31/a.spv-258b53.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x711000000000, 305)
                                                                                                                                                                                                                                                                                                                              ^
<stdin>:2:319: note: with "SECONDLLVMLINKOUT" equal to "/tmp/lit-tmp-erq7on31/a\\.spv-258b53"
 "llvm-link" -only-needed /tmp/lit-tmp-erq7on31/a.spv-a6cf48.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-fast/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-erq7on31/a.spv-258b53.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x711000000000, 305)
                                                                                                                                                                                                                                                                                                                              ^
<stdin>:4:136: note: possible intended match here
 #0 0x574bd341371a in llvm::raw_fd_ostream::write_impl(char const*, unsigned long) /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/llvm/lib/Support/raw_ostream.cpp:766:19
                                                                                                                                       ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-fast/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp


@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder clang-ppc64le-rhel running on ppc64le-clang-rhel-test while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/145/builds/2850

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
165.242 [37/9/6252] Building CXX object tools/clang/tools/libclang/CMakeFiles/libclang.dir/CIndexer.cpp.o
165.332 [36/9/6253] Linking CXX shared library lib/libclang.so.20.0.0git
165.338 [35/9/6254] Creating library symlink lib/libclang.so.20.0git lib/libclang.so
165.377 [33/10/6255] Linking CXX executable bin/c-arcmt-test
165.390 [33/9/6256] Linking CXX executable bin/c-index-test
166.342 [33/8/6257] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/cc1gen_reproducer_main.cpp.o
168.996 [33/7/6258] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/cc1as_main.cpp.o
170.854 [33/6/6259] Building CXX object tools/clang/tools/driver/CMakeFiles/clang.dir/driver.cpp.o
174.560 [33/5/6260] Building CXX object tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o
174.625 [32/5/6261] Linking CXX executable bin/clang-sycl-linker
FAILED: bin/clang-sycl-linker 
: && /home/docker/llvm-external-buildbots/clang.17.0.6/bin/clang++ --gcc-toolchain=/gcc-toolchain/usr -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual -Wno-nested-anon-types -O3 -DNDEBUG -Wl,--color-diagnostics     -Wl,--gc-sections tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o -o bin/clang-sycl-linker  -Wl,-rpath,"\$ORIGIN/../lib:/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib:"  lib/libLLVMAArch64CodeGen.so.20.0git  lib/libLLVMAArch64AsmParser.so.20.0git  lib/libLLVMAArch64Disassembler.so.20.0git  lib/libLLVMAMDGPUCodeGen.so.20.0git  lib/libLLVMAMDGPUAsmParser.so.20.0git  lib/libLLVMAMDGPUDisassembler.so.20.0git  lib/libLLVMARMCodeGen.so.20.0git  lib/libLLVMARMAsmParser.so.20.0git  lib/libLLVMARMDisassembler.so.20.0git  lib/libLLVMAVRCodeGen.so.20.0git  lib/libLLVMAVRAsmParser.so.20.0git  lib/libLLVMAVRDesc.so.20.0git  lib/libLLVMAVRDisassembler.so.20.0git  lib/libLLVMAVRInfo.so.20.0git  lib/libLLVMBPFCodeGen.so.20.0git  lib/libLLVMBPFAsmParser.so.20.0git  lib/libLLVMBPFDesc.so.20.0git  lib/libLLVMBPFDisassembler.so.20.0git  lib/libLLVMBPFInfo.so.20.0git  lib/libLLVMHexagonCodeGen.so.20.0git  lib/libLLVMHexagonAsmParser.so.20.0git  lib/libLLVMHexagonDisassembler.so.20.0git  lib/libLLVMLanaiCodeGen.so.20.0git  lib/libLLVMLanaiAsmParser.so.20.0git  lib/libLLVMLanaiDisassembler.so.20.0git  lib/libLLVMLoongArchCodeGen.so.20.0git  lib/libLLVMLoongArchAsmParser.so.20.0git  lib/libLLVMLoongArchDisassembler.so.20.0git  lib/libLLVMMipsCodeGen.so.20.0git  lib/libLLVMMipsAsmParser.so.20.0git  lib/libLLVMMipsDesc.so.20.0git  lib/libLLVMMipsDisassembler.so.20.0git  lib/libLLVMMipsInfo.so.20.0git  lib/libLLVMMSP430CodeGen.so.20.0git  lib/libLLVMMSP430AsmParser.so.20.0git  lib/libLLVMMSP430Desc.so.20.0git  lib/libLLVMMSP430Disassembler.so.20.0git  lib/libLLVMMSP430Info.so.20.0git  lib/libLLVMNVPTXCodeGen.so.20.0git  lib/libLLVMNVPTXDesc.so.20.0git  lib/libLLVMNVPTXInfo.so.20.0git  lib/libLLVMPowerPCCodeGen.so.20.0git  lib/libLLVMPowerPCAsmParser.so.20.0git  lib/libLLVMPowerPCDesc.so.20.0git  lib/libLLVMPowerPCDisassembler.so.20.0git  lib/libLLVMPowerPCInfo.so.20.0git  lib/libLLVMRISCVCodeGen.so.20.0git  lib/libLLVMRISCVAsmParser.so.20.0git  lib/libLLVMRISCVDisassembler.so.20.0git  lib/libLLVMSparcCodeGen.so.20.0git  lib/libLLVMSparcAsmParser.so.20.0git  lib/libLLVMSparcDesc.so.20.0git  lib/libLLVMSparcDisassembler.so.20.0git  lib/libLLVMSparcInfo.so.20.0git  lib/libLLVMSystemZCodeGen.so.20.0git  lib/libLLVMSystemZAsmParser.so.20.0git  lib/libLLVMSystemZDisassembler.so.20.0git  lib/libLLVMVECodeGen.so.20.0git  lib/libLLVMVEAsmParser.so.20.0git  lib/libLLVMVEDesc.so.20.0git  lib/libLLVMVEDisassembler.so.20.0git  lib/libLLVMVEInfo.so.20.0git  lib/libLLVMWebAssemblyCodeGen.so.20.0git  lib/libLLVMWebAssemblyAsmParser.so.20.0git  lib/libLLVMWebAssemblyDisassembler.so.20.0git  lib/libLLVMWebAssemblyUtils.so.20.0git  lib/libLLVMX86CodeGen.so.20.0git  lib/libLLVMX86AsmParser.so.20.0git  lib/libLLVMX86Desc.so.20.0git  lib/libLLVMX86Disassembler.so.20.0git  lib/libLLVMX86Info.so.20.0git  lib/libLLVMXCoreCodeGen.so.20.0git  lib/libLLVMXCoreDesc.so.20.0git  lib/libLLVMXCoreDisassembler.so.20.0git  lib/libLLVMXCoreInfo.so.20.0git  lib/libLLVMOption.so.20.0git  -lpthread  lib/libclangBasic.so.20.0git  lib/libLLVMAArch64Desc.so.20.0git  lib/libLLVMAArch64Info.so.20.0git  lib/libLLVMAArch64Utils.so.20.0git  lib/libLLVMAMDGPUDesc.so.20.0git  lib/libLLVMAMDGPUInf
o.so.20.0git  lib/libLLVMARMUtils.so.20.0git  lib/libLLVMHexagonDesc.so.20.0git  lib/libLLVMHexagonInfo.so.20.0git  lib/libLLVMLanaiDesc.so.20.0git  lib/libLLVMLanaiInfo.so.20.0git  lib/libLLVMLoongArchDesc.so.20.0git  lib/libLLVMLoongArchInfo.so.20.0git  lib/libLLVMRISCVDesc.so.20.0git  lib/libLLVMRISCVInfo.so.20.0git  lib/libLLVMSystemZDesc.so.20.0git  lib/libLLVMSystemZInfo.so.20.0git  lib/libLLVMWebAssemblyDesc.so.20.0git  lib/libLLVMWebAssemblyInfo.so.20.0git  -Wl,-rpath-link,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-rhel-test/clang-ppc64le-rhel/build/lib && :
ld.lld: error: undefined symbol: llvm::InitLLVM::InitLLVM(int&, char const**&, bool)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)

ld.lld: error: undefined symbol: llvm::sys::PrintStackTraceOnErrorSignal(llvm::StringRef, bool)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)

ld.lld: error: undefined symbol: llvm::outs()
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:((anonymous namespace)::reportError(llvm::Error))

ld.lld: error: undefined symbol: llvm::deallocate_buffer(void*, unsigned long, unsigned long)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(llvm::opt::InputArgList::~InputArgList())

ld.lld: error: undefined symbol: llvm::InitLLVM::~InitLLVM()
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)

ld.lld: error: undefined symbol: llvm::raw_ostream::write(char const*, unsigned long)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:(main)
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:((anonymous namespace)::executeCommands(llvm::StringRef, llvm::ArrayRef<llvm::StringRef>))
>>> referenced by ClangSYCLLinker.cpp
>>>               tools/clang/tools/clang-sycl-linker/CMakeFiles/clang-sycl-linker.dir/ClangSYCLLinker.cpp.o:((anonymous namespace)::executeCommands(llvm::StringRef, llvm::ArrayRef<llvm::StringRef>))
>>> referenced 16 more times

@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-bootstrap-msan running on sanitizer-buildbot5 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/164/builds/4141

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86759 tests, 88 workers --
Testing:  0.. 10
FAIL: Clang :: Driver/clang-sycl-linker-test.cpp (10605 of 86759)
******************** TEST 'Clang :: Driver/clang-sycl-linker-test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
RUN: at line 5: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
RUN: at line 6: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
RUN: at line 12: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv
RUN: at line 17: touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
+ touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
RUN: at line 18: touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
+ touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
RUN: at line 19: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp:23:18: error: DEVLIBS-NEXT: expected string not found in input
// DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
                 ^
<stdin>:2:339: note: scanning from here
 "llvm-link" -only-needed /tmp/lit-tmp-ra7iram6/a.spv-3f9a5c.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-ra7iram6/a.spv-d8e8d8.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x712000000180, 325)
                                                                                                                                                                                                                                                                                                                                                  ^
<stdin>:2:339: note: with "SECONDLLVMLINKOUT" equal to "/tmp/lit-tmp-ra7iram6/a\\.spv-d8e8d8"
 "llvm-link" -only-needed /tmp/lit-tmp-ra7iram6/a.spv-3f9a5c.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-ra7iram6/a.spv-d8e8d8.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x712000000180, 325)
                                                                                                                                                                                                                                                                                                                                                  ^
<stdin>:4:146: note: possible intended match here
 #0 0x5555556e7cf3 in llvm::raw_fd_ostream::write_impl(char const*, unsigned long) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/raw_ostream.cpp:766:19
                                                                                                                                                 ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp

Step 10 (stage2/msan check) failure: stage2/msan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86759 tests, 88 workers --
Testing:  0.. 10
FAIL: Clang :: Driver/clang-sycl-linker-test.cpp (10605 of 86759)
******************** TEST 'Clang :: Driver/clang-sycl-linker-test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
RUN: at line 5: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
RUN: at line 6: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
RUN: at line 12: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv
RUN: at line 17: touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
+ touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc
RUN: at line 18: touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
+ touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc
RUN: at line 19: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp:23:18: error: DEVLIBS-NEXT: expected string not found in input
// DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
                 ^
<stdin>:2:339: note: scanning from here
 "llvm-link" -only-needed /tmp/lit-tmp-ra7iram6/a.spv-3f9a5c.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-ra7iram6/a.spv-d8e8d8.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x712000000180, 325)
                                                                                                                                                                                                                                                                                                                                                  ^
<stdin>:2:339: note: with "SECONDLLVMLINKOUT" equal to "/tmp/lit-tmp-ra7iram6/a\\.spv-d8e8d8"
 "llvm-link" -only-needed /tmp/lit-tmp-ra7iram6/a.spv-3f9a5c.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-ra7iram6/a.spv-d8e8d8.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x712000000180, 325)
                                                                                                                                                                                                                                                                                                                                                  ^
<stdin>:4:146: note: possible intended match here
 #0 0x5555556e7cf3 in llvm::raw_fd_ostream::write_impl(char const*, unsigned long) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/raw_ostream.cpp:766:19
                                                                                                                                                 ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp

Step 14 (stage2/msan_track_origins check) failure: stage2/msan_track_origins check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86759 tests, 88 workers --
Testing:  0.. 10
FAIL: Clang :: Driver/clang-sycl-linker-test.cpp (10580 of 86759)
******************** TEST 'Clang :: Driver/clang-sycl-linker-test.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 4: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc
RUN: at line 5: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang --driver-mode=g++ -emit-llvm -c /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp -o /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc
RUN: at line 6: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc -o a.spv
RUN: at line 12: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=SIMPLE-NO-LINK
RUN: at line 17: touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib1.bc
+ touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib1.bc
RUN: at line 18: touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib2.bc
+ touch /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib2.bc
RUN: at line 19: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv 2>&1    | /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/clang-sycl-linker --dry-run -triple spirv64 /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/clang-sycl-linker-test.cpp.tmp_2.bc --library-path=/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output --device-libs=lib1.bc,lib2.bc -o a.spv
+ /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp --check-prefix=DEVLIBS
/home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp:23:18: error: DEVLIBS-NEXT: expected string not found in input
// DEVLIBS-NEXT: "{{.*}}llvm-spirv{{.*}}" {{.*}}-o a.spv [[SECONDLLVMLINKOUT]].bc
                 ^
<stdin>:2:367: note: scanning from here
 "llvm-link" -only-needed /tmp/lit-tmp-s4qdy6zf/a.spv-0a4812.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-s4qdy6zf/a.spv-45619f.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x712000000180, 353)
                                                                                                                                                                                                                                                                                                                                                                              ^
<stdin>:2:367: note: with "SECONDLLVMLINKOUT" equal to "/tmp/lit-tmp-s4qdy6zf/a\\.spv-45619f"
 "llvm-link" -only-needed /tmp/lit-tmp-s4qdy6zf/a.spv-0a4812.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib1.bc /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm_build_msan_track_origins/tools/clang/test/Driver/Output/lib2.bc -o /tmp/lit-tmp-s4qdy6zf/a.spv-45619f.bc --suppress-warningsUninitialized bytes in write at offset 13 inside [0x712000000180, 353)
                                                                                                                                                                                                                                                                                                                                                                              ^
<stdin>:4:146: note: possible intended match here
 #0 0x5d64d3d8ec83 in llvm::raw_fd_ostream::write_impl(char const*, unsigned long) /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/raw_ostream.cpp:766:19
                                                                                                                                                 ^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-bootstrap-msan/build/llvm-project/clang/test/Driver/clang-sycl-linker-test.cpp


@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder sanitizer-x86_64-linux-bootstrap-asan running on sanitizer-buildbot1 while building clang at step 2 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/52/builds/3359

Here is the relevant piece of the build log for the reference
Step 2 (annotate) failure: 'python ../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py' (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86761 of 86762 tests, 88 workers --
Testing:  0.. 10
FAIL: Clang :: Interpreter/inline-virtual.cpp (12531 of 86761)
******************** TEST 'Clang :: Interpreter/inline-virtual.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 6: cat /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang-repl -Xcc -fno-rtti -Xcc -fno-sized-deallocation      | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang-repl -Xcc -fno-rtti -Xcc -fno-sized-deallocation
+ cat /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp
JIT session error: In graph incr_module_20-jitted-objectbuffer, section .text._ZN1AC2Ei: relocation target "_ZTV1A" at address 0x6cb11830e000 is out of range of Delta32 fixup at 0x70b118c2f082 (_ZN1AC2Ei, 0x70b118c2f070 + 0x12)
JIT session error: Failed to materialize symbols: { (main, { DW.ref.__gxx_personality_v0 }) }
error: Failed to materialize symbols: { (main, { _ZN1AC2Ei, a1, DW.ref.__gxx_personality_v0, $.incr_module_20.__inits.0, __orc_init_func.incr_module_20 }) }
JIT session error: Failed to materialize symbols: { (main, { a1 }) }
error: Failed to materialize symbols: { (main, { $.incr_module_21.__inits.0, __orc_init_func.incr_module_21 }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_20 }) }
JIT session error: Failed to materialize symbols: { (main, { _ZN1AD2Ev }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_25, a2, $.incr_module_25.__inits.0 }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_25 }) }
/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp:22:11: error: CHECK: expected string not found in input
// CHECK: ~A(1)
          ^
<stdin>:1:1: note: scanning from here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl... clang-repl> clang-repl... clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
          1: clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl... clang-repl> clang-repl... clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl>  
check:22     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
>>>>>>

--

Step 10 (stage2/asan check) failure: stage2/asan check (failure)
...
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using lld-link: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/lld-link
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using ld64.lld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/ld64.lld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/llvm/config.py:506: note: using wasm-ld: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/wasm-ld
llvm-lit: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72: note: The test suite configuration requested an individual test timeout of 0 seconds but a timeout of 900 seconds was requested on the command line. Forcing timeout to be 900 seconds.
-- Testing: 86761 of 86762 tests, 88 workers --
Testing:  0.. 10
FAIL: Clang :: Interpreter/inline-virtual.cpp (12531 of 86761)
******************** TEST 'Clang :: Interpreter/inline-virtual.cpp' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 6: cat /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang-repl -Xcc -fno-rtti -Xcc -fno-sized-deallocation      | /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/clang-repl -Xcc -fno-rtti -Xcc -fno-sized-deallocation
+ cat /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp
+ /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm_build_asan/bin/FileCheck /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp
JIT session error: In graph incr_module_20-jitted-objectbuffer, section .text._ZN1AC2Ei: relocation target "_ZTV1A" at address 0x6cb11830e000 is out of range of Delta32 fixup at 0x70b118c2f082 (_ZN1AC2Ei, 0x70b118c2f070 + 0x12)
JIT session error: Failed to materialize symbols: { (main, { DW.ref.__gxx_personality_v0 }) }
error: Failed to materialize symbols: { (main, { _ZN1AC2Ei, a1, DW.ref.__gxx_personality_v0, $.incr_module_20.__inits.0, __orc_init_func.incr_module_20 }) }
JIT session error: Failed to materialize symbols: { (main, { a1 }) }
error: Failed to materialize symbols: { (main, { $.incr_module_21.__inits.0, __orc_init_func.incr_module_21 }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_20 }) }
JIT session error: Failed to materialize symbols: { (main, { _ZN1AD2Ev }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_25, a2, $.incr_module_25.__inits.0 }) }
error: Failed to materialize symbols: { (main, { __orc_init_func.incr_module_25 }) }
/home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp:22:11: error: CHECK: expected string not found in input
// CHECK: ~A(1)
          ^
<stdin>:1:1: note: scanning from here
clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl... clang-repl> clang-repl... clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> 
^

Input file: <stdin>
Check file: /home/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/test/Interpreter/inline-virtual.cpp

-dump-input=help explains the following input dump.

Input was:
<<<<<<
          1: clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl... clang-repl> clang-repl... clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl> clang-repl>  
check:22     X~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
>>>>>>

--


@llvm-ci
Copy link
Collaborator

llvm-ci commented Oct 31, 2024

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-lnt running on systemz-1 while building clang at step 7 "ninja check 1".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/136/builds/1458

Here is the relevant piece of the build log for the reference
Step 7 (ninja check 1) failure: stage 1 checked (failure)
******************** TEST 'libFuzzer-s390x-default-Linux :: fuzzer-timeout.test' FAILED ********************
Exit Code: 1

Command Output (stderr):
--
RUN: at line 1: /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/lib/fuzzer  /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/TimeoutTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest
RUN: at line 2: /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/./bin/clang    -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta   --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/lib/fuzzer  /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/./bin/clang -Wthread-safety -Wthread-safety-reference -Wthread-safety-beta --driver-mode=g++ -O2 -gline-tables-only -fsanitize=address,fuzzer -I/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/lib/fuzzer /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/TimeoutEmptyTest.cpp -o /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutEmptyTest
RUN: at line 3: not  /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 2>&1 | FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=TimeoutTest
+ not /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1
+ FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=TimeoutTest
RUN: at line 12: not  /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/hi.txt 2>&1 | FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=SingleInputTimeoutTest
+ not /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/hi.txt
+ FileCheck /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/llvm/compiler-rt/test/fuzzer/fuzzer-timeout.test --check-prefix=SingleInputTimeoutTest
RUN: at line 16: /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 -timeout_exitcode=0
+ /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/stage1/runtimes/runtimes-bins/compiler-rt/test/fuzzer/S390XDefaultLinuxConfig/Output/fuzzer-timeout.test.tmp-TimeoutTest -timeout=1 -timeout_exitcode=0
INFO: Running with entropic power schedule (0xFF, 100).
INFO: Seed: 556617559
INFO: Loaded 1 modules   (13 inline 8-bit counters): 13 [0x2aa1ffcfe60, 0x2aa1ffcfe6d), 
INFO: Loaded 1 PC tables (13 PCs): 13 [0x2aa1ffcfe70,0x2aa1ffcff40), 
INFO: -max_len is not provided; libFuzzer will not generate inputs larger than 4096 bytes
INFO: A corpus is not provided, starting from an empty corpus
#2	INITED cov: 2 ft: 2 corp: 1/1b exec/s: 0 rss: 31Mb
#687	NEW    cov: 3 ft: 3 corp: 2/3b lim: 8 exec/s: 0 rss: 32Mb L: 2/2 MS: 5 CrossOver-ChangeByte-ShuffleBytes-ChangeByte-ChangeBinInt-
#733	NEW    cov: 4 ft: 4 corp: 3/4b lim: 8 exec/s: 0 rss: 32Mb L: 1/2 MS: 1 EraseBytes-
#3793	NEW    cov: 5 ft: 5 corp: 4/8b lim: 38 exec/s: 0 rss: 32Mb L: 4/4 MS: 5 ChangeByte-CrossOver-CMP-InsertByte-ChangeBinInt- DE: "\000\000"-
#3959	NEW    cov: 6 ft: 6 corp: 5/10b lim: 38 exec/s: 0 rss: 32Mb L: 2/4 MS: 1 EraseBytes-
#4311	REDUCE cov: 6 ft: 6 corp: 5/9b lim: 38 exec/s: 0 rss: 32Mb L: 3/3 MS: 2 ChangeByte-EraseBytes-
ALARM: working on the last Unit for 1 seconds
       and the timeout value is 1 (use -timeout=N to change)
MS: 3 CopyPart-CrossOver-ChangeByte-; base unit: 1955a7bcffa0306974b1971947ce8e1789c2977f
0x48,0x69,0x21,0xa,0x64,
Hi!\012d
artifact_prefix='./'; Test unit written to ./timeout-7473bfeaf9d3e13e1754fe0d77d2b5c28d7cc5f3
Base64: SGkhCmQ=
==3922379== ERROR: libFuzzer: timeout after 1 seconds
AddressSanitizer:DEADLYSIGNAL
=================================================================
AddressSanitizer:DEADLYSIGNAL
=================================================================
AddressSanitizer: CHECK failed: asan_report.cpp:199 "((current_error_.kind)) == ((kErrorKindInvalid))" (0x1, 0x0) (tid=3922379)
    <empty stack>

MS: 3 CopyPart-CrossOver-ChangeByte-; base unit: 1955a7bcffa0306974b1971947ce8e1789c2977f
0x48,0x69,0x21,0xa,0x64,
Hi!\012d
artifact_prefix='./'; Test unit written to ./crash-7473bfeaf9d3e13e1754fe0d77d2b5c28d7cc5f3
Base64: SGkhCmQ=

...

@asudarsa
Copy link
Contributor Author

asudarsa commented Nov 1, 2024

Sanitizer test failures should be resolved by #114488 (under review).
Thanks to @sarnex for the timely fix.

Sincerely

smallp-o-p pushed a commit to smallp-o-p/llvm-project that referenced this pull request Nov 3, 2024
…ice code (Part 1 of many) (llvm#112245)

This PR is one of the many PRs in the SYCL upstreaming effort focusing
on device code linking during the SYCL offload compilation process. RFC:
https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device
code linking for SYCL offload kind. It accepts SYCL device objects in
LLVM IR bitcode format and will generate a fully linked device object
that can then be wrapped and linked into the host object.

A primary use case for this tool is to perform device code linking for
objects with SYCL offload kind inside the clang-linker-wrapper. It can
also be invoked via clang driver as follows:

`clang --target=spirv64 --sycl-link input.bc`

Device code linking for SYCL offloading kind has a number of known
quirks that makes it difficult to use in a unified offloading setting.
Two of the primary issues are:
1. Several finalization steps are required to be run on the fully-linked
LLVM IR bitcode to gaurantee conformance to SYCL standards. This step is
unique to SYCL offloading compilation flow.
2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR
code generation cannot be done as part of LTO. This limitation will be
lifted once SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform
SYCL device linking.

Co-Author: Michael Toguchi
Thanks

---------

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
NoumanAmir657 pushed a commit to NoumanAmir657/llvm-project that referenced this pull request Nov 4, 2024
…ice code (Part 1 of many) (llvm#112245)

This PR is one of the many PRs in the SYCL upstreaming effort focusing
on device code linking during the SYCL offload compilation process. RFC:
https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

In this PR, we introduce a new tool that will be used to perform device
code linking for SYCL offload kind. It accepts SYCL device objects in
LLVM IR bitcode format and will generate a fully linked device object
that can then be wrapped and linked into the host object.

A primary use case for this tool is to perform device code linking for
objects with SYCL offload kind inside the clang-linker-wrapper. It can
also be invoked via clang driver as follows:

`clang --target=spirv64 --sycl-link input.bc`

Device code linking for SYCL offloading kind has a number of known
quirks that makes it difficult to use in a unified offloading setting.
Two of the primary issues are:
1. Several finalization steps are required to be run on the fully-linked
LLVM IR bitcode to gaurantee conformance to SYCL standards. This step is
unique to SYCL offloading compilation flow.
2. SPIR-V LLVM Translator tool is an extenal tool and hence SPIR-V IR
code generation cannot be done as part of LTO. This limitation will be
lifted once SPIR-V backend is available as a viable LLVM backend.

Hence, we introduce this new tool to provide a clean wrapper to perform
SYCL device linking.

Co-Author: Michael Toguchi
Thanks

---------

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
sarnex pushed a commit that referenced this pull request Apr 17, 2025
… SYCL offloads (#135683)

This PR is one of the many PRs in the SYCL upstreaming effort focusing
on device code linking during the SYCL offload compilation process. RFC:
https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

Approved PRs so far:
1. [Clang][SYCL] Introduce clang-sycl-linker to link SYCL offloading
device code (Part 1 of many) -
[Link](#112245)
2. [clang-sycl-linker] Replace llvm-link with API calls -
[Link](#133797)
3. [SYCL][SPIR-V Backend][clang-sycl-linker] Add SPIR-V backend support
inside clang-sycl-linker -
[Link](#133967)

This PR adds SYCL device code linking support to clang-linker-wrapper.

### Summary for this PR

Device code linking happens inside clang-linker-wrapper. In the current
implementation, clang-linker-wrapper does the following:

1. Extracts device code. Input_1, Input_2,.....
5. Group device code according to target devices Inputs[triple_1] = ....
Inputs[triple_2] = ....
6. For each group, i.e. Inputs[triple_i], a. Gather all the offload
kinds found inside those inputs in ActiveOffloadKinds b. Link all images
inside Inputs[triple_i] by calling clang --target=triple_i .... c.
Create a copy of that linked image for each offload kind and add it to
Output[Kind] list.

In SYCL compilation flow, there is a deviation in Step 3b. We call
device code splitting inside the 'clang --target=triple_i ....' call and
the output is now a 'packaged' file containing multiple device images.
This deviation requires us to capture the OffloadKind during the linking
stage and pass it along to the linking function (clang), so that clang
can be called with a unique option '--sycl-link' that will help us to
call 'clang-sycl-linker' under the hood (clang-sycl-linker will do SYCL
specific linking).

Our current objective is to implement an end-to-end SYCL offloading flow
and get it working. We will eventually merge our approach with the
community flow.

Thanks

---------

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
llvm-sync bot pushed a commit to arm/arm-toolchain that referenced this pull request Apr 17, 2025
…-linker for SYCL offloads (#135683)

This PR is one of the many PRs in the SYCL upstreaming effort focusing
on device code linking during the SYCL offload compilation process. RFC:
https://discourse.llvm.org/t/rfc-offloading-design-for-sycl-offload-kind-and-spir-targets/74088

Approved PRs so far:
1. [Clang][SYCL] Introduce clang-sycl-linker to link SYCL offloading
device code (Part 1 of many) -
[Link](llvm/llvm-project#112245)
2. [clang-sycl-linker] Replace llvm-link with API calls -
[Link](llvm/llvm-project#133797)
3. [SYCL][SPIR-V Backend][clang-sycl-linker] Add SPIR-V backend support
inside clang-sycl-linker -
[Link](llvm/llvm-project#133967)

This PR adds SYCL device code linking support to clang-linker-wrapper.

### Summary for this PR

Device code linking happens inside clang-linker-wrapper. In the current
implementation, clang-linker-wrapper does the following:

1. Extracts device code. Input_1, Input_2,.....
5. Group device code according to target devices Inputs[triple_1] = ....
Inputs[triple_2] = ....
6. For each group, i.e. Inputs[triple_i], a. Gather all the offload
kinds found inside those inputs in ActiveOffloadKinds b. Link all images
inside Inputs[triple_i] by calling clang --target=triple_i .... c.
Create a copy of that linked image for each offload kind and add it to
Output[Kind] list.

In SYCL compilation flow, there is a deviation in Step 3b. We call
device code splitting inside the 'clang --target=triple_i ....' call and
the output is now a 'packaged' file containing multiple device images.
This deviation requires us to capture the OffloadKind during the linking
stage and pass it along to the linking function (clang), so that clang
can be called with a unique option '--sycl-link' that will help us to
call 'clang-sycl-linker' under the hood (clang-sycl-linker will do SYCL
specific linking).

Our current objective is to implement an end-to-end SYCL offloading flow
and get it working. We will eventually merge our approach with the
community flow.

Thanks

---------

Signed-off-by: Arvind Sudarsanam <arvind.sudarsanam@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:SPIR-V clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category SYCL https://registry.khronos.org/SYCL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants