From 051bfaca95eaba1655c58b2033871c0a480c4293 Mon Sep 17 00:00:00 2001 From: Paul Osmialowski Date: Thu, 7 Jun 2018 07:41:42 +0100 Subject: [PATCH] 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 --- lib/Driver/ToolChain.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp index c2daa5bbb10f..06534377e6dc 100644 --- a/lib/Driver/ToolChain.cpp +++ b/lib/Driver/ToolChain.cpp @@ -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 ) {