[all-commits] [llvm/llvm-project] 50a5f5: [flang][driver] Add -fno-fortran-main (link time) ...

Michael Klemm via All-commits all-commits at lists.llvm.org
Mon Dec 11 04:35:41 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 50a5f5c1838f8583d050eb15a3b770bb4661910d
      https://github.com/llvm/llvm-project/commit/50a5f5c1838f8583d050eb15a3b770bb4661910d
  Author: Michael Klemm <michael.klemm at amd.com>
  Date:   2023-12-11 (Mon, 11 Dec 2023)

  Changed paths:
    M clang/include/clang/Driver/Options.td
    M clang/lib/Driver/ToolChains/CommonArgs.cpp
    M clang/lib/Driver/ToolChains/Flang.cpp
    M flang/test/Driver/driver-help-hidden.f90
    M flang/test/Driver/driver-help.f90
    M flang/test/Driver/no-duplicate-main.f90

  Log Message:
  -----------
  [flang][driver] Add -fno-fortran-main (link time) option to remove Fortran_main from link line (#74139)

This PR adds the `-fno-fortran-main` command line option to remove
`Fortran_main.a` from the link and to allow for linking Fortran code w/o
program unit with C/C++ translation units that provide the `main()`
entrypoint.

When linking Fortran code with C/C++ code (Fortran calling into C/C++),
PR #73124 introduced a proper error message that would prevent
successful linkage, if there was a program unit from Fortran *and*
`main()` function coming from C/C++. Alas, this caused some breakage of
code that would call Fortran code from C/C++ and rightfully provided the
`main()` entrypoint. Classic Flang had the command-line option
`-fno-fortran-main` to then remove the entrypoints for the Fortran
program unit from the linker stage.

This PR is related to PR #74120 and (merged) PR #73124.

---------

Co-authored-by: Andrzej WarzyƄski <andrzej.warzynski at gmail.com>




More information about the All-commits mailing list