Skip to content

Commit 18fbeda

Browse files
committed
Avoid LLVM_LIBRARY_OUTPUT_INTDIR
1 parent f14a662 commit 18fbeda

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

flang-rt/CMakeLists.txt

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,13 +73,22 @@ if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSIO
7373
endif()
7474

7575
if (LLVM_TREE_AVAILABLE)
76+
# In a bootstrap build emit the libraries into a default search path in the
77+
# build directory of the just-built compiler. This allows using the
78+
# just-built compiler without specifying paths to runtime libraries.
79+
#
7680
# Despite Clang in the name, get_clang_resource_dir does not depend on Clang
7781
# being added to the build. Flang uses the same resource dir as clang.
7882
include(GetClangResourceDir)
7983
get_clang_resource_dir(FLANG_RT_BUILD_LIB_DIR PREFIX "${LLVM_LIBRARY_OUTPUT_INTDIR}/.." SUBDIR "lib${LLVM_LIBDIR_SUFFIX}")
8084
get_clang_resource_dir(FLANG_RT_INSTALL_LIB_DIR SUBDIR "lib${LLVM_LIBDIR_SUFFIX}") # No prefix, CMake's install command finds the install prefix itself
8185
else ()
82-
set(FLANG_RT_BUILD_LIB_DIR "${LLVM_LIBRARY_OUTPUT_INTDIR}")
86+
# In a runtimes build never write into LLVM's build dir. It might be reused
87+
# for mutliple Flang-RT builds (e.g. Debug/Release). Instead create our own
88+
# library directory.
89+
#
90+
# TODO: Support multi-config generators
91+
set(FLANG_RT_BUILD_LIB_DIR "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
8392
set(FLANG_RT_INSTALL_LIB_DIR "lib${LLVM_LIBDIR_SUFFIX}")
8493
endif ()
8594

flang-rt/test/Driver/ctofortran.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! UNSUPPORTED: system-windows
22
! RUN: split-file %s %t
33
! RUN: chmod +x %t/runtest.sh
4-
! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang | FileCheck %s
4+
! RUN: %t/runtest.sh %t %t/ffile.f90 %t/cfile.c %flang %libdir | FileCheck %s
55

66
!--- ffile.f90
77
program fmain
@@ -71,16 +71,16 @@ end subroutine foo
7171
FFILE=$2
7272
CFILE=$3
7373
FLANG=$4
74-
shift 4
74+
LIBDIR=$5
75+
shift 5
7576
FLAGS="$*"
7677
BINDIR=`dirname $FLANG`
77-
LIBDIR=$BINDIR/../lib
7878
CCOMP=$BINDIR/clang
7979
if [ -x $CCOMP ]
8080
then
8181
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$LIBDIR
8282
$CCOMP $FLAGS -c $CFILE -o $TMPDIR/cfile.o
83-
$FLANG $FLAGS $FFILE $TMPDIR/cfile.o -o $TMPDIR/ctofortran
83+
$FLANG $FLAGS $FFILE $TMPDIR/cfile.o -o $TMPDIR/ctofortran -L"${LIBDIR}"
8484
$TMPDIR/ctofortran # should print "PASS"
8585
else
8686
# No clang compiler, just pass by default

flang-rt/test/Driver/exec.f90

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
! Verify that flang can correctly build executables.
22

3-
! RUN: %flang %s -o %t
4-
! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%llvmshlibdir" %t | FileCheck %s
3+
! RUN: %flang -L"%libdir" %s -o %t
4+
! RUN: env LD_LIBRARY_PATH="$LD_LIBRARY_PATH:%libdir" %t | FileCheck %s
55
! RUN: rm -f %t
66

77
! CHECK: Hello, World!

flang-rt/test/lit.cfg.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@
7070
)
7171
]
7272

73+
tools.append(ToolSubst("%libdir", command=config.flangrt_build_lib_dir, unresolved="fatal"))
74+
7375
# Define some variables to help us test that the flang runtime doesn't depend on
7476
# the C++ runtime libraries. For this we need a C compiler.
7577
libruntime = os.path.join(config.flangrt_build_lib_dir, "libflang_rt.a")

0 commit comments

Comments
 (0)