[PATCH] D95460: [flang][driver] Add forced form flags and -ffixed-line-length

Andrzej Warzynski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 18 06:01:45 PDT 2021


awarzynski added a comment.

Hi @protze.joachim,

Thank you for your feedback. I'm sorry that this is causing issues in your set-up.

In D95460#2632844 <https://reviews.llvm.org/D95460#2632844>, @protze.joachim wrote:

> Before this patch, clang would happily ignore a `-ffree-form` flag.

It's a bit more nuanced than this. Originally, `-ffree-form` (and other similar flags) were added to be forwarded to `gfortran`. This forwarding was effectively switched off ~6 months before this patch, please see this commit <https://reviews.llvm.org/rG6a75496836ea14bcfd2f4b59d35a1cad4ac58cee>. As such, these flags stopped being used/needed by Clang. This patch makes Flang "re-claim" them.

> With this patch, none of `-Wno-error=unknown-argument`, `-Wno-unknown-argument` , `-Qunused-arguments` help to avoid clang from exiting with
>
>   error: unknown argument: '-ffree-form'
>
> Why can't clang ignore these flags as any other unknown flags?

IIUC, this is not something specific to the options refactored in this patch. For example:

  # Test -foo
  clang-cl -c -Wno-unknown-argument -foo  file.c
  clang -c -Wno-unknown-argument -foo  file.c
  clang-13: error: unknown argument: '-foo'
  # Test -ffree-form
  clang-cl -c -Wno-unknown-argument -ffree-form  file.c
  clang -c -Wno-unknown-argument -ffree-form  file.c
  clang-13: error: unknown argument: '-ffree-form'

Basically, `-Wno-unknown-argument` is only honored in `clang-cl`. Also, it applies to any option rather then just the options modified here.
I'm not particularly familiar with the semantics of the diagnostics options that you listed (`-Wno-error=unknown-argument`, `-Wno-unknown-argument` , `-Qunused-arguments`), but I get the impression that in general `clang` does not ignore options that it does not know about. I couldn't find any example that would demonstrate otherwise.

> As a background: in the build system I'm dealing with, I cannot avoid that fortran flags are passed to the linking command. As C++ and fortran is involved, I prefer using clang++ as the linking command and explicitly link the fortran runtime library (at the moment gfortran, but in the future probably the flang runtime library)

It sounds like your build system relies on the `gfortran` support in Clang, but this support has been "bit rotting <https://reviews.llvm.org/rG6a75496836ea14bcfd2f4b59d35a1cad4ac58cee>". I'm keen to help you resolve your problems, but finding a solution that will work for `clang`, `flang` and `gfortran` might require some effort. Would you be able to step-up as Clang's `gfortran`-mode maintainer? (no pressure, just brainstorming!)
Alternatively, do you need ToT `clang` for your build system?

Thank you,
-Andrzej


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D95460



More information about the cfe-commits mailing list