[PATCH] D129258: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (4/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
Herald added a subscriber: mgorny.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API.

This NFC patch (4/4) moves the API files from
clang/tools/clang-offload-bundler into clang/lib/Driver and
clang/include/clang/Driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129258

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.h

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -52,7 +51,6 @@
 #include 
 #include 
 #include 
-#include "OffloadBundler.h"
 
 using namespace llvm;
 using namespace llvm::object;
Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,7 +2,6 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  OffloadBundler.cpp
 
   DEPENDS
   intrinsics_gen
@@ -10,6 +9,7 @@
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
 
 add_dependencies(clang clang-offload-bundler)
Index: clang/lib/Driver/OffloadBundler.cpp
===
--- clang/lib/Driver/OffloadBundler.cpp
+++ clang/lib/Driver/OffloadBundler.cpp
@@ -1,4 +1,4 @@
-//===-- clang-offload-bundler/ClangOffloadBundler.cpp -===//
+//===- OffloadBundler.cpp - File Bundling and Unbundling --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,15 +7,16 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements an offload bundling API that bundles different files
+/// that relate with the same source code but different targets into a single
+/// one. Also the implements the opposite functionality, i.e. unbundle files
+/// previous created by this API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -53,8 +54,6 @@
 #include 
 #include 
 
-#include "OffloadBundler.h"
-
 using namespace llvm;
 using namespace llvm::object;
 
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -20,6 +20,7 @@
   DriverOptions.cpp
   Job.cpp
   Multilib.cpp
+  OffloadBundler.cpp
   OptionUtils.cpp
   Phases.cpp
   SanitizerArgs.cpp
Index: clang/include/clang/Driver/OffloadBundler.h
===
--- clang/include/clang/Driver/OffloadBundler.h
+++ clang/include/clang/Driver/OffloadBundler.h
@@ -1,4 +1,4 @@
-//===-- clang-offload-bundler/OffloadBundler.h ===//
+//=== -OffloadBundler.h - File Bundling and Unbundling --*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for l

[PATCH] D129300: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (4/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
lamb-j added reviewers: kzhuravl, scott.linder, yaxunl.
Herald added a subscriber: mgorny.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API.

This NFC patch (4/4) moves the API files from
clang/tools/clang-offload-bundler into clang/lib/Driver and
clang/include/clang/Driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129300

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.h

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -52,7 +51,6 @@
 #include 
 #include 
 #include 
-#include "OffloadBundler.h"
 
 using namespace llvm;
 using namespace llvm::object;
Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,7 +2,6 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  OffloadBundler.cpp
 
   DEPENDS
   intrinsics_gen
@@ -10,6 +9,7 @@
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
 
 add_dependencies(clang clang-offload-bundler)
Index: clang/lib/Driver/OffloadBundler.cpp
===
--- clang/lib/Driver/OffloadBundler.cpp
+++ clang/lib/Driver/OffloadBundler.cpp
@@ -1,4 +1,4 @@
-//===-- clang-offload-bundler/ClangOffloadBundler.cpp -===//
+//===- OffloadBundler.cpp - File Bundling and Unbundling --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,15 +7,16 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements an offload bundling API that bundles different files
+/// that relate with the same source code but different targets into a single
+/// one. Also the implements the opposite functionality, i.e. unbundle files
+/// previous created by this API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -53,8 +54,6 @@
 #include 
 #include 
 
-#include "OffloadBundler.h"
-
 using namespace llvm;
 using namespace llvm::object;
 
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -20,6 +20,7 @@
   DriverOptions.cpp
   Job.cpp
   Multilib.cpp
+  OffloadBundler.cpp
   OptionUtils.cpp
   Phases.cpp
   SanitizerArgs.cpp
Index: clang/include/clang/Driver/OffloadBundler.h
===
--- clang/include/clang/Driver/OffloadBundler.h
+++ clang/include/clang/Driver/OffloadBundler.h
@@ -1,4 +1,4 @@
-//===-- clang-offload-bundler/OffloadBundler.h ===//
+//=== -OffloadBundler.h - File Bundling and Unbundling --*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLV

[PATCH] D129301: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (1/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
lamb-j added reviewers: kzhuravl, scott.linder, yaxunl.
Herald added a subscriber: mgorny.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API. This will allow online and JIT compilers to
bundle and unbundle files without spawning a new process.

This NFC patch (1/4) lifts the classes and functions used to
implement the clang-offload-bundler into a separate
OffloadBundler.cpp, and defines three top-level API functions in
OfflaodBundler.h

  BundleFiles()
  UnbundleFiles()
  UnbundleArchives()

In successive patches, we aim to:

1. Refactor global command-line option variables (cl::opt, cl::list, cl::bool, 
etc.) out of the API and into a Config class that can be passed as a local 
argument.
2. Refactor dependence on the bundler executable path into an optional parameter
3. Move OffloadBundler.cpp and OffloadBundler.h into clang/lib/Driver and 
clang/include/clang/Driver


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129301

Files:
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.h

Index: clang/tools/clang-offload-bundler/OffloadBundler.h
===
--- /dev/null
+++ clang/tools/clang-offload-bundler/OffloadBundler.h
@@ -0,0 +1,45 @@
+//===-- clang-offload-bundler/OffloadBundler.h ===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This file defines a clang-offload-bundler library that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+using namespace llvm;
+using namespace llvm::object;
+
+Error BundleFiles();
+Error UnbundleFiles();
+Error UnbundleArchive();
+
+/// Obtain the offload kind, real machine triple, and an optional GPUArch
+/// out of the target information specified by the user.
+/// Bundle Entry ID (or, Offload Target String) has following components:
+///  * Offload Kind - Host, OpenMP, or HIP
+///  * Triple - Standard LLVM Triple
+///  * GPUArch (Optional) - Processor name, followed by set of ON/OFF features
+struct OffloadTargetInfo {
+  StringRef OffloadKind;
+  llvm::Triple Triple;
+  StringRef GPUArch;
+
+  OffloadTargetInfo(const StringRef Target);
+  bool hasHostKind() const;
+  bool isOffloadKindValid() const;
+  bool isOffloadKindCompatible(const StringRef TargetOffloadKind) const;
+  bool isTripleValid() const;
+  bool operator==(const OffloadTargetInfo &Target) const;
+  std::string str();
+};
+
+// List bundle IDs. Return true if an error was found.
+Error ListBundleIDsInFile(StringRef InputFileName);
Index: clang/tools/clang-offload-bundler/OffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/OffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/OffloadBundler.cpp
@@ -53,164 +53,84 @@
 #include 
 #include 
 
+#include "OffloadBundler.h"
+
 using namespace llvm;
 using namespace llvm::object;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
-ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
-InputFileNames("input",
-   cl::desc("Input file."
-" Can be specified multiple times "
-"for multiple input files."),
-   cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
-cl::desc("[,...] (deprecated)"),
-cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNames("output",
-cl::desc("Output file."
- " Can be specified multiple times "
- "for multiple output files."),
-cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
-  

[PATCH] D129301: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (1/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 442945.
lamb-j added a comment.

Adding clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129301/new/

https://reviews.llvm.org/D129301

Files:
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.h

Index: clang/tools/clang-offload-bundler/OffloadBundler.h
===
--- /dev/null
+++ clang/tools/clang-offload-bundler/OffloadBundler.h
@@ -0,0 +1,45 @@
+//===-- clang-offload-bundler/OffloadBundler.h ===//
+//
+// 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
+//
+//===--===//
+///
+/// \file
+/// This file defines a clang-offload-bundler library that bundles different
+/// files that relate with the same source code but different targets into a
+/// single one. Also the implements the opposite functionality, i.e. unbundle
+/// files previous created by this tool.
+///
+//===--===//
+
+using namespace llvm;
+using namespace llvm::object;
+
+Error BundleFiles();
+Error UnbundleFiles();
+Error UnbundleArchive();
+
+/// Obtain the offload kind, real machine triple, and an optional GPUArch
+/// out of the target information specified by the user.
+/// Bundle Entry ID (or, Offload Target String) has following components:
+///  * Offload Kind - Host, OpenMP, or HIP
+///  * Triple - Standard LLVM Triple
+///  * GPUArch (Optional) - Processor name, followed by set of ON/OFF features
+struct OffloadTargetInfo {
+  StringRef OffloadKind;
+  llvm::Triple Triple;
+  StringRef GPUArch;
+
+  OffloadTargetInfo(const StringRef Target);
+  bool hasHostKind() const;
+  bool isOffloadKindValid() const;
+  bool isOffloadKindCompatible(const StringRef TargetOffloadKind) const;
+  bool isTripleValid() const;
+  bool operator==(const OffloadTargetInfo &Target) const;
+  std::string str();
+};
+
+// List bundle IDs. Return true if an error was found.
+Error ListBundleIDsInFile(StringRef InputFileName);
Index: clang/tools/clang-offload-bundler/OffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/OffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/OffloadBundler.cpp
@@ -53,164 +53,84 @@
 #include 
 #include 
 
+#include "OffloadBundler.h"
+
 using namespace llvm;
 using namespace llvm::object;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
-
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
-ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
-InputFileNames("input",
-   cl::desc("Input file."
-" Can be specified multiple times "
-"for multiple input files."),
-   cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
-cl::desc("[,...] (deprecated)"),
-cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNames("output",
-cl::desc("Output file."
- " Can be specified multiple times "
- "for multiple output files."),
-cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
- cl::desc("[,...] (deprecated)"),
- cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-TargetNames("targets", cl::CommaSeparated,
-cl::desc("[-,...]"),
-cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
-FilesType("type", cl::Required,
-  cl::desc("Type of the files to be bundled/unbundled.\n"
-   "Current supported types are:\n"
-   "  i   - cpp-output\n"
-   "  ii  - c++-cpp-output\n"
-   "  cui - cuda/hip-output\n"
-   "  d   - dependency\n"
-   "  ll  - llvm\n"
-   "  bc  - llvm-bc\n"
-   "  s   - assembler\n"
-   "  o   - object\n"
-   "  a   - archive of objects\n"
-   "  gch - precompiled-header\n"
-   "  ast - clang AST file"),
-  cl::cat(ClangOffloadBundle

[PATCH] D129303: [clang-offload-bundler] Library-ize ClangOffloadBundler (2/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
lamb-j added reviewers: kzhuravl, scott.linder, yaxunl.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API.

This patch (2/4) introduces a Config class that locally stores the
previously global cl::opt options and arrays. This localization
will allow users to call the APIs in a multi-threaded context. This
patch also introduces an OffloadBundler class to encapsulate the
top-level API functions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129303

Files:
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.h

Index: clang/tools/clang-offload-bundler/OffloadBundler.h
===
--- clang/tools/clang-offload-bundler/OffloadBundler.h
+++ clang/tools/clang-offload-bundler/OffloadBundler.h
@@ -17,9 +17,37 @@
 using namespace llvm;
 using namespace llvm::object;
 
-Error BundleFiles();
-Error UnbundleFiles();
-Error UnbundleArchive();
+class Config {
+public:
+  bool AllowNoHost = false;
+  bool AllowMissingBundles = false;
+  bool CheckInputArchive = false;
+  bool PrintExternalCommands = false;
+  bool HipOpenmpCompatible = false;
+
+  unsigned BundleAlignment = 1;
+  unsigned HostInputIndex = ~0u;
+
+  std::string FilesType;
+  std::string BundlerExecutable;
+
+  // TODO: Convert these to llvm::SmallVector
+  std::vector TargetNames;
+  std::vector InputFileNames;
+  std::vector OutputFileNames;
+};
+
+class OffloadBundler {
+public:
+  Config *BundlerConfig;
+
+  // TODO: Add error checking from ClangOffloadBundler.cpp
+  OffloadBundler(Config *BC) : BundlerConfig(BC) {}
+
+  Error BundleFiles();
+  Error UnbundleFiles();
+  Error UnbundleArchive();
+};
 
 /// Obtain the offload kind, real machine triple, and an optional GPUArch
 /// out of the target information specified by the user.
@@ -31,8 +59,9 @@
   StringRef OffloadKind;
   llvm::Triple Triple;
   StringRef GPUArch;
+  Config *BundlerConfig;
 
-  OffloadTargetInfo(const StringRef Target);
+  OffloadTargetInfo(const StringRef Target, Config *BC);
   bool hasHostKind() const;
   bool isOffloadKindValid() const;
   bool isOffloadKindCompatible(const StringRef TargetOffloadKind) const;
@@ -42,4 +71,4 @@
 };
 
 // List bundle IDs. Return true if an error was found.
-Error ListBundleIDsInFile(StringRef InputFileName);
+Error ListBundleIDsInFile(StringRef InputFileName, Config *BundlerConfig);
Index: clang/tools/clang-offload-bundler/OffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/OffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/OffloadBundler.cpp
@@ -58,28 +58,12 @@
 using namespace llvm;
 using namespace llvm::object;
 
-extern cl::list InputFileNames;
-extern cl::list OutputFileNames;
-extern cl::list TargetNames;
-extern cl::opt FilesType;
-extern cl::opt PrintExternalCommands;
-extern cl::opt AllowMissingBundles;
-extern cl::opt BundleAlignment;
-extern cl::opt HipOpenmpCompatible;
-
 /// Magic string that marks the existence of offloading data.
 #define OFFLOAD_BUNDLER_MAGIC_STR "__CLANG_OFFLOAD_BUNDLE__"
 
-/// The index of the host input in the list of inputs.
-extern unsigned HostInputIndex;
-
-/// Whether not having host target is allowed.
-extern bool AllowNoHost;
-
-/// Path to the current binary.
-extern std::string BundlerExecutable;
-
-OffloadTargetInfo::OffloadTargetInfo(const StringRef Target) {
+OffloadTargetInfo::OffloadTargetInfo(const StringRef Target, Config *BC) {
+  // TODO: Add error checking from ClangOffloadBundler.cpp
+  BundlerConfig = BC;
   auto TargetFeatures = Target.split(':');
   auto TripleOrGPU = TargetFeatures.first.rsplit('-');
 
@@ -107,7 +91,7 @@
 bool OffloadTargetInfo::isOffloadKindCompatible(const StringRef TargetOffloadKind) const {
   if (OffloadKind == TargetOffloadKind)
 return true;
-  if (HipOpenmpCompatible) {
+  if (BundlerConfig->HipOpenmpCompatible) {
 bool HIPCompatibleWithOpenMP =
   OffloadKind.startswith_insensitive("hip") &&
   TargetOffloadKind == "openmp";
@@ -306,8 +290,12 @@
   /// Current bundle target to be written.
   std::string CurWriteBundleTarget;
 
+  /// Configuration options and arrays for this bundler job
+  Config *BundlerConfig;
+
 public:
-  BinaryFileHandler() {}
+  // TODO: Add error checking from ClangOffloadBundler.cpp
+  BinaryFileHandler(Config *BC) : BundlerConfig(BC) {}
 
   ~BinaryFileHandler() final {}
 
@@ -407,7 +395,7 @@
 HeaderSize += sizeof(OFFLOAD_BUNDLER_MAGIC_STR) - 1;
 HeaderSize += 8; // Number of Bundles
 
-for (auto &T : TargetNames) {
+for (auto &T : BundlerConfig->TargetNames) {
   HeaderSize 

[PATCH] D129304: [clang-offload-bundler] Library-ize ClangOffloadBundler (3/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
lamb-j added reviewers: kzhuravl, scott.linder, yaxunl.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API.

This patch (3/4) lifts the BundlerExecutable variable, which is
specific to the clang-offload-bundler tool, from the API, and
replaces its use with an ObjcopyPath variable. This variable
must be set in order to internally call llvm-objcopy.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129304

Files:
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.h


Index: clang/tools/clang-offload-bundler/OffloadBundler.h
===
--- clang/tools/clang-offload-bundler/OffloadBundler.h
+++ clang/tools/clang-offload-bundler/OffloadBundler.h
@@ -29,7 +29,7 @@
   unsigned HostInputIndex = ~0u;
 
   std::string FilesType;
-  std::string BundlerExecutable;
+  std::string ObjcopyPath;
 
   // TODO: Convert these to llvm::SmallVector
   std::vector TargetNames;
Index: clang/tools/clang-offload-bundler/OffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/OffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/OffloadBundler.cpp
@@ -587,15 +587,8 @@
 // link editor to remove them from linker inputs when linking executable or
 // shared library.
 
-// Find llvm-objcopy in order to create the bundle binary.
-ErrorOr Objcopy = sys::findProgramByName(
-"llvm-objcopy",
-   sys::path::parent_path(BundlerConfig->BundlerExecutable));
-if (!Objcopy)
-  Objcopy = sys::findProgramByName("llvm-objcopy");
-if (!Objcopy)
-  return createStringError(Objcopy.getError(),
-   "unable to find 'llvm-objcopy' in path");
+assert(BundlerConfig->ObjcopyPath != "" &&
+   "llvm-objcopy path not specified");
 
 // We write to the output file directly. So, we close it and use the name
 // to pass down to llvm-objcopy.
@@ -636,7 +629,7 @@
   BundlerConfig->InputFileNames[BundlerConfig->HostInputIndex]);
 ObjcopyArgs.push_back(BundlerConfig->OutputFileNames.front());
 
-if (Error Err = executeObjcopy(*Objcopy, ObjcopyArgs))
+if (Error Err = executeObjcopy(BundlerConfig->ObjcopyPath, ObjcopyArgs))
   return Err;
 
 return Error::success();
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -182,6 +182,16 @@
 BundlerExecutable =
   sys::fs::getMainExecutable(argv[0], &BundlerExecutable);
 
+  // Find llvm-objcopy in order to create the bundle binary.
+  ErrorOr Objcopy = sys::findProgramByName(
+"llvm-objcopy",
+sys::path::parent_path(BundlerExecutable));
+  if (!Objcopy)
+Objcopy = sys::findProgramByName("llvm-objcopy");
+  if (!Objcopy)
+reportError(createStringError(Objcopy.getError(),
+ "unable to find 'llvm-objcopy' in path"));
+
   if (InputFileNames.getNumOccurrences() != 0 &&
   InputFileNamesDeprecatedOpt.getNumOccurrences() != 0) {
 reportError(createStringError(
@@ -233,7 +243,7 @@
 
 Config BundlerPrint;
 BundlerPrint.PrintExternalCommands = PrintExternalCommands;
-BundlerPrint.BundlerExecutable = BundlerExecutable;
+BundlerPrint.ObjcopyPath = *Objcopy;
 doWork([&]() { return ListBundleIDsInFile(InputFileNames.front(),
  &BundlerPrint); });
 return 0;
@@ -294,7 +304,7 @@
 
 Config BundlerOpenmp;
 BundlerOpenmp.HipOpenmpCompatible = HipOpenmpCompatible;
-BundlerOpenmp.BundlerExecutable = BundlerExecutable;
+BundlerOpenmp.ObjcopyPath = *Objcopy;
 auto OffloadInfo = OffloadTargetInfo(Target, &BundlerOpenmp);
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
@@ -344,7 +354,7 @@
   BundlerConfig.BundleAlignment = BundleAlignment;
   BundlerConfig.HostInputIndex = HostInputIndex;
   BundlerConfig.FilesType = FilesType;
-  BundlerConfig.BundlerExecutable = BundlerExecutable;
+  BundlerConfig.ObjcopyPath = *Objcopy;
 
   BundlerConfig.TargetNames = TargetNames;
   BundlerConfig.InputFileNames = InputFileNames;


Index: clang/tools/clang-offload-bundler/OffloadBundler.h
===
--- clang/tools/clang-offload-bundler/OffloadBundler.h
+++ clang/tools/clang-offload-bundler/OffloadBundler.h
@@ -29,7 +29,7 @@
   unsigned HostInputIndex = ~0u;
 
   

[PATCH] D129305: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (4/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
lamb-j added reviewers: kzhuravl, scott.linder, yaxunl.
Herald added a subscriber: mgorny.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API.

This NFC patch (4/4) moves the API files from
clang/tools/clang-offload-bundler into clang/lib/Driver and
clang/include/clang/Driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129305

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/OffloadBundler.h

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -52,7 +51,6 @@
 #include 
 #include 
 #include 
-#include "OffloadBundler.h"
 
 using namespace llvm;
 using namespace llvm::object;
Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,7 +2,6 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  OffloadBundler.cpp
 
   DEPENDS
   intrinsics_gen
@@ -10,6 +9,7 @@
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
 
 add_dependencies(clang clang-offload-bundler)
Index: clang/lib/Driver/OffloadBundler.cpp
===
--- clang/lib/Driver/OffloadBundler.cpp
+++ clang/lib/Driver/OffloadBundler.cpp
@@ -1,4 +1,4 @@
-//===-- clang-offload-bundler/ClangOffloadBundler.cpp -===//
+//===- OffloadBundler.cpp - File Bundling and Unbundling --===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -7,15 +7,16 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements an offload bundling API that bundles different files
+/// that relate with the same source code but different targets into a single
+/// one. Also the implements the opposite functionality, i.e. unbundle files
+/// previous created by this API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -53,8 +54,6 @@
 #include 
 #include 
 
-#include "OffloadBundler.h"
-
 using namespace llvm;
 using namespace llvm::object;
 
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -20,6 +20,7 @@
   DriverOptions.cpp
   Job.cpp
   Multilib.cpp
+  OffloadBundler.cpp
   OptionUtils.cpp
   Phases.cpp
   SanitizerArgs.cpp
Index: clang/include/clang/Driver/OffloadBundler.h
===
--- clang/include/clang/Driver/OffloadBundler.h
+++ clang/include/clang/Driver/OffloadBundler.h
@@ -1,4 +1,4 @@
-//===-- clang-offload-bundler/OffloadBundler.h ===//
+//=== -OffloadBundler.h - File Bundling and Unbundling --*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLV

[PATCH] D129301: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (1/4)

2022-07-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.

@yaxunl Are you recommending I combine all 4 patches down into 1 patch? Or 
combine a subset of patches?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129301/new/

https://reviews.llvm.org/D129301

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-26 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8348c4095600: [clang-offload-bundler] Library-ize 
ClangOffloadBundler (authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
+  cl::list
 InputFileNames("input",
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNames("output",
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt PrintExternalCommands(
+  cl::opt PrintExternalCommands(
 "#

[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-26 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 447894.
lamb-j added a comment.

Updating driver cmake to correctly build shared library


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
+  cl::list
 InputFileNames("input",
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNames("output",
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt PrintExternalCommands(
+  cl::opt PrintExternalCommands(
 "###",
 cl::desc("Print any external commands that are to be executed "
  "instead of actually execut

[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-27 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0f3f357e26cf: [clang-offload-bundler] Library-ize 
ClangOffloadBundler (authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
+  cl::list
 InputFileNames("input",
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNames("output",
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt PrintExternalCommands(
+  cl::opt PrintExternalCommands(
 "#

[PATCH] D124151: [clang][HIP] Updating driver to enable archive/bitcode to bitcode linking when targeting HIPAMD toolchain

2022-04-21 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
lamb-j added reviewers: yaxunl, kzhuravl.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D124151

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/HIPAMD.h
  clang/test/Driver/hip-link-bc-to-bc.hip
  clang/test/Driver/hip-phases.hip

Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -520,3 +520,25 @@
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx803)
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx900)
 // MIXED2-NEG-NOT: input, "{{.*}}empty.cpp", c++
+
+// Test HIP bitcode to bitcode linking. Input should be bundled or unbundled bitcode, and
+// output should be unbundled linked bitcode
+
+// RUN: touch %T/bitcodeA.bc
+// RUN: touch %T/bitcodeB.bc
+// RUN: %clang -ccc-print-phases --hip-link -emit-llvm --cuda-device-only \
+// RUN: --offload-arch=gfx906 %T/bitcodeA.bc %T/bitcodeB.bc 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK %s
+
+// CHECK: [[A0:[0-9]+]]: input, "{{.*}}bitcodeA.bc", ir
+// CHECK: [[A1:[0-9]+]]: clang-offload-unbundler, {[[A0]]}, ir
+// CHECK: [[A2:[0-9]+]]: compiler, {[[A1]]}, ir, (device-hip, [[ARCH:gfx906]])
+// CHECK: [[A3:[0-9]+]]: backend, {[[A2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[B0:[0-9]+]]: input, "{{.*}}bitcodeB.bc", ir
+// CHECK: [[B1:[0-9]+]]: clang-offload-unbundler, {[[B0]]}, ir
+// CHECK: [[B2:[0-9]+]]: compiler, {[[B1]]}, ir, (device-hip, [[ARCH]])
+// CHECK: [[B3:[0-9]+]]: backend, {[[B2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[L0:[0-9]+]]: linker, {[[A3]], [[B3]]}, ir, (device-hip, [[ARCH]])
+// CHECK: offload, "device-hip (amdgcn-amd-amdhsa:[[ARCH]])" {[[L0]]}, ir
Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- /dev/null
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -0,0 +1,34 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+
+// Check that clang unbundles the two bitcodes and links via llvm-link
+// RUN: touch %T/bundle1.bc
+// RUN: touch %T/bundle2.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle1.bc %T/bundle2.bc \
+// RUN:   2>&1 | FileCheck -check-prefix=BITCODE %s
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle1.bc" "-output=[[B1HOST:.*\.bc]]" "-output=[[B1DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B1DEV2:.*bundle1-gfx906.bc]]" "-x" "ir" "[[B1DEV1]]"
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle2.bc" "-output=[[B2HOST:.*\.bc]]" "-output=[[B2DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B2DEV2:.*bundle2-gfx906.bc]]" "-x" "ir" "[[B2DEV1]]"
+
+// BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[B1DEV2]]" "[[B2DEV2]]"
+
+// Check that clang unbundles the bitcode and archive and links via llvm-link
+// RUN: touch %T/libhipbundle.a
+// RUN: touch %T/bundle.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle.bc -L%T -lhipbundle \
+// RUN:   2>&1 | FileCheck -check-prefix=ARCHIVE %s
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle.bc" "-output=[[HOST:.*\.bc]]" "-output=[[DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// ARCHIVE: "{{.*}}clang-{{.*}}" "-o" "[[DEV2:.*\.bc]]" "-x" "ir" "[[DEV1]]"
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}libhipbundle.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" "-output=[[AR:.*\.a]]" "-allow-missing-bundles" "-hip-openmp-compatible"
+
+// ARCHIVE: "{{.*}}llvm-link" "-o" "bundle-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[DEV2]]" "[[AR]]"
Index: clang/lib/Driver/ToolChains/HIPAMD.h
===
--- clang/lib/Driver/ToolChains/HIPAMD.h
+++ clang/lib/Driver/ToolChains/HIPAMD.h
@@ -36,6 +36,9 @@
   void constructLldCommand(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs, const InputInfo &Output,
const llvm::opt::ArgList &Args) const;
+  void constructLlvmLinkCommand(Compilation &C, const JobAction &JA,
+   const InputInfoList &Inputs, const InputInfo &Output,
+   const llvm:

[PATCH] D124151: [clang][HIP] Updating driver to enable archive/bitcode to bitcode linking when targeting HIPAMD toolchain

2022-04-21 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 424110.
lamb-j added a comment.

Adding clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124151/new/

https://reviews.llvm.org/D124151

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/HIPAMD.h
  clang/test/Driver/hip-link-bc-to-bc.hip
  clang/test/Driver/hip-phases.hip

Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -520,3 +520,25 @@
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx803)
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx900)
 // MIXED2-NEG-NOT: input, "{{.*}}empty.cpp", c++
+
+// Test HIP bitcode to bitcode linking. Input should be bundled or unbundled bitcode, and
+// output should be unbundled linked bitcode
+
+// RUN: touch %T/bitcodeA.bc
+// RUN: touch %T/bitcodeB.bc
+// RUN: %clang -ccc-print-phases --hip-link -emit-llvm --cuda-device-only \
+// RUN: --offload-arch=gfx906 %T/bitcodeA.bc %T/bitcodeB.bc 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK %s
+
+// CHECK: [[A0:[0-9]+]]: input, "{{.*}}bitcodeA.bc", ir
+// CHECK: [[A1:[0-9]+]]: clang-offload-unbundler, {[[A0]]}, ir
+// CHECK: [[A2:[0-9]+]]: compiler, {[[A1]]}, ir, (device-hip, [[ARCH:gfx906]])
+// CHECK: [[A3:[0-9]+]]: backend, {[[A2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[B0:[0-9]+]]: input, "{{.*}}bitcodeB.bc", ir
+// CHECK: [[B1:[0-9]+]]: clang-offload-unbundler, {[[B0]]}, ir
+// CHECK: [[B2:[0-9]+]]: compiler, {[[B1]]}, ir, (device-hip, [[ARCH]])
+// CHECK: [[B3:[0-9]+]]: backend, {[[B2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[L0:[0-9]+]]: linker, {[[A3]], [[B3]]}, ir, (device-hip, [[ARCH]])
+// CHECK: offload, "device-hip (amdgcn-amd-amdhsa:[[ARCH]])" {[[L0]]}, ir
Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- /dev/null
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -0,0 +1,34 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+
+// Check that clang unbundles the two bitcodes and links via llvm-link
+// RUN: touch %T/bundle1.bc
+// RUN: touch %T/bundle2.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle1.bc %T/bundle2.bc \
+// RUN:   2>&1 | FileCheck -check-prefix=BITCODE %s
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle1.bc" "-output=[[B1HOST:.*\.bc]]" "-output=[[B1DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B1DEV2:.*bundle1-gfx906.bc]]" "-x" "ir" "[[B1DEV1]]"
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle2.bc" "-output=[[B2HOST:.*\.bc]]" "-output=[[B2DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B2DEV2:.*bundle2-gfx906.bc]]" "-x" "ir" "[[B2DEV1]]"
+
+// BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[B1DEV2]]" "[[B2DEV2]]"
+
+// Check that clang unbundles the bitcode and archive and links via llvm-link
+// RUN: touch %T/libhipbundle.a
+// RUN: touch %T/bundle.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle.bc -L%T -lhipbundle \
+// RUN:   2>&1 | FileCheck -check-prefix=ARCHIVE %s
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle.bc" "-output=[[HOST:.*\.bc]]" "-output=[[DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// ARCHIVE: "{{.*}}clang-{{.*}}" "-o" "[[DEV2:.*\.bc]]" "-x" "ir" "[[DEV1]]"
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}libhipbundle.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" "-output=[[AR:.*\.a]]" "-allow-missing-bundles" "-hip-openmp-compatible"
+
+// ARCHIVE: "{{.*}}llvm-link" "-o" "bundle-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[DEV2]]" "[[AR]]"
Index: clang/lib/Driver/ToolChains/HIPAMD.h
===
--- clang/lib/Driver/ToolChains/HIPAMD.h
+++ clang/lib/Driver/ToolChains/HIPAMD.h
@@ -36,6 +36,9 @@
   void constructLldCommand(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs, const InputInfo &Output,
const llvm::opt::ArgList &Args) const;
+  void constructLlvmLinkCommand(Compilation &C, const JobAction &JA,
+   const InputInfoList &Inputs, const InputInfo &Output,
+   const llvm::opt::ArgList &Args) const;
 };
 
 } // end namespace AMDGCN
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===

[PATCH] D124151: [clang][HIP] Updating driver to enable archive/bitcode to bitcode linking when targeting HIPAMD toolchain

2022-04-21 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 424111.
lamb-j added a comment.

Adding clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124151/new/

https://reviews.llvm.org/D124151

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/HIPAMD.h
  clang/test/Driver/hip-link-bc-to-bc.hip
  clang/test/Driver/hip-phases.hip

Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -520,3 +520,25 @@
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx803)
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx900)
 // MIXED2-NEG-NOT: input, "{{.*}}empty.cpp", c++
+
+// Test HIP bitcode to bitcode linking. Input should be bundled or unbundled bitcode, and
+// output should be unbundled linked bitcode
+
+// RUN: touch %T/bitcodeA.bc
+// RUN: touch %T/bitcodeB.bc
+// RUN: %clang -ccc-print-phases --hip-link -emit-llvm --cuda-device-only \
+// RUN: --offload-arch=gfx906 %T/bitcodeA.bc %T/bitcodeB.bc 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK %s
+
+// CHECK: [[A0:[0-9]+]]: input, "{{.*}}bitcodeA.bc", ir
+// CHECK: [[A1:[0-9]+]]: clang-offload-unbundler, {[[A0]]}, ir
+// CHECK: [[A2:[0-9]+]]: compiler, {[[A1]]}, ir, (device-hip, [[ARCH:gfx906]])
+// CHECK: [[A3:[0-9]+]]: backend, {[[A2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[B0:[0-9]+]]: input, "{{.*}}bitcodeB.bc", ir
+// CHECK: [[B1:[0-9]+]]: clang-offload-unbundler, {[[B0]]}, ir
+// CHECK: [[B2:[0-9]+]]: compiler, {[[B1]]}, ir, (device-hip, [[ARCH]])
+// CHECK: [[B3:[0-9]+]]: backend, {[[B2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[L0:[0-9]+]]: linker, {[[A3]], [[B3]]}, ir, (device-hip, [[ARCH]])
+// CHECK: offload, "device-hip (amdgcn-amd-amdhsa:[[ARCH]])" {[[L0]]}, ir
Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- /dev/null
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -0,0 +1,34 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+
+// Check that clang unbundles the two bitcodes and links via llvm-link
+// RUN: touch %T/bundle1.bc
+// RUN: touch %T/bundle2.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle1.bc %T/bundle2.bc \
+// RUN:   2>&1 | FileCheck -check-prefix=BITCODE %s
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle1.bc" "-output=[[B1HOST:.*\.bc]]" "-output=[[B1DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B1DEV2:.*bundle1-gfx906.bc]]" "-x" "ir" "[[B1DEV1]]"
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle2.bc" "-output=[[B2HOST:.*\.bc]]" "-output=[[B2DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B2DEV2:.*bundle2-gfx906.bc]]" "-x" "ir" "[[B2DEV1]]"
+
+// BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[B1DEV2]]" "[[B2DEV2]]"
+
+// Check that clang unbundles the bitcode and archive and links via llvm-link
+// RUN: touch %T/libhipbundle.a
+// RUN: touch %T/bundle.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle.bc -L%T -lhipbundle \
+// RUN:   2>&1 | FileCheck -check-prefix=ARCHIVE %s
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle.bc" "-output=[[HOST:.*\.bc]]" "-output=[[DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// ARCHIVE: "{{.*}}clang-{{.*}}" "-o" "[[DEV2:.*\.bc]]" "-x" "ir" "[[DEV1]]"
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}libhipbundle.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" "-output=[[AR:.*\.a]]" "-allow-missing-bundles" "-hip-openmp-compatible"
+
+// ARCHIVE: "{{.*}}llvm-link" "-o" "bundle-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[DEV2]]" "[[AR]]"
Index: clang/lib/Driver/ToolChains/HIPAMD.h
===
--- clang/lib/Driver/ToolChains/HIPAMD.h
+++ clang/lib/Driver/ToolChains/HIPAMD.h
@@ -36,6 +36,10 @@
   void constructLldCommand(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs, const InputInfo &Output,
const llvm::opt::ArgList &Args) const;
+  void constructLlvmLinkCommand(Compilation &C, const JobAction &JA,
+const InputInfoList &Inputs,
+const InputInfo &Output,
+const llvm::opt::ArgList &Args) const;
 };
 
 } // end namespace AMDGCN
Index

[PATCH] D124151: [clang][HIP] Updating driver to enable archive/bitcode to bitcode linking when targeting HIPAMD toolchain

2022-04-21 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGafcc6baac52f: [clang][HIP] Updating driver to enable 
archive/bitcode to bitcode linking when… (authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D124151/new/

https://reviews.llvm.org/D124151

Files:
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/lib/Driver/ToolChains/HIPAMD.h
  clang/test/Driver/hip-link-bc-to-bc.hip
  clang/test/Driver/hip-phases.hip

Index: clang/test/Driver/hip-phases.hip
===
--- clang/test/Driver/hip-phases.hip
+++ clang/test/Driver/hip-phases.hip
@@ -520,3 +520,25 @@
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx803)
 // MIXED2-DAG: input, "{{.*}}empty.cpp", hip, (device-hip, gfx900)
 // MIXED2-NEG-NOT: input, "{{.*}}empty.cpp", c++
+
+// Test HIP bitcode to bitcode linking. Input should be bundled or unbundled bitcode, and
+// output should be unbundled linked bitcode
+
+// RUN: touch %T/bitcodeA.bc
+// RUN: touch %T/bitcodeB.bc
+// RUN: %clang -ccc-print-phases --hip-link -emit-llvm --cuda-device-only \
+// RUN: --offload-arch=gfx906 %T/bitcodeA.bc %T/bitcodeB.bc 2>&1 \
+// RUN: | FileCheck -check-prefixes=CHECK %s
+
+// CHECK: [[A0:[0-9]+]]: input, "{{.*}}bitcodeA.bc", ir
+// CHECK: [[A1:[0-9]+]]: clang-offload-unbundler, {[[A0]]}, ir
+// CHECK: [[A2:[0-9]+]]: compiler, {[[A1]]}, ir, (device-hip, [[ARCH:gfx906]])
+// CHECK: [[A3:[0-9]+]]: backend, {[[A2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[B0:[0-9]+]]: input, "{{.*}}bitcodeB.bc", ir
+// CHECK: [[B1:[0-9]+]]: clang-offload-unbundler, {[[B0]]}, ir
+// CHECK: [[B2:[0-9]+]]: compiler, {[[B1]]}, ir, (device-hip, [[ARCH]])
+// CHECK: [[B3:[0-9]+]]: backend, {[[B2]]}, ir, (device-hip, [[ARCH]])
+
+// CHECK: [[L0:[0-9]+]]: linker, {[[A3]], [[B3]]}, ir, (device-hip, [[ARCH]])
+// CHECK: offload, "device-hip (amdgcn-amd-amdhsa:[[ARCH]])" {[[L0]]}, ir
Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- /dev/null
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -0,0 +1,34 @@
+// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+
+// Check that clang unbundles the two bitcodes and links via llvm-link
+// RUN: touch %T/bundle1.bc
+// RUN: touch %T/bundle2.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle1.bc %T/bundle2.bc \
+// RUN:   2>&1 | FileCheck -check-prefix=BITCODE %s
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle1.bc" "-output=[[B1HOST:.*\.bc]]" "-output=[[B1DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B1DEV2:.*bundle1-gfx906.bc]]" "-x" "ir" "[[B1DEV1]]"
+
+// BITCODE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle2.bc" "-output=[[B2HOST:.*\.bc]]" "-output=[[B2DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// BITCODE: "{{.*}}clang-{{.*}}" "-o" "[[B2DEV2:.*bundle2-gfx906.bc]]" "-x" "ir" "[[B2DEV1]]"
+
+// BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[B1DEV2]]" "[[B2DEV2]]"
+
+// Check that clang unbundles the bitcode and archive and links via llvm-link
+// RUN: touch %T/libhipbundle.a
+// RUN: touch %T/bundle.bc
+
+// RUN: %clang -### --offload-arch=gfx906 --hip-link \
+// RUN:   -emit-llvm -fgpu-rdc --cuda-device-only \
+// RUN:   %T/bundle.bc -L%T -lhipbundle \
+// RUN:   2>&1 | FileCheck -check-prefix=ARCHIVE %s
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-type=bc" "-targets=host-x86_64-unknown-linux-gnu,hip-amdgcn-amd-amdhsa-gfx906" "-input={{.*}}bundle.bc" "-output=[[HOST:.*\.bc]]" "-output=[[DEV1:.*\.bc]]" "-unbundle" "-allow-missing-bundles"
+// ARCHIVE: "{{.*}}clang-{{.*}}" "-o" "[[DEV2:.*\.bc]]" "-x" "ir" "[[DEV1]]"
+
+// ARCHIVE: "{{.*}}clang-offload-bundler" "-unbundle" "-type=a" "-input={{.*}}libhipbundle.a" "-targets=hip-amdgcn-amd-amdhsa-gfx906" "-output=[[AR:.*\.a]]" "-allow-missing-bundles" "-hip-openmp-compatible"
+
+// ARCHIVE: "{{.*}}llvm-link" "-o" "bundle-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[DEV2]]" "[[AR]]"
Index: clang/lib/Driver/ToolChains/HIPAMD.h
===
--- clang/lib/Driver/ToolChains/HIPAMD.h
+++ clang/lib/Driver/ToolChains/HIPAMD.h
@@ -36,6 +36,10 @@
   void constructLldCommand(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs, const InputInfo &Output,
const llvm::opt::ArgList &Args) const;
+  void constructLlvmLinkCommand(Compilation &C, const JobAction &JA,
+const InputInfoList &I

[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-15 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
Herald added a subscriber: mgorny.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Lifting the core functionalities of the clang-offload-bundler into a
user-facing library/API. This will allow online and JIT compilers to
bundle and unbundle files without spawning a new process.

This patch lifts the classes and functions used to implement 
the clang-offload-bundler into a separate OffloadBundler.cpp,
and defines three top-level API functions in OfflaodBundler.h.

  BundleFiles()
  UnbundleFiles()
  UnbundleArchives()

This patch also introduces a Config class that locally stores the
previously global cl::opt options and arrays to allow users to call
the APIs in a multi-threaded context, and introduces an
OffloadBundler class to encapsulate the top-level API functions.

We also  lift the BundlerExecutable variable, which is specific
to the clang-offload-bundler tool, from the API, and replace
its use with an ObjcopyPath variable. This variable must be set
in order to internally call llvm-objcopy.

Finally, we move the API files from
clang/tools/clang-offload-bundler into clang/lib/Driver and
clang/include/clang/Driver.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -56,37 +55,43 @@
 using namespace llvm;
 using namespace llvm::object;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
-InputFileNames("input",
+  cl::list
+InputFileNames("input", cl::ZeroOrMore,
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
+  cl::list
+InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated, cl::ZeroOrMore,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNames("output",
+  cl::list
+OutputFileNames("output", cl::ZeroOrMore,
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNamesDeprecate

[PATCH] D129301: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (1/4)

2022-07-15 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j abandoned this revision.
lamb-j added a comment.

Abandoned in favor of combined patch: https://reviews.llvm.org/D129873


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129301/new/

https://reviews.llvm.org/D129301

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129303: [clang-offload-bundler] Library-ize ClangOffloadBundler (2/4)

2022-07-15 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j abandoned this revision.
lamb-j added a comment.

Abandoned in favor of combined patch: https://reviews.llvm.org/D129873


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129303/new/

https://reviews.llvm.org/D129303

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129304: [clang-offload-bundler] Library-ize ClangOffloadBundler (3/4)

2022-07-15 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j abandoned this revision.
lamb-j added a comment.

Abandoned in favor of combined patch: https://reviews.llvm.org/D129873


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129304/new/

https://reviews.llvm.org/D129304

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129305: [clang-offload-bundler][NFC] Library-ize ClangOffloadBundler (4/4)

2022-07-15 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j abandoned this revision.
lamb-j added a comment.

Abandoned in favor of combined patch: https://reviews.llvm.org/D129873


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129305/new/

https://reviews.llvm.org/D129305

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-19 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 445863.
lamb-j added a comment.

Moving classes into clang namespace, more specific name for config class


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
-InputFileNames("input",
+  cl::list
+InputFileNames("input", cl::ZeroOrMore,
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
+  cl::list
+InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated, cl::ZeroOrMore,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNames("output",
+  cl::list
+OutputFileNames("output", cl::ZeroOrMore,
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
+  cl::list
+OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated, cl::ZeroOrMore,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   

[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-19 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 445865.
lamb-j added a comment.

Bug fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
-InputFileNames("input",
+  cl::list
+InputFileNames("input", cl::ZeroOrMore,
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
+  cl::list
+InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated, cl::ZeroOrMore,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNames("output",
+  cl::list
+OutputFileNames("output", cl::ZeroOrMore,
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
-OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
+  cl::list
+OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated, cl::ZeroOrMore,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   cl::init(false), cl::cat(ClangOffloadBundlerCateg

[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-22 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 446945.
lamb-j added a comment.

Switching pointers to references, adding namespace comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
+  cl::list
 InputFileNames("input",
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNames("output",
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt PrintExternalCommands(
+  cl::opt PrintExternalCommands(
 "###",
 cl::desc("Print any external commands that are to be executed "
  "instead of actually exe

[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-22 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 446946.
lamb-j added a comment.

Fixing header typo


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
+  cl::list
 InputFileNames("input",
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNames("output",
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt PrintExternalCommands(
+  cl::opt PrintExternalCommands(
 "###",
 cl::desc("Print any external commands that are to be executed "
  "instead of actually executing them - for testing purposes.\n"),

[PATCH] D129873: [clang-offload-bundler] Library-ize ClangOffloadBundler

2022-07-25 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 447531.
lamb-j added a comment.

Removing trailing whitespace


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129873/new/

https://reviews.llvm.org/D129873

Files:
  clang/include/clang/Driver/OffloadBundler.h
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/OffloadBundler.cpp
  clang/tools/clang-offload-bundler/CMakeLists.txt
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/CMakeLists.txt
===
--- clang/tools/clang-offload-bundler/CMakeLists.txt
+++ clang/tools/clang-offload-bundler/CMakeLists.txt
@@ -2,15 +2,16 @@
 
 add_clang_tool(clang-offload-bundler
   ClangOffloadBundler.cpp
-  
+
   DEPENDS
   intrinsics_gen
   )
 
 set(CLANG_OFFLOAD_BUNDLER_LIB_DEPS
   clangBasic
+  clangDriver
   )
-  
+
 add_dependencies(clang clang-offload-bundler)
 
 clang_target_link_libraries(clang-offload-bundler
Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -7,15 +7,14 @@
 //===--===//
 ///
 /// \file
-/// This file implements a clang-offload-bundler that bundles different
-/// files that relate with the same source code but different targets into a
-/// single one. Also the implements the opposite functionality, i.e. unbundle
-/// files previous created by this tool.
+/// This file implements a stand-alone clang-offload-bundler tool using the
+/// OffloadBundler API.
 ///
 //===--===//
 
 #include "clang/Basic/Cuda.h"
 #include "clang/Basic/Version.h"
+#include "clang/Driver/OffloadBundler.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/SmallVector.h"
@@ -55,38 +54,45 @@
 
 using namespace llvm;
 using namespace llvm::object;
+using namespace clang;
 
-static cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
+static void PrintVersion(raw_ostream &OS) {
+  OS << clang::getClangToolFullVersion("clang-offload-bundler") << '\n';
+}
+
+int main(int argc, const char **argv) {
+
+  cl::opt Help("h", cl::desc("Alias for -help"), cl::Hidden);
 
-// Mark all our options with this category, everything else (except for -version
-// and -help) will be hidden.
-static cl::OptionCategory
+  // Mark all our options with this category, everything else (except for
+  // -version and -help) will be hidden.
+  cl::OptionCategory
 ClangOffloadBundlerCategory("clang-offload-bundler options");
-static cl::list
+  cl::list
 InputFileNames("input",
cl::desc("Input file."
 " Can be specified multiple times "
 "for multiple input files."),
cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 InputFileNamesDeprecatedOpt("inputs", cl::CommaSeparated,
 cl::desc("[,...] (deprecated)"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNames("output",
 cl::desc("Output file."
  " Can be specified multiple times "
  "for multiple output files."),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 OutputFileNamesDeprecatedOpt("outputs", cl::CommaSeparated,
  cl::desc("[,...] (deprecated)"),
  cl::cat(ClangOffloadBundlerCategory));
-static cl::list
+  cl::list
 TargetNames("targets", cl::CommaSeparated,
 cl::desc("[-,...]"),
 cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 FilesType("type", cl::Required,
   cl::desc("Type of the files to be bundled/unbundled.\n"
"Current supported types are:\n"
@@ -102,1265 +108,34 @@
"  gch - precompiled-header\n"
"  ast - clang AST file"),
   cl::cat(ClangOffloadBundlerCategory));
-static cl::opt
+  cl::opt
 Unbundle("unbundle",
  cl::desc("Unbundle bundled file into several output files.\n"),
  cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt
+  cl::opt
 ListBundleIDs("list", cl::desc("List bundle IDs in the bundled file.\n"),
   cl::init(false), cl::cat(ClangOffloadBundlerCategory));
-
-static cl::opt PrintExternalCommands(
+  cl::opt PrintExternalCommands(
 "###",
 cl::desc("Print any external commands that are to be executed "
  "instead of actually executing them - for testing purp

[PATCH] D137175: [Driver][test] Remove one more obselete REQUIRES: clang-driver

2022-11-01 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

These were globally removed by 63fbc77 
 but this 
one was
inadvertently re-added by afcc6ba 
 just 
after that patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137175

Files:
  clang/test/Driver/hip-link-bc-to-bc.hip


Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- clang/test/Driver/hip-link-bc-to-bc.hip
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -1,4 +1,4 @@
-// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+// REQUIRES: x86-registered-target, amdgpu-registered-target
 
 // Check that clang unbundles the two bitcodes and links via llvm-link
 // RUN: touch %T/bundle1.bc


Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- clang/test/Driver/hip-link-bc-to-bc.hip
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -1,4 +1,4 @@
-// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target
+// REQUIRES: x86-registered-target, amdgpu-registered-target
 
 // Check that clang unbundles the two bitcodes and links via llvm-link
 // RUN: touch %T/bundle1.bc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137275: [Driver][test] Fix test by creating empty archive instead of empty file

2022-11-02 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
lamb-j added a reviewer: yaxunl.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D137275

Files:
  clang/test/Driver/hip-link-bc-to-bc.hip


Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- clang/test/Driver/hip-link-bc-to-bc.hip
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -1,6 +1,4 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
-// See issue #58711
-// XFAIL: *
 
 // Check that clang unbundles the two bitcodes and links via llvm-link
 // RUN: rm -rf %t && mkdir %t
@@ -21,7 +19,7 @@
 // BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" 
"[[B1DEV2]]" "[[B2DEV2]]"
 
 // Check that clang unbundles the bitcode and archive and links via llvm-link
-// RUN: touch %t/libhipbundle.a
+// RUN: ar rc %t/libhipbundle.a
 // RUN: touch %t/bundle.bc
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu --offload-arch=gfx906 
--hip-link \


Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- clang/test/Driver/hip-link-bc-to-bc.hip
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -1,6 +1,4 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
-// See issue #58711
-// XFAIL: *
 
 // Check that clang unbundles the two bitcodes and links via llvm-link
 // RUN: rm -rf %t && mkdir %t
@@ -21,7 +19,7 @@
 // BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[B1DEV2]]" "[[B2DEV2]]"
 
 // Check that clang unbundles the bitcode and archive and links via llvm-link
-// RUN: touch %t/libhipbundle.a
+// RUN: ar rc %t/libhipbundle.a
 // RUN: touch %t/bundle.bc
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu --offload-arch=gfx906 --hip-link \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141551: Require input target triples to have Environment field

2023-01-11 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141551

Files:
  clang/lib/Driver/OffloadBundler.cpp


Index: clang/lib/Driver/OffloadBundler.cpp
===
--- clang/lib/Driver/OffloadBundler.cpp
+++ clang/lib/Driver/OffloadBundler.cpp
@@ -107,7 +107,8 @@
 }
 
 bool OffloadTargetInfo::isTripleValid() const {
-  return !Triple.str().empty() && Triple.getArch() != Triple::UnknownArch;
+  return !Triple.str().empty() && Triple.getArch() != Triple::UnknownArch &&
+Triple.hasEnvironment();
 }
 
 bool OffloadTargetInfo::operator==(const OffloadTargetInfo &Target) const {


Index: clang/lib/Driver/OffloadBundler.cpp
===
--- clang/lib/Driver/OffloadBundler.cpp
+++ clang/lib/Driver/OffloadBundler.cpp
@@ -107,7 +107,8 @@
 }
 
 bool OffloadTargetInfo::isTripleValid() const {
-  return !Triple.str().empty() && Triple.getArch() != Triple::UnknownArch;
+  return !Triple.str().empty() && Triple.getArch() != Triple::UnknownArch &&
+Triple.hasEnvironment();
 }
 
 bool OffloadTargetInfo::operator==(const OffloadTargetInfo &Target) const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141551: Require input target triples to have Environment field

2023-01-12 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j abandoned this revision.
lamb-j added a comment.

We're ok with env field being blank, so this doesn't accomplish what we need


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141551/new/

https://reviews.llvm.org/D141551

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158582: WIP: [AMDGPU] Respect unresolved symbol option if forwarded to linker

2023-08-22 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
Herald added subscribers: cfe-commits, kerbowa, tpr, dstuttard, yaxunl, 
jvesely, kzhuravl.
Herald added projects: clang, All.
lamb-j requested review of this revision.
Herald added subscribers: MaskRay, wdng.

Previously, for linking in amdgpu contexts, we always supplied the
--no-undefined option to lld. However, if a user supplies a
"-Wl,--unresolved-symbols=*" or "-Xlinker --unresolved-symbols=*"
option to a clang invocation, that option is now respected over the
default --no-undefined.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158582

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji 
-nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl 
-Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | 
FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker 
--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck 
-check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -560,7 +560,20 @@
   else if (Args.hasArg(options::OPT_mcpu_EQ))
 CmdArgs.push_back(Args.MakeArgString(
 "-plugin-opt=mcpu=" + Args.getLastArgValue(options::OPT_mcpu_EQ)));
-  CmdArgs.push_back("--no-undefined");
+
+  // If the user has manually passed -Wl,--unresolved-symbols=* as a linker
+  // option, we should not add --no-undefined
+  bool UnresolvedOpt = false;
+  for (auto A : Args)
+if (A->getOption().matches(options::OPT_Wl_COMMA) ||
+ A->getOption().matches(options::OPT_Xlinker))
+  for (StringRef V : A->getValues())
+if (V.contains("unresolved-symbols"))
+  UnresolvedOpt = true;
+
+  if (!UnresolvedOpt)
+CmdArgs.push_back("--no-undefined");
+
   CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=am

[PATCH] D158582: [AMDGPU] Respect unresolved symbol option if forwarded to linker

2023-08-23 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.

Is void amdgpu::Linker::ConstructJob() constructing a job for the host linker 
or the device linker? Or both?

> The `-Wl` and `-Xlinker` options are intended for the host linker and we 
> intentionally do not pass them to the device linker.

In the example I'm testing, both -Wl and -Xlinker result in a forwarded option 
to the lld invocation. However, when testing with `-Xoffload-linker` , I just 
get the following:

  warning: argument unused during compilation: '-Xoffload-linker 
--unresolved-symbols=ignore-all' [-Wunused-command-line-argument]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158582/new/

https://reviews.llvm.org/D158582

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D158582: WIP: [AMDGPU] Respect unresolved symbol option if forwarded to linker

2023-08-23 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j retitled this revision from "[AMDGPU] Respect unresolved symbol option 
if forwarded to linker" to "WIP: [AMDGPU] Respect unresolved symbol option if 
forwarded to linker".
lamb-j edited the summary of this revision.
lamb-j updated this revision to Diff 552773.
lamb-j planned changes to this revision.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158582/new/

https://reviews.llvm.org/D158582

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji 
-nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl 
-Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | 
FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker 
--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck 
-check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -551,6 +551,9 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
+  CmdArgs.push_back("--no-undefined");
+  CmdArgs.push_back("-shared");
+
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -560,8 +563,7 @@
   else if (Args.hasArg(options::OPT_mcpu_EQ))
 CmdArgs.push_back(Args.MakeArgString(
 "-plugin-opt=mcpu=" + Args.getLastArgValue(options::OPT_mcpu_EQ)));
-  CmdArgs.push_back("--no-undefined");
-  CmdArgs.push_back("-shared");
+
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(std::make_unique(


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker --unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Drive

[PATCH] D158582: [AMDGPU] Respect unresolved symbol option if forwarded to linker

2023-08-23 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j retitled this revision from "WIP: [AMDGPU] Respect unresolved symbol 
option if forwarded to linker" to "[AMDGPU] Respect unresolved symbol option if 
forwarded to linker".
lamb-j updated this revision to Diff 552775.
lamb-j requested review of this revision.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158582/new/

https://reviews.llvm.org/D158582

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji 
-nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl 
-Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | 
FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker 
--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck 
-check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -551,6 +551,9 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
+  CmdArgs.push_back("--no-undefined");
+  CmdArgs.push_back("-shared");
+
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -560,8 +563,6 @@
   else if (Args.hasArg(options::OPT_mcpu_EQ))
 CmdArgs.push_back(Args.MakeArgString(
 "-plugin-opt=mcpu=" + Args.getLastArgValue(options::OPT_mcpu_EQ)));
-  CmdArgs.push_back("--no-undefined");
-  CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(std::make_unique(


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker --unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
=

[PATCH] D158582: [AMDGPU] Prepend --no-undefined option for linker instead of append

2023-08-23 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j retitled this revision from "[AMDGPU] Respect unresolved symbol option 
if forwarded to linker" to "[AMDGPU] Prepend --no-undefined option for linker 
instead of append".
lamb-j updated this revision to Diff 552777.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158582/new/

https://reviews.llvm.org/D158582

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji 
-nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl 
-Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | 
FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker 
--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck 
-check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -551,6 +551,9 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
+  CmdArgs.push_back("--no-undefined");
+  CmdArgs.push_back("-shared");
+
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -560,8 +563,6 @@
   else if (Args.hasArg(options::OPT_mcpu_EQ))
 CmdArgs.push_back(Args.MakeArgString(
 "-plugin-opt=mcpu=" + Args.getLastArgValue(options::OPT_mcpu_EQ)));
-  CmdArgs.push_back("--no-undefined");
-  CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(std::make_unique(


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker --unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
=

[PATCH] D158582: [AMDGPU] Prepend --no-undefined option for linker instead of append

2023-08-23 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 552803.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158582/new/

https://reviews.llvm.org/D158582

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} 
"--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji 
-nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl 
-Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | 
FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker 
--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck 
-check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} 
"--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -551,6 +551,9 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
+  CmdArgs.push_back("--no-undefined");
+  CmdArgs.push_back("-shared");
+
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -560,8 +563,6 @@
   else if (Args.hasArg(options::OPT_mcpu_EQ))
 CmdArgs.push_back(Args.MakeArgString(
 "-plugin-opt=mcpu=" + Args.getLastArgValue(options::OPT_mcpu_EQ)));
-  CmdArgs.push_back("--no-undefined");
-  CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(std::make_unique(


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker --unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} "--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU

[PATCH] D158582: [AMDGPU] Prepend --no-undefined option for linker instead of append

2023-08-23 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0661533e4168: [AMDGPU] Prepend --no-undefined option for 
linker instead of append (authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158582/new/

https://reviews.llvm.org/D158582

Files:
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/test/Driver/amdgpu-toolchain-opencl.cl
  clang/test/Driver/amdgpu-toolchain.c


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck 
-check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} 
"--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck 
-check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji 
-nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl 
-Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | 
FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker 
--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck 
-check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} 
"--unresolved-symbols=ignore-all"
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -551,6 +551,9 @@
 
   std::string Linker = getToolChain().GetProgramPath(getShortName());
   ArgStringList CmdArgs;
+  CmdArgs.push_back("--no-undefined");
+  CmdArgs.push_back("-shared");
+
   addLinkerCompressDebugSectionsOption(getToolChain(), Args, CmdArgs);
   Args.AddAllArgs(CmdArgs, options::OPT_L);
   AddLinkerInputs(getToolChain(), Inputs, Args, CmdArgs, JA);
@@ -560,8 +563,6 @@
   else if (Args.hasArg(options::OPT_mcpu_EQ))
 CmdArgs.push_back(Args.MakeArgString(
 "-plugin-opt=mcpu=" + Args.getLastArgValue(options::OPT_mcpu_EQ)));
-  CmdArgs.push_back("--no-undefined");
-  CmdArgs.push_back("-shared");
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
   C.addCommand(std::make_unique(


Index: clang/test/Driver/amdgpu-toolchain.c
===
--- clang/test/Driver/amdgpu-toolchain.c
+++ clang/test/Driver/amdgpu-toolchain.c
@@ -10,6 +10,14 @@
 
 // DWARF_VER: "-dwarf-version=5"
 
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Wl,--unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+// RUN: %clang -### --target=amdgcn--amdhsa -x assembler \
+// RUN:  -Xlinker --unresolved-symbols=ignore-all %s 2>&1 | FileCheck -check-prefix=AS_LINK_UR %s
+
+// AS_LINK_UR: "-cc1as"
+// AS_LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} "--unresolved-symbols=ignore-all"
+
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
 // RUN:   -L. -flto -fconvergent-functions %s 2>&1 | FileCheck -check-prefixes=LTO,MCPU %s
 // RUN: %clang -### --target=amdgcn-amd-amdhsa -mcpu=gfx906 -nogpulib \
Index: clang/test/Driver/amdgpu-toolchain-opencl.cl
===
--- clang/test/Driver/amdgpu-toolchain-opencl.cl
+++ clang/test/Driver/amdgpu-toolchain-opencl.cl
@@ -28,3 +28,7 @@
 
 // RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK %s
 // CHK-LINK: ld.lld{{.*}} "--no-undefined" "-shared"
+
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Wl,--unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// RUN: %clang -### --target=amdgcn-amd-amdhsa-opencl -Xlinker --unresolved-symbols=ignore-all -x cl -mcpu=fiji -nogpulib %s 2>&1 | FileCheck -check-prefix=CHK-LINK_UR %s
+// CHK-LINK_UR: ld.lld{{.*}} "--no-undefined"{{.*}} "--unresolved-symbol

[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 505227.
lamb-j added a comment.

Updating commit message


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler-standardize.c
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -313,6 +313,8 @@
   llvm::DenseSet ParsedTargets;
   // Map {offload-kind}-{triple} to target IDs.
   std::map> TargetIDs;
+  // Standardize target names to include env field
+  std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
   reportError(createStringError(errc::invalid_argument,
@@ -324,6 +326,8 @@
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
 
+StandardizedTargetNames.push_back(OffloadInfo.str());
+
 if (!KindIsValid || !TripleIsValid) {
   SmallVector Buf;
   raw_svector_ostream Msg(Buf);
@@ -348,6 +352,9 @@
 
 ++Index;
   }
+
+  BundlerConfig.TargetNames = StandardizedTargetNames;
+
   for (const auto &TargetID : TargetIDs) {
 if (auto ConflictingTID =
 clang::getConflictTargetIDCombination(TargetID.second)) {
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,5 +1,4 @@
 // REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
 
 //
@@ -297,11 +296,11 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDL

[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-14 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe48ae0dbd80d: [clang-offload-bundler] Standardize TargetID 
field for bundler (authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler-standardize.c
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -313,6 +313,8 @@
   llvm::DenseSet ParsedTargets;
   // Map {offload-kind}-{triple} to target IDs.
   std::map> TargetIDs;
+  // Standardize target names to include env field
+  std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
   reportError(createStringError(errc::invalid_argument,
@@ -324,6 +326,8 @@
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
 
+StandardizedTargetNames.push_back(OffloadInfo.str());
+
 if (!KindIsValid || !TripleIsValid) {
   SmallVector Buf;
   raw_svector_ostream Msg(Buf);
@@ -348,6 +352,9 @@
 
 ++Index;
   }
+
+  BundlerConfig.TargetNames = StandardizedTargetNames;
+
   for (const auto &TargetID : TargetIDs) {
 if (auto ConflictingTID =
 clang::getConflictTargetIDCombination(TargetID.second)) {
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,5 +1,4 @@
 // REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
 
 //
@@ -297,11 +296,11 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_

[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-15 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.
Herald added a subscriber: jplehr.

Needed to update this after landing with two quick patch fixes:

  [clang-offload-bundler] Fix test failures and document typo (65fb636bd462)
  
  [clang-offload-bundler] Fix error with regex in bundler test (f3b991202689)

There were also two quick fixes by others that overlapped but got in before my 
fixes:

  Mark test modified in e48ae0d as XFAIL for PS4/PS5 until the author ... 
(768211f48f2d)
  
  clang/test/Driver/clang-offload-bundler-standardize.c REQUIRES asserts. 
(fixup D145770) (d4a4d0d79127)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-27 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.

In D145770#4220246 , @mdtoguchi wrote:

> @lamb-j - is it expected for any bundled objects created before your change 
> without the explicit env field to be able to be unbundled?  Newly generated 
> bundles work as expected given similar `-target` values, but older generated 
> binaries fail to unbundle the target given equivalent commands.  Is it 
> possible to provide the ability to do so?

That should still be supported. The target triple for the old bundle should be 
converted to the new format (and compared against the Target-ID that was also 
converted to the new format). Can you provide an example to recreate the 
failure? I just tried one example locally and didn't hit any failures:

  old-clang -c --offload-arch=gfx906 -emit-llvm -fgpu-rdc --gpu-bundle-output 
square.hip
  new-clang-offload-bundler -unbundle -type=bc 
-targets=hip-amdgcn-amd-amdhsa-gfx906 -input=square.bc 
-output=square-hip-gfx906.bc -allow-missing-bundles 
-debug-only=CodeObjectCompatibility
  
  Compatible: Exact match:[CodeObject: hip-amdgcn-amd-amdhsa--gfx906]   
  :   [Target: hip-amdgcn-amd-amdhsa--gfx906]


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-10 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
Herald added a subscriber: kosarev.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

The bundler accepts both of the following for the --target option:

  hip-amdgcn-amd-amdhsa-gfx900(no ABI field)
  hip-amdgcn-amd-amdhsa--gfx900   (blank ABI field)

The ABI field is defined as optional for Triples in Triple.h.
However, in this patch we update the bundler to internally
standardize to include the ABI field. While users aren't required
to specify an ABI field when listing targets on the commandline,
bundles generated by the offload-bundler will include the ABI
field.

This standardization simplifies things for APIs that deal with
bundles generated by the clang-offload-bundler tool.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145770

Files:
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp


Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -313,6 +313,8 @@
   llvm::DenseSet ParsedTargets;
   // Map {offload-kind}-{triple} to target IDs.
   std::map> TargetIDs;
+  // Standardize target names to include ABI field
+  std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
   reportError(createStringError(errc::invalid_argument,
@@ -324,6 +326,8 @@
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
 
+StandardizedTargetNames.push_back(OffloadInfo.str());
+
 if (!KindIsValid || !TripleIsValid) {
   SmallVector Buf;
   raw_svector_ostream Msg(Buf);
@@ -348,6 +352,9 @@
 
 ++Index;
   }
+
+  BundlerConfig.TargetNames = StandardizedTargetNames;
+
   for (const auto &TargetID : TargetIDs) {
 if (auto ConflictingTID =
 clang::getConflictTargetIDCombination(TargetID.second)) {
Index: clang/test/Driver/clang-offload-bundler-asserts-on.c
===
--- clang/test/Driver/clang-offload-bundler-asserts-on.c
+++ clang/test/Driver/clang-offload-bundler-asserts-on.c
@@ -21,12 +21,12 @@
 
 // Tests to check compatibility between Bundle Entry ID formats i.e. between 
presence/absence of extra hyphen in case of missing environment field
 // RUN: clang-offload-bundler -unbundle -type=a 
-targets=openmp-amdgcn-amd-amdhsa--gfx906,openmp-amdgcn-amd-amdhsa-gfx908 
-input=%t.input-archive.a -output=%t-archive-gfx906-simple.a 
-output=%t-archive-gfx908-simple.a -debug-only=CodeObjectCompatibility 2>&1 | 
FileCheck %s -check-prefix=BUNDLECOMPATIBILITY
-// BUNDLECOMPATIBILITY: Compatible: Exact match:[CodeObject: 
openmp-amdgcn-amd-amdhsa-gfx906]   :   [Target: 
openmp-amdgcn-amd-amdhsa--gfx906]
-// BUNDLECOMPATIBILITY: Compatible: Exact match:[CodeObject: 
openmp-amdgcn-amd-amdhsa--gfx908]  :   [Target: 
openmp-amdgcn-amd-amdhsa-gfx908]
+// BUNDLECOMPATIBILITY: Compatible: Exact match:[CodeObject: 
openmp-amdgcn-amd-amdhsa--gfx906]  :   [Target: 
openmp-amdgcn-amd-amdhsa--gfx906]
+// BUNDLECOMPATIBILITY: Compatible: Exact match:[CodeObject: 
openmp-amdgcn-amd-amdhsa--gfx908]  :   [Target: 
openmp-amdgcn-amd-amdhsa--gfx908]
 
 // RUN: clang-offload-bundler -unbundle -type=a 
-targets=hip-amdgcn-amd-amdhsa--gfx906,hipv4-amdgcn-amd-amdhsa-gfx908 
-input=%t.input-archive.a -output=%t-hip-archive-gfx906-simple.a 
-output=%t-hipv4-archive-gfx908-simple.a -hip-openmp-compatible 
-debug-only=CodeObjectCompatibility 2>&1 | FileCheck %s 
-check-prefix=HIPOpenMPCOMPATIBILITY
-// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible
[CodeObject: openmp-amdgcn-amd-amdhsa-gfx906]   :   [Target: 
hip-amdgcn-amd-amdhsa--gfx906]
-// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible
[CodeObject: openmp-amdgcn-amd-amdhsa--gfx908]  :   [Target: 
hipv4-amdgcn-amd-amdhsa-gfx908]
+// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible
[CodeObject: openmp-amdgcn-amd-amdhsa--gfx906]  :   [Target: 
hip-amdgcn-amd-amdhsa--gfx906]
+// HIPOpenMPCOMPATIBILITY: Compatible: Code Objects are compatible
[CodeObject: openmp-amdgcn-amd-amdhsa--gfx908]  :   [Target: 
hipv4-amdgcn-amd-amdhsa--gfx908]
 
 // Some code so that we can create a binary out of this file.
 int A = 0;
Index: clang/lib/Driver/OffloadBundler.cpp
===
--- clang/lib/Driver/OffloadBundler.cpp
+++ clang/lib/Driver/OffloadBundler.cpp
@@ -72,12 +72,22 @@
   if (clang::StringToCudaArch(Trip

[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-10 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.

In D145770#4184996 , @yaxunl wrote:

> The description needs fix. "ABI field" should be "environment component".
>
> Also, we need a clang-offload-bundler test which bundles with a non-canonical 
> triple and unbundles with a canonical triple and vice versa.

I'm not sure if we can use Triple.normalize(). Here's what I got from a small 
test:

  amdgcn-amd-amdhsa  ->  amdgcn-amd-amdhsa (no env field added)
  amdgcn-amd-amdhsa- ->  amdgcn-amd-amdhsa-unknown (empty env changed to 
unknown)

Also are we sure ABI is incorrect? That's what is used here:

https://clang.llvm.org/docs/CrossCompilation.html

(I'm happy to change to environment, just double checking)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-10 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.

In D145770#4186142 , @yaxunl wrote:

> In D145770#4185658 , @lamb-j wrote:
>
>> In D145770#4184996 , @yaxunl wrote:
>>
>>> The description needs fix. "ABI field" should be "environment component".
>>>
>>> Also, we need a clang-offload-bundler test which bundles with a 
>>> non-canonical triple and unbundles with a canonical triple and vice versa.
>>
>> I'm not sure if we can use Triple.normalize(). Here's what I got from a 
>> small test:
>>
>>   amdgcn-amd-amdhsa  ->  amdgcn-amd-amdhsa (no env field added)
>>   amdgcn-amd-amdhsa- ->  amdgcn-amd-amdhsa-unknown (empty env changed to 
>> unknown)
>>
>> Also are we sure ABI is incorrect? That's what is used here:
>>
>> https://clang.llvm.org/docs/CrossCompilation.html
>>
>> (I'm happy to change to environment, just double checking)
>
> https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/TargetParser/Triple.h
>  only talks about "environment", which seems to be more accurate and 
> up-to-date.
>
> It is unfortunate that we have used our own normalization (empty string for 
> unspecified environment instead of "unknown") for triple. Looks like we have 
> to keep that for now. Ideally, HIP runtime should accept 
> "amdgcn-amd-amdhsa-unknown" in addition to "amdgcn-amd-amdhsa--" in fat 
> binary, then we could switch to the LLVM Triple normalization. But that 
> requires runtime change first. Probably we could do that in future.

It may be fine to use "unknown" instead of an empty string, I didn't test that. 
It's just that the Triple.normalize() doesn't add anything for the env field if 
there wasn't anything there to begin with. That is, it doesn't convert a 
3-field triple to a 4-field triple (it only converts a 4-field with empty 
string env to 4-field "unknown" env").

And sounds good about abi vs. env, maybe I'll add another patch to update 
CrossCompilation.html so it's more consistent with Triple.h


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-10 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 504310.
lamb-j added a comment.
Herald added a reviewer: alexander-shaposhnikov.

Adding another test, updating existing large test, and switching from ABI
to env


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

Files:
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler-standardize.c
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -313,6 +313,8 @@
   llvm::DenseSet ParsedTargets;
   // Map {offload-kind}-{triple} to target IDs.
   std::map> TargetIDs;
+  // Standardize target names to include env field
+  std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
   reportError(createStringError(errc::invalid_argument,
@@ -324,6 +326,8 @@
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
 
+StandardizedTargetNames.push_back(OffloadInfo.str());
+
 if (!KindIsValid || !TripleIsValid) {
   SmallVector Buf;
   raw_svector_ostream Msg(Buf);
@@ -348,6 +352,9 @@
 
 ++Index;
   }
+
+  BundlerConfig.TargetNames = StandardizedTargetNames;
+
   for (const auto &TargetID : TargetIDs) {
 if (auto ConflictingTID =
 clang::getConflictTargetIDCombination(TargetID.second)) {
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,5 +1,4 @@
 // REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
 
 //
@@ -297,11 +296,11 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64

[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-10 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j marked an inline comment as done.
lamb-j added inline comments.



Comment at: clang/test/Driver/clang-offload-bundler.c:2
 // REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}

Can most systems cross-compile for powerpc? This test does a lot of testing, 
seems like it would be nice to test it on other systems.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145833: Switch ABI references to env/environment

2023-03-10 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j created this revision.
Herald added a project: All.
lamb-j requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

To be consistent with Triple.h, we update references to the
optional fourth triple field from ABI to env or enviornment


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145833

Files:
  clang/docs/CrossCompilation.rst


Index: clang/docs/CrossCompilation.rst
===
--- clang/docs/CrossCompilation.rst
+++ clang/docs/CrossCompilation.rst
@@ -77,12 +77,12 @@
 go ahead, creating code for the host platform, which will break later
 on when assembling or linking.
 
-The triple has the general format ``---``, where:
+The triple has the general format ``---``, where:
  * ``arch`` = ``x86_64``, ``i386``, ``arm``, ``thumb``, ``mips``, etc.
  * ``sub`` = for ex. on ARM: ``v5``, ``v6m``, ``v7a``, ``v7m``, etc.
  * ``vendor`` = ``pc``, ``apple``, ``nvidia``, ``ibm``, etc.
  * ``sys`` = ``none``, ``linux``, ``win32``, ``darwin``, ``cuda``, etc.
- * ``abi`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
+ * ``env`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
 
 The sub-architecture options are available for their own architectures,
 of course, so "x86v7a" doesn't make sense. The vendor needs to be
@@ -97,8 +97,8 @@
 that Clang doesn't know, like ``blerg``, it'll ignore and assume
 ``unknown``, which is not always desired, so be careful.
 
-Finally, the ABI option is something that will pick default CPU/FPU,
-define the specific behaviour of your code (PCS, extensions),
+Finally, the env (enviornment) option is something that will pick default
+CPU/FPU, define the specific behaviour of your code (PCS, extensions),
 and also choose the correct library calls, etc.
 
 CPU, FPU, ABI
@@ -198,6 +198,6 @@
 uses hard-float), Clang will pick the ``armv7l-linux-gnueabi-ld``
 (which uses soft-float) and linker errors will happen.
 
-The same is true if you're compiling for different ABIs, like ``gnueabi``
-and ``androideabi``, and might even link and run, but produce run-time
-errors, which are much harder to track down and fix.
+The same is true if you're compiling for different environments, like
+``gnueabi`` and ``androideabi``, and might even link and run, but produce
+run-time errors, which are much harder to track down and fix.


Index: clang/docs/CrossCompilation.rst
===
--- clang/docs/CrossCompilation.rst
+++ clang/docs/CrossCompilation.rst
@@ -77,12 +77,12 @@
 go ahead, creating code for the host platform, which will break later
 on when assembling or linking.
 
-The triple has the general format ``---``, where:
+The triple has the general format ``---``, where:
  * ``arch`` = ``x86_64``, ``i386``, ``arm``, ``thumb``, ``mips``, etc.
  * ``sub`` = for ex. on ARM: ``v5``, ``v6m``, ``v7a``, ``v7m``, etc.
  * ``vendor`` = ``pc``, ``apple``, ``nvidia``, ``ibm``, etc.
  * ``sys`` = ``none``, ``linux``, ``win32``, ``darwin``, ``cuda``, etc.
- * ``abi`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
+ * ``env`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
 
 The sub-architecture options are available for their own architectures,
 of course, so "x86v7a" doesn't make sense. The vendor needs to be
@@ -97,8 +97,8 @@
 that Clang doesn't know, like ``blerg``, it'll ignore and assume
 ``unknown``, which is not always desired, so be careful.
 
-Finally, the ABI option is something that will pick default CPU/FPU,
-define the specific behaviour of your code (PCS, extensions),
+Finally, the env (enviornment) option is something that will pick default
+CPU/FPU, define the specific behaviour of your code (PCS, extensions),
 and also choose the correct library calls, etc.
 
 CPU, FPU, ABI
@@ -198,6 +198,6 @@
 uses hard-float), Clang will pick the ``armv7l-linux-gnueabi-ld``
 (which uses soft-float) and linker errors will happen.
 
-The same is true if you're compiling for different ABIs, like ``gnueabi``
-and ``androideabi``, and might even link and run, but produce run-time
-errors, which are much harder to track down and fix.
+The same is true if you're compiling for different environments, like
+``gnueabi`` and ``androideabi``, and might even link and run, but produce
+run-time errors, which are much harder to track down and fix.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145833: Switch ABI references to env/environment

2023-03-13 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb47d4df25c69: Switch ABI references to env/environment 
(authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145833/new/

https://reviews.llvm.org/D145833

Files:
  clang/docs/CrossCompilation.rst


Index: clang/docs/CrossCompilation.rst
===
--- clang/docs/CrossCompilation.rst
+++ clang/docs/CrossCompilation.rst
@@ -77,12 +77,12 @@
 go ahead, creating code for the host platform, which will break later
 on when assembling or linking.
 
-The triple has the general format ``---``, where:
+The triple has the general format ``---``, where:
  * ``arch`` = ``x86_64``, ``i386``, ``arm``, ``thumb``, ``mips``, etc.
  * ``sub`` = for ex. on ARM: ``v5``, ``v6m``, ``v7a``, ``v7m``, etc.
  * ``vendor`` = ``pc``, ``apple``, ``nvidia``, ``ibm``, etc.
  * ``sys`` = ``none``, ``linux``, ``win32``, ``darwin``, ``cuda``, etc.
- * ``abi`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
+ * ``env`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
 
 The sub-architecture options are available for their own architectures,
 of course, so "x86v7a" doesn't make sense. The vendor needs to be
@@ -97,8 +97,8 @@
 that Clang doesn't know, like ``blerg``, it'll ignore and assume
 ``unknown``, which is not always desired, so be careful.
 
-Finally, the ABI option is something that will pick default CPU/FPU,
-define the specific behaviour of your code (PCS, extensions),
+Finally, the env (enviornment) option is something that will pick default
+CPU/FPU, define the specific behaviour of your code (PCS, extensions),
 and also choose the correct library calls, etc.
 
 CPU, FPU, ABI
@@ -198,6 +198,6 @@
 uses hard-float), Clang will pick the ``armv7l-linux-gnueabi-ld``
 (which uses soft-float) and linker errors will happen.
 
-The same is true if you're compiling for different ABIs, like ``gnueabi``
-and ``androideabi``, and might even link and run, but produce run-time
-errors, which are much harder to track down and fix.
+The same is true if you're compiling for different environments, like
+``gnueabi`` and ``androideabi``, and might even link and run, but produce
+run-time errors, which are much harder to track down and fix.


Index: clang/docs/CrossCompilation.rst
===
--- clang/docs/CrossCompilation.rst
+++ clang/docs/CrossCompilation.rst
@@ -77,12 +77,12 @@
 go ahead, creating code for the host platform, which will break later
 on when assembling or linking.
 
-The triple has the general format ``---``, where:
+The triple has the general format ``---``, where:
  * ``arch`` = ``x86_64``, ``i386``, ``arm``, ``thumb``, ``mips``, etc.
  * ``sub`` = for ex. on ARM: ``v5``, ``v6m``, ``v7a``, ``v7m``, etc.
  * ``vendor`` = ``pc``, ``apple``, ``nvidia``, ``ibm``, etc.
  * ``sys`` = ``none``, ``linux``, ``win32``, ``darwin``, ``cuda``, etc.
- * ``abi`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
+ * ``env`` = ``eabi``, ``gnu``, ``android``, ``macho``, ``elf``, etc.
 
 The sub-architecture options are available for their own architectures,
 of course, so "x86v7a" doesn't make sense. The vendor needs to be
@@ -97,8 +97,8 @@
 that Clang doesn't know, like ``blerg``, it'll ignore and assume
 ``unknown``, which is not always desired, so be careful.
 
-Finally, the ABI option is something that will pick default CPU/FPU,
-define the specific behaviour of your code (PCS, extensions),
+Finally, the env (enviornment) option is something that will pick default
+CPU/FPU, define the specific behaviour of your code (PCS, extensions),
 and also choose the correct library calls, etc.
 
 CPU, FPU, ABI
@@ -198,6 +198,6 @@
 uses hard-float), Clang will pick the ``armv7l-linux-gnueabi-ld``
 (which uses soft-float) and linker errors will happen.
 
-The same is true if you're compiling for different ABIs, like ``gnueabi``
-and ``androideabi``, and might even link and run, but produce run-time
-errors, which are much harder to track down and fix.
+The same is true if you're compiling for different environments, like
+``gnueabi`` and ``androideabi``, and might even link and run, but produce
+run-time errors, which are much harder to track down and fix.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-13 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j updated this revision to Diff 504893.
lamb-j added a comment.

Adding note to documentation


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

Files:
  clang/docs/ClangOffloadBundler.rst
  clang/lib/Driver/OffloadBundler.cpp
  clang/test/Driver/clang-offload-bundler-asserts-on.c
  clang/test/Driver/clang-offload-bundler-standardize.c
  clang/test/Driver/clang-offload-bundler.c
  clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp

Index: clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
===
--- clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
+++ clang/tools/clang-offload-bundler/ClangOffloadBundler.cpp
@@ -313,6 +313,8 @@
   llvm::DenseSet ParsedTargets;
   // Map {offload-kind}-{triple} to target IDs.
   std::map> TargetIDs;
+  // Standardize target names to include env field
+  std::vector StandardizedTargetNames;
   for (StringRef Target : TargetNames) {
 if (ParsedTargets.contains(Target)) {
   reportError(createStringError(errc::invalid_argument,
@@ -324,6 +326,8 @@
 bool KindIsValid = OffloadInfo.isOffloadKindValid();
 bool TripleIsValid = OffloadInfo.isTripleValid();
 
+StandardizedTargetNames.push_back(OffloadInfo.str());
+
 if (!KindIsValid || !TripleIsValid) {
   SmallVector Buf;
   raw_svector_ostream Msg(Buf);
@@ -348,6 +352,9 @@
 
 ++Index;
   }
+
+  BundlerConfig.TargetNames = StandardizedTargetNames;
+
   for (const auto &TargetID : TargetIDs) {
 if (auto ConflictingTID =
 clang::getConflictTargetIDCombination(TargetID.second)) {
Index: clang/test/Driver/clang-offload-bundler.c
===
--- clang/test/Driver/clang-offload-bundler.c
+++ clang/test/Driver/clang-offload-bundler.c
@@ -1,5 +1,4 @@
 // REQUIRES: x86-registered-target
-// REQUIRES: powerpc-registered-target
 // UNSUPPORTED: target={{.*}}-darwin{{.*}}, target={{.*}}-aix{{.*}}
 
 //
@@ -297,11 +296,11 @@
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD
-// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
 
 // RUN: clang-offload-bundler -type=o -targets=host-%itanium_abi_triple,openmp-powerpc64le-ibm-linux-gnu,openmp-x86_64-pc-linux-gnu -input=%t.o -input=%t.tgt1 -input=%t.tgt2 -output=%t.bundle3.o -### 2>&1 \
 // RUN: | FileCheck %s -DHOST=%itanium_abi_triple -DINOBJ1=%t.o -DINOBJ2=%t.tgt1 -DINOBJ3=%t.tgt2 -DOUTOBJ=%t.bundle3.o --check-prefix CK-OBJ-CMD-INPUTS
-// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu=readonly,exclude" "--" "[[INOBJ1]]" "[[OUTOBJ]]"
+// CK-OBJ-CMD-INPUTS: llvm-objcopy{{(.exe)?}}" "--add-section=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-={{.*}}" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__host-[[HOST]]-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=[[INOBJ2]]" "--set-section-flags=__CLANG_OFFLOAD_BUNDLE__openmp-powerpc64le-ibm-linux-gnu-=readonly,exclude" "--add-section=__CLANG_OFFLOAD_BUNDLE__openmp-x86_64-pc-linux-gnu-=[[INOBJ3]]" "--set-section-flags=__CLANG_OFFLOAD_

[PATCH] D145770: [clang-offload-bundler] Standardize TargetID field for bundler

2023-03-13 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.

In D145770#4190901 , @scott.linder 
wrote:

> Is there a corresponding document update to go along with this? If consumers 
> of the bundles will begin to rely on this it should be documented that it is 
> guaranteed by the producer.

Good point, documentation udpated


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145770/new/

https://reviews.llvm.org/D145770

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D154133: [amdgpu] start documenting amdgpu support by clang

2023-06-30 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added inline comments.



Comment at: clang/docs/AMDGPUSupport.rst:20
+
+Clang supports OpenCL, HIP and OpenMP on amdgpu target.
+

arsenm wrote:
> "on amdgpu target" doesn't sound grammatical
"for the //amdgpu// target"? or
"on AMD GPU targets?"




Comment at: clang/docs/AMDGPUSupport.rst:49
+   * - ``__AMDGCN_CUMODE__``
+ - Defines as 1 if the CU mode is enabled and 0 if the WGP mode is enabled.
+   * - ``__AMDGCN_UNSAFE_FP_ATOMICS__``

Defined?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154133/new/

https://reviews.llvm.org/D154133

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137275: [Driver][test] Fix test by creating empty archive instead of empty file

2022-12-05 Thread Jacob Lambert via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6b992bcce0c5: [Driver][test] Fix test by creating empty 
archive instead of empty file (authored by lamb-j).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137275/new/

https://reviews.llvm.org/D137275

Files:
  clang/test/Driver/hip-link-bc-to-bc.hip


Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- clang/test/Driver/hip-link-bc-to-bc.hip
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -1,6 +1,4 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
-// See issue #58711
-// XFAIL: *
 
 // Check that clang unbundles the two bitcodes and links via llvm-link
 // RUN: rm -rf %t && mkdir %t
@@ -21,7 +19,7 @@
 // BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" 
"[[B1DEV2]]" "[[B2DEV2]]"
 
 // Check that clang unbundles the bitcode and archive and links via llvm-link
-// RUN: touch %t/libhipbundle.a
+// RUN: ar rc %t/libhipbundle.a
 // RUN: touch %t/bundle.bc
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu --offload-arch=gfx906 
--hip-link \


Index: clang/test/Driver/hip-link-bc-to-bc.hip
===
--- clang/test/Driver/hip-link-bc-to-bc.hip
+++ clang/test/Driver/hip-link-bc-to-bc.hip
@@ -1,6 +1,4 @@
 // REQUIRES: x86-registered-target, amdgpu-registered-target
-// See issue #58711
-// XFAIL: *
 
 // Check that clang unbundles the two bitcodes and links via llvm-link
 // RUN: rm -rf %t && mkdir %t
@@ -21,7 +19,7 @@
 // BITCODE: "{{.*}}llvm-link" "-o" "bundle1-hip-amdgcn-amd-amdhsa-gfx906.bc" "[[B1DEV2]]" "[[B2DEV2]]"
 
 // Check that clang unbundles the bitcode and archive and links via llvm-link
-// RUN: touch %t/libhipbundle.a
+// RUN: ar rc %t/libhipbundle.a
 // RUN: touch %t/bundle.bc
 
 // RUN: %clang -### --target=x86_64-unknown-linux-gnu --offload-arch=gfx906 --hip-link \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D137275: [Driver][test] Fix test by creating empty archive instead of empty file

2022-12-07 Thread Jacob Lambert via Phabricator via cfe-commits
lamb-j added a comment.

@thakis thanks for reverting that, sorry I didn't see your request sooner!

I've switched the patch to use "llvm-ar" instead of "ar", which should solve 
the issues


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137275/new/

https://reviews.llvm.org/D137275

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits