File tree Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Expand file tree Collapse file tree 4 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -73,13 +73,22 @@ if (LLVM_LIBRARY_OUTPUT_INTDIR AND LLVM_RUNTIME_OUTPUT_INTDIR AND PACKAGE_VERSIO
7373endif ()
7474
7575if (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
8185else ()
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} " )
8493endif ()
8594
Original file line number Diff line number Diff line change 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
77program fmain
@@ -71,16 +71,16 @@ end subroutine foo
7171FFILE= $2
7272CFILE= $3
7373FLANG= $4
74- shift 4
74+ LIBDIR= $5
75+ shift 5
7576FLAGS= " $*"
7677BINDIR= `dirname $FLANG`
77- LIBDIR= $BINDIR/ ../ lib
7878CCOMP= $BINDIR/ clang
7979if [ - x $CCOMP ]
8080then
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"
8585else
8686 # No clang compiler, just pass by default
Original file line number Diff line number Diff line change 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!
Original file line number Diff line number Diff line change 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.
7577libruntime = os .path .join (config .flangrt_build_lib_dir , "libflang_rt.a" )
You can’t perform that action at this time.
0 commit comments