[PATCH] D105896: [flang][driver] Fix output filename generation in `flang`

Andrzej Warzynski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 15 03:34:23 PDT 2021


awarzynski added a comment.

In D105896#2879350 <https://reviews.llvm.org/D105896#2879350>, @DavidSpickett wrote:

> The failure handling looks good. I'm still confused about the output naming. Can you clarify what you mean by:
>
>   In particular, we should use it in this case:
>   
>   compilation only
>   flang -c -o <output> <input>
>   but leave it for the final executable here:
>   
>   compile, assemble and link
>   flang  -o <output> <input>
>
> Do you mean "but leave it for the final executable" as in, only use <output> to name the final executable. Instead of using it to name the intermediate sources as well?

Let's consider 2 examples. This is basically what the script does.
**CASE 1**: compilation only

  flang -c hello.f90 -o hello

This script will translate this into:

  # Genreate temporary unaprsed Fortran file
  flang-new -fdebug-unparse hello.f90 -o flang_unparsed_source_file_0.f90
  # Genreate the output object file - do use `-o hello`
  gfortran -c -o hello flang_unparsed_source_file_0.f90

**CASE 2**: compilation + assembly + linking

  flang  hello.f90 -o hello

This script will translate this into:

  # Genreate temporary unaprsed Fortran file
  flang-new -fdebug-unparse hello.f90 -o flang_unparsed_source_file_0.f90
  # Generate a temporary object file - don't use `-o hello`
  gfortran -c  flang_unparsed_source_file_0.f90  -o flang_unparsed_source_file_0.o
  # Generate the final outupt - do use `-o hello`
  gfortran  flang_unparsed_source_file_0.o -o hello

**BOTTOM LINE**
The script needs to be careful _when_ to use `-o <output>` and _what_ to use as `<output>`. Sadly, it's tricky to convey that with comments or code :/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105896



More information about the llvm-commits mailing list