[llvm-branch-commits] [clang] [flang] [lld] [llvm] [Flang] LLVM_ENABLE_RUNTIMES=flang-rt (PR #110217)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Dec 9 07:42:12 PST 2024


Meinersbur wrote:

> I built things as of [ac1f46f](https://github.com/llvm/llvm-project/commit/ac1f46faeef2507bb680f14b9256ac38817824df) in [conda-forge/flang-feedstock#80](https://github.com/conda-forge/flang-feedstock/pull/80), and getting the following failure on linux:
> 
> ```
> [228/375] Linking CXX shared library lib/libFlangOpenMPTransforms.so.20.0git
> FAILED: lib/libFlangOpenMPTransforms.so.20.0git 
> : && $BUILD_PREFIX/bin/x86_64-conda-linux-gnu-c++ -fPIC -fvisibility-inlines-hidden -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem $PREFIX/include -fdebug-prefix-map=$SRC_DIR=/usr/local/src/conda/flang-split-20.0.0.dev1 -fdebug-prefix-map=$PREFIX=/usr/local/src/conda-prefix -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -fno-strict-aliasing -fno-semantic-interposition -O3 -DNDEBUG -fno-semantic-interposition  -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now -Wl,--disable-new-dtags -Wl,--gc-sections -Wl,--allow-shlib-undefined -Wl,-rpath,$PREFIX/lib -Wl,-rpath-link,$PREFIX/lib -L$PREFIX/lib -Wl,-z,defs -Wl,-z,nodelete   -Wl,-rpath-link,$SRC_DIR/build/lib  -Wl,--gc-sections  -Wl,--dependency-file=lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/link.d -shared -Wl,-soname,libFlangOpenMPTransforms.so.20.0git -o lib/libFlangOpenMPTransforms.so.20.0git lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/FunctionFiltering.cpp.o lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/GenericLoopConversion.cpp.o lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/MapsForPrivatizedSymbols.cpp.o lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/MapInfoFinalization.cpp.o lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/MarkDeclareTarget.cpp.o lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/LowerWorkshare.cpp.o  -Wl,-rpath,"\$ORIGIN/../lib:$SRC_DIR/build/lib:"  lib/libFIRCodeGen.so.20.0git  lib/libFortranCommon.so.20.0git  $PREFIX/lib/libMLIRFuncDialect.a  $PREFIX/lib/libMLIROpenMPDialect.a  $PREFIX/lib/libMLIRIR.a  $PREFIX/lib/libMLIRPass.a  $PREFIX/lib/libMLIRTransformUtils.a  lib/libFIRAnalysis.so.20.0git  lib/libFIRBuilder.so.20.0git  lib/libHLFIRDialect.so.20.0git  lib/libFIRSupport.so.20.0git  lib/libFIRDialect.so.20.0git  lib/libFIRDialectSupport.so.20.0git  $PREFIX/lib/libclang-cpp.so.20.0git  $PREFIX/lib/libMLIRFuncDialect.a  $PREFIX/lib/libMLIRLLVMDialect.a  $PREFIX/lib/libMLIRMemorySlotInterfaces.a  $PREFIX/lib/libMLIROpenACCMPCommon.a  $PREFIX/lib/libMLIRSubsetOpInterface.a  $PREFIX/lib/libMLIRValueBoundsOpInterface.a  $PREFIX/lib/libMLIRDestinationStyleOpInterface.a  $PREFIX/lib/libMLIRRewrite.a  $PREFIX/lib/libMLIRRewritePDL.a  $PREFIX/lib/libMLIRPDLToPDLInterp.a  $PREFIX/lib/libMLIRPass.a  $PREFIX/lib/libMLIRAnalysis.a  $PREFIX/lib/libMLIRCallInterfaces.a  $PREFIX/lib/libMLIRControlFlowInterfaces.a  $PREFIX/lib/libMLIRLoopLikeInterface.a  $PREFIX/lib/libMLIRDataLayoutInterfaces.a  $PREFIX/lib/libMLIRInferIntRangeInterface.a  $PREFIX/lib/libMLIRPresburger.a  $PREFIX/lib/libMLIRViewLikeInterface.a  $PREFIX/lib/libMLIRPDLInterpDialect.a  $PREFIX/lib/libMLIRFunctionInterfaces.a  $PREFIX/lib/libMLIRPDLDialect.a  $PREFIX/lib/libMLIRInferTypeOpInterface.a  $PREFIX/lib/libMLIRSideEffectInterfaces.a  $PREFIX/lib/libMLIRIR.a  $PREFIX/lib/libMLIRSupport.a  -lpthread  $PREFIX/lib/libLLVM.so.20.0git  -Wl,-rpath-link,$SRC_DIR/build/lib && :
> $BUILD_PREFIX/bin/../lib/gcc/x86_64-conda-linux-gnu/13.3.0/../../../../x86_64-conda-linux-gnu/bin/ld: lib/Optimizer/OpenMP/CMakeFiles/FlangOpenMPTransforms.dir/GenericLoopConversion.cpp.o: in function `(anonymous namespace)::GenericLoopConversionPattern::rewriteToDistributeParallelDo(mlir::omp::LoopOp, mlir::ConversionPatternRewriter&) const [clone .isra.0]':
> GenericLoopConversion.cpp:(.text._ZNK12_GLOBAL__N_128GenericLoopConversionPattern29rewriteToDistributeParallelDoEN4mlir3omp6LoopOpERNS1_25ConversionPatternRewriterE.isra.0+0x442): undefined reference to `Fortran::common::openmp::genEntryBlock(mlir::OpBuilder&, Fortran::common::openmp::EntryBlockArgs const&, mlir::Region&)'
> collect2: error: ld returned 1 exit status
> ```

I don't see this in any configuration that I am testing locally (currently there are 10 of them) before pushing any update to this PR, and don't see what the cmake parameters are from https://github.com/conda-forge/flang-feedstock/pull/80. It looks like a dependence to FortranSupport is missing. Just as a precaution, I added it to everywhere that depends on FortranCommon in a03606822b0eaef8efdeb00c4f2c33e1a029f79f.



> How are out-of-tree builds supposed to work? I had added `-DLLVM_ENABLE_RUNTIMES="flang-rt"` to our existing flang builds (which leverage pre-built llvm, clang & mlir), and noticed that nothing related to `flang_rt` gets built. Upon closer inspection, this is unsurprising, because the config step ignored that variable:
> 
> ```
> CMake Warning:
> -- Generating done (1.7s)
>   Manually-specified variables were not used by the project:
> 
>     LLVM_ENABLE_RUNTIMES
> ```

See documentation:
https://libcxx.llvm.org/VendorDocumentation.html#the-default-build
and 
https://github.com/llvm/llvm-project/blob/users/meinersbur/flang_runtime/flang-rt/README.md#runtime-onlyout-of-tree-build

You might have tried with `LLVM_ENABLE_RUNTIMES` with using `flang/CMakeLists.txt` as top-level CMake file. That one does not handle `LLVM_ENABLE_RUNTIMES`.  Try `LLVM_ENABLE_RUNTIMES` with `runtimes/CMakeLists.txt` as top-level. Pass `-DCMAKE_Fortran_COMPILER=<path-to-standalone-flang-build>/bin/flang` and `-DCMAKE_Fortran_COMPILER_WORKS=YES`.

https://github.com/llvm/llvm-project/pull/110217


More information about the llvm-branch-commits mailing list