[PATCH] D145726: Fix assembler error when -g and -gdwarf-* is passed with -fno-integrated-as.

Nick Desaulniers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Mar 14 12:23:04 PDT 2023


nickdesaulniers requested changes to this revision.
nickdesaulniers added a comment.
This revision now requires changes to proceed.

The description needs to be rewritten to elucidate that this is purely to support old versions of the GNU assembler still in use by various Linux LTS distros.  This problem does not exist for folks using up to date tooling.  I would like to see specific GNU assembler version details in the commit description as well.



================
Comment at: clang/lib/Driver/ToolChains/Gnu.cpp:978-986
+      if (Arg *A = Args.getLastArg(options::OPT_g_Flag, options::OPT_gN_Group,
+                                   options::OPT_gdwarf_2, options::OPT_gdwarf_3,
+                                   options::OPT_gdwarf_4, options::OPT_gdwarf_5,
+                                   options::OPT_gdwarf))
+        if (!A->getOption().matches(options::OPT_g0)) {
+          Args.AddLastArg(CmdArgs, options::OPT_g_Flag);
+          unsigned DwarfVersion = getDwarfVersion(getToolChain(), Args);
----------------
garvitgupta08 wrote:
> nickdesaulniers wrote:
> > Isn't this potentially going to add `-gdwarf-` repeatedly if there's many inputs?
> > 
> > Wouldn't it be better to scan the inputs to see if there's any .S or .s files, then add the flags once?
> Let me know if this is fine.
I don't think the current implementation addresses my point.  Having `CmdArgs.push_back` be called in a loop on the number of inputs will potentially add the arg repeatedly.

I think you should simply check if the `InputType` is asm or asm-with-cpp in the loop, potentially setting a boolean scoped outside the loop. Then, after the loop, decide whether to add the cmd arg.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145726



More information about the cfe-commits mailing list