[clang] [Clang] Fix 'nvlink-wrapper' not ignoring `-plugin` like lld does (PR #104056)

via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 14 10:01:22 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-driver

Author: Joseph Huber (jhuber6)

<details>
<summary>Changes</summary>

Summary:
This caused issues with
https://gitlab.e4s.io/uo-public/llvm-openmp-offloading/-/jobs/301520
because adding `-flto` caused it to pass `-plugin` sometimes, which
isn't supported.


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


2 Files Affected:

- (modified) clang/test/Driver/nvlink-wrapper.c (+7) 
- (modified) clang/tools/clang-nvlink-wrapper/NVLinkOpts.td (+3) 


``````````diff
diff --git a/clang/test/Driver/nvlink-wrapper.c b/clang/test/Driver/nvlink-wrapper.c
index 5d835d8d6cb2a2..2ef09b699eccb8 100644
--- a/clang/test/Driver/nvlink-wrapper.c
+++ b/clang/test/Driver/nvlink-wrapper.c
@@ -78,3 +78,10 @@ int baz() { return y + x; }
 // RUN:   --lto-debug-pass-manager --lto-newpm-passes=forceattrs \
 // RUN:   -arch sm_52 -o a.out 2>&1 | FileCheck %s --check-prefix=PASSES
 // PASSES: Running pass: ForceFunctionAttrsPass
+
+//
+// Check that '-plugin` is ingored like in `ld.lld`
+//
+// RUN: clang-nvlink-wrapper --dry-run %t.o -plugin -arch sm_52 -o a.out \
+// RUN:   2>&1 | FileCheck %s --check-prefix=PLUGIN
+// PLUGIN-NOT: -plugin
diff --git a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
index a97190b7a614cc..ef1a7542e49502 100644
--- a/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
+++ b/clang/tools/clang-nvlink-wrapper/NVLinkOpts.td
@@ -39,6 +39,9 @@ def library_S : Separate<["--", "-"], "library">, Flags<[HelpHidden]>,
 def library_EQ : Joined<["--", "-"], "library=">, Flags<[HelpHidden]>,
   Alias<library_path>;
 
+def plugin : Joined<["--", "-"], "plugin">, 
+  Flags<[HelpHidden, WrapperOnlyOption]>;
+
 def arch : Separate<["--", "-"], "arch">,
   HelpText<"Specify the 'sm_' name of the target architecture.">;
 def : Joined<["--", "-"], "plugin-opt=mcpu=">,

``````````

</details>


https://github.com/llvm/llvm-project/pull/104056


More information about the cfe-commits mailing list