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

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 14 10:00:50 PDT 2024


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

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.


>From c0f14a2c484fc6172ea93f563d8f3e3706ca8009 Mon Sep 17 00:00:00 2001
From: Joseph Huber <huberjn at outlook.com>
Date: Wed, 14 Aug 2024 11:58:48 -0500
Subject: [PATCH] [Clang] Fix 'nvlink-wrapper' not ignoring `-plugin` like lld
 does

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.
---
 clang/test/Driver/nvlink-wrapper.c             | 7 +++++++
 clang/tools/clang-nvlink-wrapper/NVLinkOpts.td | 3 +++
 2 files changed, 10 insertions(+)

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=">,



More information about the cfe-commits mailing list