Skip to content

Commit e9fb06b

Browse files
committed
flang: libflangrti.so should depend on libompstub.so instead of libomp.so
This commit is a clang part of a change that drops unfortunate dependency of libflangrti.so on libomp.so. For non-OpenMP programs (built without -fopenmp flag) frontend driver instructs the linker to link against libompstub.so library, which exports stubs for all OpenMP runtime library symbols. This is because Flang runtime library contains calls to those symbols (for OpenMP programs, final binary is linked against libomp.so instead). Apart form above, all of the Fortran programs are linked against libflang.so and libflangrti.so. Unfortunately, before this change libflangrti.so was depending on full blown OpenMP runtime library (libomp.so). This change creates two sets of Flang runtime shared objects with following chains of dependencies: 1. libflang.so -> libflangrti.so -> libompstub.so 2. libflang-omp.so -> libflangrti-omp.so -> libomp.so Note that before this commit is applied, relevant commit must be applied on flang repository first. Otherwise all OpenMP Fortran programs will fail to build at link time. Signed-off-by: Paul Osmialowski <pawel.osmialowski@arm.com>
1 parent b47f06e commit e9fb06b

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/Driver/ToolChain.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -795,12 +795,14 @@ void ToolChain::AddFortranStdlibLibArgs(const ArgList &Args,
795795
if (staticFlangLibs) {
796796
CmdArgs.push_back("-Bstatic");
797797
}
798-
CmdArgs.push_back("-lflang");
799-
CmdArgs.push_back("-lflangrti");
800798
if( useOpenMP ) {
799+
CmdArgs.push_back("-lflang-omp");
800+
CmdArgs.push_back("-lflangrti-omp");
801801
CmdArgs.push_back("-lomp");
802802
}
803803
else {
804+
CmdArgs.push_back("-lflang");
805+
CmdArgs.push_back("-lflangrti");
804806
CmdArgs.push_back("-lompstub");
805807
}
806808
if( staticFlangLibs ) {

0 commit comments

Comments
 (0)