[flang] Support linking to MLIR dylib (#120966)
Introduce a new `MLIR_LIBS` argument to `add_flang_library`, that uses `mlir_target_link_libraries` to link the MLIR dylib alterantively to the component libraries. Use it, along with a few inline `mlir_target_link_libraries` in tools, to support linking Flang to MLIR dylib rather than the static libraries. With these changes, the vast majority of Flang can be linked dynamically. The only parts still using static libraries are these requiring MLIR test libraries, that are not included in the dylib.
This commit is contained in:
@@ -18,7 +18,7 @@ endmacro()
|
||||
|
||||
function(add_flang_library name)
|
||||
set(options SHARED STATIC INSTALL_WITH_TOOLCHAIN)
|
||||
set(multiValueArgs ADDITIONAL_HEADERS CLANG_LIBS)
|
||||
set(multiValueArgs ADDITIONAL_HEADERS CLANG_LIBS MLIR_LIBS)
|
||||
cmake_parse_arguments(ARG
|
||||
"${options}"
|
||||
""
|
||||
@@ -66,6 +66,7 @@ function(add_flang_library name)
|
||||
llvm_add_library(${name} ${LIBTYPE} ${ARG_UNPARSED_ARGUMENTS} ${srcs})
|
||||
|
||||
clang_target_link_libraries(${name} PRIVATE ${ARG_CLANG_LIBS})
|
||||
mlir_target_link_libraries(${name} PRIVATE ${ARG_MLIR_LIBS})
|
||||
|
||||
if (TARGET ${name})
|
||||
|
||||
|
||||
@@ -47,6 +47,6 @@ add_flang_library(FortranCommon
|
||||
LINK_COMPONENTS
|
||||
Support
|
||||
|
||||
LINK_LIBS
|
||||
MLIR_LIBS
|
||||
MLIRIR
|
||||
)
|
||||
|
||||
@@ -41,13 +41,6 @@ add_flang_library(flangFrontend
|
||||
flangPasses
|
||||
FIROpenACCSupport
|
||||
FlangOpenMPTransforms
|
||||
MLIRTransforms
|
||||
MLIRBuiltinToLLVMIRTranslation
|
||||
MLIRLLVMToLLVMIRTranslation
|
||||
MLIRSCFToControlFlow
|
||||
MLIRTargetLLVMIRImport
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
|
||||
LINK_COMPONENTS
|
||||
Passes
|
||||
@@ -63,6 +56,15 @@ add_flang_library(flangFrontend
|
||||
FrontendOpenACC
|
||||
FrontendOpenMP
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRTransforms
|
||||
MLIRBuiltinToLLVMIRTranslation
|
||||
MLIRLLVMToLLVMIRTranslation
|
||||
MLIRSCFToControlFlow
|
||||
MLIRTargetLLVMIRImport
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
|
||||
CLANG_LIBS
|
||||
clangBasic
|
||||
clangDriver
|
||||
|
||||
@@ -8,12 +8,14 @@ add_flang_library(flangFrontendTool
|
||||
|
||||
LINK_LIBS
|
||||
flangFrontend
|
||||
MLIRPass
|
||||
|
||||
LINK_COMPONENTS
|
||||
Option
|
||||
Support
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRPass
|
||||
|
||||
CLANG_LIBS
|
||||
clangBasic
|
||||
clangDriver
|
||||
|
||||
@@ -55,17 +55,19 @@ add_flang_library(FortranLower
|
||||
FIRSupport
|
||||
FIRTransforms
|
||||
HLFIRDialect
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
FortranCommon
|
||||
FortranParser
|
||||
FortranEvaluate
|
||||
FortranSemantics
|
||||
|
||||
LINK_COMPONENTS
|
||||
Support
|
||||
|
||||
MLIR_LIBS
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
MLIRAffineToStandard
|
||||
MLIRFuncDialect
|
||||
MLIRLLVMDialect
|
||||
MLIRSCFToControlFlow
|
||||
|
||||
LINK_COMPONENTS
|
||||
Support
|
||||
)
|
||||
|
||||
@@ -13,6 +13,8 @@ add_flang_library(FIRAnalysis
|
||||
FIRBuilder
|
||||
FIRDialect
|
||||
HLFIRDialect
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRFuncDialect
|
||||
MLIRLLVMDialect
|
||||
MLIRMathTransforms
|
||||
|
||||
@@ -51,6 +51,8 @@ add_flang_library(FIRBuilder
|
||||
FIRSupport
|
||||
FortranEvaluate
|
||||
HLFIRDialect
|
||||
|
||||
MLIR_LIBS
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
)
|
||||
|
||||
@@ -21,6 +21,14 @@ add_flang_library(FIRCodeGen
|
||||
FIRDialect
|
||||
FIRDialectSupport
|
||||
FIRSupport
|
||||
|
||||
LINK_COMPONENTS
|
||||
AsmParser
|
||||
AsmPrinter
|
||||
Remarks
|
||||
TargetParser
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRComplexToLLVM
|
||||
MLIRComplexToStandard
|
||||
MLIRGPUDialect
|
||||
@@ -34,10 +42,4 @@ add_flang_library(FIRCodeGen
|
||||
MLIRLLVMToLLVMIRTranslation
|
||||
MLIRTargetLLVMIRExport
|
||||
MLIRVectorToLLVM
|
||||
|
||||
LINK_COMPONENTS
|
||||
AsmParser
|
||||
AsmPrinter
|
||||
Remarks
|
||||
TargetParser
|
||||
)
|
||||
|
||||
@@ -20,14 +20,16 @@ add_flang_library(FIRDialect
|
||||
LINK_LIBS
|
||||
CUFAttrs
|
||||
FIRDialectSupport
|
||||
MLIRArithDialect
|
||||
MLIRBuiltinToLLVMIRTranslation
|
||||
MLIROpenMPToLLVM
|
||||
MLIRLLVMToLLVMIRTranslation
|
||||
MLIRTargetLLVMIRExport
|
||||
|
||||
LINK_COMPONENTS
|
||||
AsmParser
|
||||
AsmPrinter
|
||||
Remarks
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRArithDialect
|
||||
MLIRBuiltinToLLVMIRTranslation
|
||||
MLIROpenMPToLLVM
|
||||
MLIRLLVMToLLVMIRTranslation
|
||||
MLIRTargetLLVMIRExport
|
||||
)
|
||||
|
||||
@@ -7,11 +7,11 @@ add_flang_library(CUFAttrs
|
||||
CUFAttrsIncGen
|
||||
CUFOpsIncGen
|
||||
|
||||
LINK_LIBS
|
||||
MLIRTargetLLVMIRExport
|
||||
|
||||
LINK_COMPONENTS
|
||||
AsmParser
|
||||
AsmPrinter
|
||||
Remarks
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRTargetLLVMIRExport
|
||||
)
|
||||
|
||||
@@ -14,12 +14,14 @@ add_flang_library(CUFDialect
|
||||
CUFAttrs
|
||||
FIRDialect
|
||||
FIRDialectSupport
|
||||
MLIRIR
|
||||
MLIRGPUDialect
|
||||
MLIRTargetLLVMIRExport
|
||||
|
||||
LINK_COMPONENTS
|
||||
AsmParser
|
||||
AsmPrinter
|
||||
Remarks
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRIR
|
||||
MLIRGPUDialect
|
||||
MLIRTargetLLVMIRExport
|
||||
)
|
||||
|
||||
@@ -8,6 +8,6 @@ add_flang_library(FIRDialectSupport
|
||||
MLIRIR
|
||||
intrinsics_gen
|
||||
|
||||
LINK_LIBS
|
||||
MLIR_LIBS
|
||||
${dialect_libs}
|
||||
)
|
||||
|
||||
@@ -13,11 +13,13 @@ add_flang_library(HLFIRDialect
|
||||
LINK_LIBS
|
||||
CUFAttrs
|
||||
FIRDialect
|
||||
MLIRIR
|
||||
${dialect_libs}
|
||||
|
||||
LINK_COMPONENTS
|
||||
AsmParser
|
||||
AsmPrinter
|
||||
Remarks
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRIR
|
||||
${dialect_libs}
|
||||
)
|
||||
|
||||
@@ -27,11 +27,13 @@ add_flang_library(HLFIRTransforms
|
||||
FIRTransforms
|
||||
FlangOpenMPTransforms
|
||||
HLFIRDialect
|
||||
MLIRIR
|
||||
${dialect_libs}
|
||||
|
||||
LINK_COMPONENTS
|
||||
AsmParser
|
||||
AsmPrinter
|
||||
Remarks
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRIR
|
||||
${dialect_libs}
|
||||
)
|
||||
|
||||
@@ -18,5 +18,7 @@ add_flang_library(FIROpenACCSupport
|
||||
FIRDialectSupport
|
||||
FIRSupport
|
||||
HLFIRDialect
|
||||
|
||||
MLIR_LIBS
|
||||
MLIROpenACCDialect
|
||||
)
|
||||
|
||||
@@ -23,9 +23,11 @@ add_flang_library(FlangOpenMPTransforms
|
||||
FIRSupport
|
||||
FortranCommon
|
||||
FortranEvaluate
|
||||
HLFIRDialect
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRFuncDialect
|
||||
MLIROpenMPDialect
|
||||
HLFIRDialect
|
||||
MLIRIR
|
||||
MLIRPass
|
||||
MLIRTransformUtils
|
||||
|
||||
@@ -12,16 +12,18 @@ add_flang_library(flangPasses
|
||||
FIRCodeGen
|
||||
FIRTransforms
|
||||
FlangOpenMPTransforms
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
FortranCommon
|
||||
HLFIRTransforms
|
||||
|
||||
LINK_COMPONENTS
|
||||
Passes
|
||||
|
||||
MLIR_LIBS
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
MLIRPass
|
||||
MLIRReconcileUnrealizedCasts
|
||||
MLIRSCFToControlFlow
|
||||
MLIRSupport
|
||||
MLIRTransforms
|
||||
|
||||
LINK_COMPONENTS
|
||||
Passes
|
||||
)
|
||||
|
||||
@@ -16,6 +16,11 @@ add_flang_library(FIRSupport
|
||||
|
||||
LINK_LIBS
|
||||
FIRDialect
|
||||
|
||||
LINK_COMPONENTS
|
||||
TargetParser
|
||||
|
||||
MLIR_LIBS
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
MLIRBuiltinToLLVMIRTranslation
|
||||
@@ -24,7 +29,4 @@ add_flang_library(FIRSupport
|
||||
MLIRLLVMToLLVMIRTranslation
|
||||
MLIRTargetLLVMIRExport
|
||||
MLIRTargetLLVMIRImport
|
||||
|
||||
LINK_COMPONENTS
|
||||
TargetParser
|
||||
)
|
||||
|
||||
@@ -48,6 +48,8 @@ add_flang_library(FIRTransforms
|
||||
FIRSupport
|
||||
FortranCommon
|
||||
HLFIRDialect
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRAffineUtils
|
||||
MLIRFuncDialect
|
||||
MLIRGPUDialect
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
add_flang_library(FortranSupport
|
||||
Timing.cpp
|
||||
|
||||
LINK_LIBS
|
||||
MLIRSupport
|
||||
|
||||
LINK_COMPONENTS
|
||||
Support
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRSupport
|
||||
)
|
||||
|
||||
@@ -16,14 +16,16 @@ add_flang_library(FIRTestAnalysis
|
||||
FIRSupport
|
||||
FIRTransforms
|
||||
FIRAnalysis
|
||||
MLIRTestAnalysis
|
||||
|
||||
MLIR_LIBS
|
||||
${dialect_libs}
|
||||
MLIRFuncDialect
|
||||
MLIRLLVMDialect
|
||||
MLIRAnalysis
|
||||
MLIRTestAnalysis
|
||||
)
|
||||
|
||||
target_include_directories(FIRTestAnalysis
|
||||
PRIVATE
|
||||
${MLIR_MAIN_SRC_DIR}/..
|
||||
)
|
||||
)
|
||||
|
||||
@@ -14,6 +14,8 @@ add_flang_library(FIRTestOpenACCInterfaces
|
||||
FIRDialect
|
||||
FIROpenACCSupport
|
||||
FIRSupport
|
||||
|
||||
MLIR_LIBS
|
||||
MLIRIR
|
||||
MLIROpenACCDialect
|
||||
MLIRPass
|
||||
|
||||
@@ -29,6 +29,9 @@ target_link_libraries(bbc PRIVATE
|
||||
flangFrontend
|
||||
flangPasses
|
||||
FlangOpenMPTransforms
|
||||
)
|
||||
|
||||
mlir_target_link_libraries(bbc PRIVATE
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
MLIRAffineToStandard
|
||||
|
||||
@@ -12,7 +12,9 @@ target_link_libraries(fir-lsp-server PRIVATE
|
||||
CUFDialect
|
||||
FIRDialect
|
||||
FIROpenACCSupport
|
||||
HLFIRDialect
|
||||
HLFIRDialect)
|
||||
|
||||
mlir_target_link_libraries(fir-lsp-server PRIVATE
|
||||
MLIRLspServerLib
|
||||
${dialect_libs}
|
||||
${extension_libs})
|
||||
|
||||
@@ -24,6 +24,9 @@ target_link_libraries(fir-opt PRIVATE
|
||||
FlangOpenMPTransforms
|
||||
FIRAnalysis
|
||||
${test_libs}
|
||||
)
|
||||
|
||||
mlir_target_link_libraries(fir-opt PRIVATE
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
|
||||
|
||||
@@ -21,6 +21,9 @@ target_link_libraries(tco PRIVATE
|
||||
FIROpenACCSupport
|
||||
FlangOpenMPTransforms
|
||||
FortranCommon
|
||||
)
|
||||
|
||||
mlir_target_link_libraries(tco PRIVATE
|
||||
${dialect_libs}
|
||||
${extension_libs}
|
||||
MLIRIR
|
||||
|
||||
@@ -20,5 +20,9 @@ target_link_libraries(FlangFrontendTests
|
||||
FortranSemantics
|
||||
FortranCommon
|
||||
FortranEvaluate
|
||||
)
|
||||
|
||||
mlir_target_link_libraries(FlangFrontendTests
|
||||
PRIVATE
|
||||
MLIRIR
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user