Skip to content

Commit

Permalink
flang: libflangrti.so should depend on libompstub.so instead of libom…
Browse files Browse the repository at this point in the history
…p.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 <[email protected]>
  • Loading branch information
pawosm-arm committed Jul 10, 2018
1 parent 4cd0029 commit 051bfac
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,13 +783,16 @@ void ToolChain::AddFortranStdlibLibArgs(const ArgList &Args,
if (staticFlangLibs) {
CmdArgs.push_back("-Bstatic");
}
CmdArgs.push_back("-lflang");
CmdArgs.push_back("-lflangrti");
CmdArgs.push_back("-lpgmath");
if( useOpenMP ) {
CmdArgs.push_back("-lflang-omp");
CmdArgs.push_back("-lflangrti-omp");
CmdArgs.push_back("-lpgmath");
CmdArgs.push_back("-lomp");
}
else {
CmdArgs.push_back("-lflang");
CmdArgs.push_back("-lflangrti");
CmdArgs.push_back("-lpgmath");
CmdArgs.push_back("-lompstub");
}
if( staticFlangLibs ) {
Expand Down

0 comments on commit 051bfac

Please sign in to comment.