[flang][driver] Add the new flang compiler and frontend drivers
This is the first patch implementing the new Flang driver as outlined in ,
 & . It creates Flang driver (flang-new) and Flang frontend driver
(flang-new -fc1). These will be renamed as flang and flang -fc1 once the
current Flang throwaway driver, flang, can be replaced with flang-new.
Currently only 2 options are supported: -help and --version.
flang-new is implemented in terms of libclangDriver, defaulting the driver
mode to FlangMode (added to libclangDriver in ). This ensures that the
driver runs in Flang mode regardless of the name of the binary inferred from
The design of the new Flang compiler and frontend drivers is inspired by it
counterparts in Clang . Currently, the new Flang compiler and frontend
drivers re-use Clang libraries: clangBasic, clangDriver and clangFrontend.
To identify Flang options, this patch adds FlangOption/FC1Option enums.
Driver::printHelp is updated so that flang-new prints only Flang options.
The new Flang driver is disabled by default. To enable it, set
-DBUILD_FLANG_NEW_DRIVER=ON when configuring CMake and add clang to
LLVM_ENABLE_PROJECTS (e.g. -DLLVM_ENABLE_PROJECTS=“clang;flang;mlir”).
 “RFC: new Flang driver - next steps”
 “RFC: Adding a fortran mode to the clang driver for flang”
 “RFC: refactoring libclangDriver/libclangFrontend to share with Flang”
co-authored-by: Andrzej Warzynski <firstname.lastname@example.org>
Reviewed By: richard.barton.arm, sameeranjoshi
Differential Revision: https://reviews.llvm.org/D86089