[all-commits] [llvm/llvm-project] e5cdb6: [flang][driver] Add support for `-c` and `-emit-obj`

Andrzej WarzyƄski via All-commits all-commits at lists.llvm.org
Thu Jan 7 02:58:45 PST 2021


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: e5cdb6c56edf656d03f57c5c285cfa8c6b7b6f57
      https://github.com/llvm/llvm-project/commit/e5cdb6c56edf656d03f57c5c285cfa8c6b7b6f57
  Author: Andrzej Warzynski <andrzej.warzynski at arm.com>
  Date:   2021-01-07 (Thu, 07 Jan 2021)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/Flang.cpp
    M flang/include/flang/Frontend/FrontendActions.h
    M flang/include/flang/Frontend/FrontendOptions.h
    M flang/lib/Frontend/CompilerInvocation.cpp
    M flang/lib/Frontend/FrontendActions.cpp
    M flang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
    A flang/test/Flang-Driver/code-gen.f90
    M flang/test/Flang-Driver/driver-help-hidden.f90
    M flang/test/Flang-Driver/driver-help.f90
    R flang/test/Flang-Driver/emit-obj.f90
    A flang/test/Flang-Driver/phases.f90

  Log Message:
  -----------
  [flang][driver] Add support for `-c` and `-emit-obj`

This patch adds a frontend action for emitting object files. While Flang
does not support code-generation, this action remains a placeholder.
This patch simply provides glue-code to connect the compiler driver
with the appropriate frontend action.

The new action is triggered with the `-c` compiler driver flag, i.e.
`flang-new -c`. This is then translated to `flang-new -fc1 -emit-obj`,
so `-emit-obj` has to be marked as supported as well.

As code-generation is not available yet, `flang-new -c` results in a
driver error:
```
error: code-generation is not available yet
```
Hopefully this will help communicating the level of available
functionality within Flang.

The definition of `emit-obj` is updated so that it can be shared between
Clang and Flang. As the original definition was enclosed within a
Clang-specific TableGen `let` statement, it is extracted into a new `let`
statement. That felt like the cleanest option.

I also commented out `-triple` in Flang::ConstructJob and updated some
comments there. This is similar to https://reviews.llvm.org/D93027. I
wanted to make sure that it's clear that we can't support `-triple`
until we have code-generation. However, once code-generation is
available we _will need_ `-triple`.

As this patch adds `-emit-obj`, the emit-obj.f90 becomes irrelevant and
is deleted. Instead, phases.f90 is added to demonstrate that users can
control compilation phases (indeed, `-c` is a phase control flag).

Reviewed By: SouraVX, clementval

Differential Revision: https://reviews.llvm.org/D93301




More information about the All-commits mailing list