[flang] Install runtime libs with the toolchainMake sure that FortranDecimal, FortranRuntime and Fortran_main areinstalled/packaged even when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled.They are used
[flang] Install runtime libs with the toolchainMake sure that FortranDecimal, FortranRuntime and Fortran_main areinstalled/packaged even when LLVM_INSTALL_TOOLCHAIN_ONLY is enabled.They are used by flang to link executables, so they should be providedeven with minimal installs.Differential Revision: https://reviews.llvm.org/D131670(cherry picked from commit 467abac2046d037f8d4cf428e76b77e5b06c187f)
show more ...
[flang][Runtime] Use proper prototypes in Fortran_main. NFCIThis is compiled as C code, so it's a good idea to be explicit about theprototype. Clang complains about this when -Wstrict-prototypes i
[flang][Runtime] Use proper prototypes in Fortran_main. NFCIThis is compiled as C code, so it's a good idea to be explicit about theprototype. Clang complains about this when -Wstrict-prototypes is used.Differential Revision: https://reviews.llvm.org/D125672
[flang] Install Fortran_main libraryAt the moment the Fortran_main library is not installed, so it cannot befound by the driver when run from an install directory. This patch fixesthe issue by re
[flang] Install Fortran_main libraryAt the moment the Fortran_main library is not installed, so it cannot befound by the driver when run from an install directory. This patch fixesthe issue by replacing llvm_add_library with add_flang_library, whichalready contains all the proper incantations for installing a library.It also enhances add_flang_library to support a STATIC arg which forcesthe library to be static even when BUILD_SHARED_LIBS is on.Differential Revision: https://reviews.llvm.org/D124759Co-authored-by: Dan Palermo <[email protected]>
[flang][driver] Add support for generating executablesThis patch adds 2 missing items required for `flang-new` to be able togenerate executables:1. The Fortran_main runtime library, which implem
[flang][driver] Add support for generating executablesThis patch adds 2 missing items required for `flang-new` to be able togenerate executables:1. The Fortran_main runtime library, which implements the main entry point into Fortran's `PROGRAM` in Flang,2. Extra linker flags to include Fortran runtime libraries (e.g. Fortran_main).Fortran_main is the bridge between object files generated by Flang andthe C runtime that takes care of program set-up at system-level. Forevery Fortran `PROGRAM`, Flang generates the `_QQmain` function.Fortran_main implements the C `main` function that simply calls`_QQmain`.Additionally, "<driver-path>/../lib" directory is added to the list ofsearch directories for libraries. This is where the required runtimelibraries are currently located. Note that this the case for the builddirectory. We haven't considered installation directories/targets yet.With this change, you can generate an executable that will print `hello,world!` as follows:```bash$ cat hello.f95PROGRAM HELLO write(*, *) "hello, world!"END PROGRAM HELLO$ flang-new -flang-experimental-exec hello.f95./a.outhello, world!```NOTE 1: Fortran_main has to be a static library at all times. It invokes`_QQmain`, which is the main entry point generated by Flang for thegiven input file (you can check this with `flang-new -S hello.f95 -o - |grep "Qmain"`). This means that Fortran_main has an unresolveddependency at build time. The linker will allow this for a staticlibrary. However, if Fortran_main was a shared object, then the linkerwill produce an error: `undefined symbol: `_QQmain`.NOTE 2: When Fortran runtime libraries are generated as shared libraries(excluding Fortran_main, which is always static), you will need totell the dynamic linker (by e.g. tweaking LD_LIBRARY_PATH) where to lookfor them when invoking the executables. For example:```bashLD_LIBRARY_PATH=$LD_LIBRARY_PATH:<flang-build-dir>/lib/ ./a.out```NOTE 3: This feature is considered experimental and currently guardedwith a flag: `-flang-experimental-exec`.Differential Revision: https://reviews.llvm.org/D122008[1] https://github.com/flang-compiler/f18-llvm-projectCREDITS: Fortran_main was originally written by Eric Schweitz, JeanPerier, Peter Klausler and Steve Scalpone in the fir-dev` branch in [1].Co-authored-by: Eric Schweitz <[email protected]>Co-authored-by: Peter Klausler <[email protected]>Co-authored-by: Jean Perier <[email protected]>Co-authored-by: Steve Scalpone <[email protected]