Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

[driver] Do not warn about unused plugin flags. #88948

Merged
merged 2 commits into from
May 6, 2024

Conversation

Meinersbur
Copy link
Member

Plugins are not loaded without the -cc1 phase. Do not report them when running on an assembly file or when linking. Many build tools add these options to all driver invocations, including LLVM's build system.

Fixes #88173

@Meinersbur Meinersbur changed the title Do not warn about unused plugin flags. [driver] Do not warn about unused plugin flags. Apr 16, 2024
@Meinersbur Meinersbur marked this pull request as ready for review April 22, 2024 09:31
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Apr 22, 2024
@llvmbot
Copy link
Member

llvmbot commented Apr 22, 2024

@llvm/pr-subscribers-clang

Author: Michael Kruse (Meinersbur)

Changes

Plugins are not loaded without the -cc1 phase. Do not report them when running on an assembly file or when linking. Many build tools add these options to all driver invocations, including LLVM's build system.

Fixes #88173


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

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3-3)
  • (added) clang/test/Driver/clang-s-plugin.s (+5)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e24626913add76..c1d85c527d437b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3630,14 +3630,14 @@ defm rwpi : BoolFOption<"rwpi",
           "Generate read-write position independent code (ARM only)">,
   NegFlag<SetFalse, [], [ClangOption, FlangOption, CC1Option]>>;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group<f_Group>,
-  Flags<[NoXarchOption]>, MetaVarName<"<dsopath>">,
+  Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"<dsopath>">,
   HelpText<"Load the named plugin (dynamic shared object)">;
 def fplugin_arg : Joined<["-"], "fplugin-arg-">,
-  MetaVarName<"<name>-<arg>">,
+  MetaVarName<"<name>-<arg>">, Flags<[NoArgumentUnused]>,
   HelpText<"Pass <arg> to plugin <name>">;
 def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
   Group<f_Group>, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  MetaVarName<"<dsopath>">,
+  MetaVarName<"<dsopath>">, Flags<[NoArgumentUnused]>,
   HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">,
   MarshallingInfoStringVector<CodeGenOpts<"PassPlugins">>;
 defm tocdata : BoolOption<"m","tocdata",
diff --git a/clang/test/Driver/clang-s-plugin.s b/clang/test/Driver/clang-s-plugin.s
new file mode 100644
index 00000000000000..81169b7bc5bbc8
--- /dev/null
+++ b/clang/test/Driver/clang-s-plugin.s
@@ -0,0 +1,5 @@
+// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s
+
+// Plugins are only relevant for the -cc1 phase. No warning should be raised
+// when applied to assembly files. See GH #88173.
+// CHECK-NOT: argument unused during compilation

@llvmbot
Copy link
Member

llvmbot commented Apr 22, 2024

@llvm/pr-subscribers-clang-driver

Author: Michael Kruse (Meinersbur)

Changes

Plugins are not loaded without the -cc1 phase. Do not report them when running on an assembly file or when linking. Many build tools add these options to all driver invocations, including LLVM's build system.

Fixes #88173


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

2 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3-3)
  • (added) clang/test/Driver/clang-s-plugin.s (+5)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e24626913add76..c1d85c527d437b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3630,14 +3630,14 @@ defm rwpi : BoolFOption<"rwpi",
           "Generate read-write position independent code (ARM only)">,
   NegFlag<SetFalse, [], [ClangOption, FlangOption, CC1Option]>>;
 def fplugin_EQ : Joined<["-"], "fplugin=">, Group<f_Group>,
-  Flags<[NoXarchOption]>, MetaVarName<"<dsopath>">,
+  Flags<[NoXarchOption, NoArgumentUnused]>, MetaVarName<"<dsopath>">,
   HelpText<"Load the named plugin (dynamic shared object)">;
 def fplugin_arg : Joined<["-"], "fplugin-arg-">,
-  MetaVarName<"<name>-<arg>">,
+  MetaVarName<"<name>-<arg>">, Flags<[NoArgumentUnused]>,
   HelpText<"Pass <arg> to plugin <name>">;
 def fpass_plugin_EQ : Joined<["-"], "fpass-plugin=">,
   Group<f_Group>, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-  MetaVarName<"<dsopath>">,
+  MetaVarName<"<dsopath>">, Flags<[NoArgumentUnused]>,
   HelpText<"Load pass plugin from a dynamic shared object file (only with new pass manager).">,
   MarshallingInfoStringVector<CodeGenOpts<"PassPlugins">>;
 defm tocdata : BoolOption<"m","tocdata",
diff --git a/clang/test/Driver/clang-s-plugin.s b/clang/test/Driver/clang-s-plugin.s
new file mode 100644
index 00000000000000..81169b7bc5bbc8
--- /dev/null
+++ b/clang/test/Driver/clang-s-plugin.s
@@ -0,0 +1,5 @@
+// RUN: %clang -### -c -fpass-plugin=bar.so -fplugin=bar.so -fplugin-arg-bar-option -Werror %s 2>&1 | FileCheck %s
+
+// Plugins are only relevant for the -cc1 phase. No warning should be raised
+// when applied to assembly files. See GH #88173.
+// CHECK-NOT: argument unused during compilation

clang/test/Driver/clang-s-plugin.s Outdated Show resolved Hide resolved
Plugins are not loaded without the -cc1 phase. Do not report them when
running on a assembly file or when linking. Many build tools add these
options to all driver invocations. See GH llvm#88173.
@Meinersbur
Copy link
Member Author

I accidentally pushed a Foxtrot merge. Will push once the pre-merge bot is happy.

Thanks for the review.

@Meinersbur Meinersbur merged commit 6e31a49 into llvm:main May 6, 2024
4 checks passed
@Meinersbur Meinersbur deleted the clang_fplugin branch May 6, 2024 12:04
@jakeegan
Copy link
Member

jakeegan commented May 7, 2024

Hi, the test plugin-driver-args.cpp is failing on AIX now, could you take a look please?
https://lab.llvm.org/buildbot/#/builders/214/builds/12118/steps/6/logs/FAIL__Clang__plugin-driver-args_cpp

@Meinersbur
Copy link
Member Author

@jakeegan Sorry, didn't see you comment over an extended weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clang produces error on compiling assembly files when using plugins like polly
4 participants