The goal of this patch is to enable the user to have more control over the linkage type of the fortran libraries used by user executables. We want to be able to, for example, have all the LLVM libs build and link statically in flang-new, but at the same time retain the ability to have the Fortran user libs (FortranDecimal, FortranRuntime) also be built and linked dynamically for executables made using flang-new.
In order to do this, a new CMake option LLVM_BUILD_USER_FORTRAN_LIBS=[shared|static|all] can be passed. This option works on top of the decisions made by BUILD_SHARED_LIBS/BUILD_STATIC_LIBS by appending additional linkage types for just the user fortran libs. For the example above, this could be done by passing BUILD_SHARED_LIBS and also LLVM_BUILD_USER_FORTRAN_LIBS=shared. The BUILD_SHARED_LIBS will guarantee that all the LLVM libs get built and linked into flang-new statically. But on top of this, the new optoin thats passed will cause cmake to also build FortranDecimal and FortranRuntime as shared. By default, flang-new tried to dynamically link these 2 libraries into user executables. A future patch will introduce a flang-new driver option to allow the end user to choose between static and shared linking of these user fortran libs.
In the case that both linkage types are built by cmake, duplicate names are avoided by appending "_static" to the lib name. This is a feature that already existed in LLVM's cmake. There are some code changes in this patch that are needed to support/expect these "_static" named libs.
Do we need to have _static added to the name? I think they can continue to have the same name as the file extensions will be different