[PATCH] D93301: [flang][driver] Add support for `-c` and `-emit-obj`

Andrzej Warzynski via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 15 07:59:37 PST 2020


awarzynski created this revision.
Herald added a reviewer: sscalpone.
Herald added a subscriber: dang.
awarzynski requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

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.

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).

Depends on: D92854 <https://reviews.llvm.org/D92854>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D93301

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

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93301.311910.patch
Type: text/x-patch
Size: 10458 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201215/09f11595/attachment-0001.bin>


More information about the cfe-commits mailing list