llvm.org GIT mirror llvm / b35552d
Clean up a pile of hacks in our CMake build relating to TableGen. The first problem to fix is to stop creating synthetic *Table_gen targets next to all of the LLVM libraries. These had no real effect as CMake specifies that add_custom_command(OUTPUT ...) directives (what the 'tablegen(...)' stuff expands to) are implicitly added as dependencies to all the rules in that CMakeLists.txt. These synthetic rules started to cause problems as we started more and more heavily using tablegen files from *subdirectories* of the one where they were generated. Within those directories, the set of tablegen outputs was still available and so these synthetic rules added them as dependencies of those subdirectories. However, they were no longer properly associated with the custom command to generate them. Most of the time this "just worked" because something would get to the parent directory first, and run tablegen there. Once run, the files existed and the build proceeded happily. However, as more and more subdirectories have started using this, the probability of this failing to happen has increased. Recently with the MC refactorings, it became quite common for me when touching a large enough number of targets. To add insult to injury, several of the backends *tried* to fix this by adding explicit dependencies back to the parent directory's tablegen rules, but those dependencies didn't work as expected -- they weren't forming a linear chain, they were adding another thread in the race. This patch removes these synthetic rules completely, and adds a much simpler function to declare explicitly that a collection of tablegen'ed files are referenced by other libraries. From that, we can add explicit dependencies from the smaller libraries (such as every architectures Desc library) on this and correctly form a linear sequence. All of the backends are updated to use it, sometimes replacing the existing attempt at adding a dependency, sometimes adding a previously missing dependency edge. Please let me know if this causes any problems, but it fixes a rather persistent and problematic source of build flakiness on our end. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136023 91177308-0d34-0410-b5e6-96231b3b80d8 Chandler Carruth 8 years ago
41 changed file(s) with 43 addition(s) and 33 deletion(s). Raw diff Collapse all Expand all
11 include(LLVM-Config)
22
33 macro(add_llvm_library name)
4 create_tablegenning_custom_target( ${name} )
54 llvm_process_sources( ALL_FILES ${ARGN} )
65 add_library( ${name} ${ALL_FILES} )
76 set_property( GLOBAL APPEND PROPERTY LLVM_LIBS ${name} )
3231 add_dependencies(${name} ${CURRENT_LLVM_TARGET})
3332 endif()
3433 set_target_properties(${name} PROPERTIES FOLDER "Libraries")
35 add_tablegenning_dependency( ${name} )
3634 endmacro(add_llvm_library name)
3735
3836
7674
7775
7876 macro(add_llvm_executable name)
79 create_tablegenning_custom_target( ${name} )
8077 llvm_process_sources( ALL_FILES ${ARGN} )
8178 if( EXCLUDE_FROM_ALL )
8279 add_executable(${name} EXCLUDE_FROM_ALL ${ALL_FILES})
9087 add_dependencies( ${name} ${LLVM_COMMON_DEPENDS} )
9188 endif( LLVM_COMMON_DEPENDS )
9289 link_system_libs( ${name} )
93 add_tablegenning_dependency( ${name} )
9490 endmacro(add_llvm_executable name)
9591
9692
4444 PROPERTIES GENERATED 1)
4545 endmacro(tablegen)
4646
47
48 function(create_tablegenning_custom_target target)
49 # Creates the global target that runs the file-level dependencies
50 # for tablegenning.
47 function(add_public_tablegen_target target)
48 # Creates a target for publicly exporting tablegen dependencies.
5149 if( TABLEGEN_OUTPUT )
52 add_custom_target(${target}Table_gen
50 add_custom_target(${target}
5351 DEPENDS ${TABLEGEN_OUTPUT})
54 add_dependencies(${target}Table_gen ${LLVM_COMMON_DEPENDS})
52 add_dependencies(${target} ${LLVM_COMMON_DEPENDS})
5553 endif( TABLEGEN_OUTPUT )
5654 endfunction()
57
58 function(add_tablegenning_dependency target)
59 # Makes the tablegenning step created with
60 # create_tablegenning_custom_target dependent on `target'.
61 if ( TABLEGEN_OUTPUT )
62 add_dependencies(${target} ${target}Table_gen)
63 set_target_properties(${target}Table_gen PROPERTIES FOLDER "Tablegenning")
64 endif (TABLEGEN_OUTPUT)
65 endfunction()
66
33 ARMAsmLexer.cpp
44 ARMAsmParser.cpp
55 )
6
6 add_dependencies(LLVMARMAsmParser ARMCommonTableGen)
1212 tablegen(ARMGenSubtargetInfo.inc -gen-subtarget)
1313 tablegen(ARMGenEDInfo.inc -gen-enhanced-disassembly-info)
1414 tablegen(ARMGenDecoderTables.inc -gen-arm-decoder)
15 add_public_tablegen_target(ARMCommonTableGen)
1516
1617 add_llvm_target(ARMCodeGen
1718 ARMAsmPrinter.cpp
1010 PROPERTY COMPILE_FLAGS "/Od"
1111 )
1212 endif()
13 add_dependencies(LLVMARMDisassembler ARMCodeGenTable_gen)
13 add_dependencies(LLVMARMDisassembler ARMCommonTableGen)
22 add_llvm_library(LLVMARMAsmPrinter
33 ARMInstPrinter.cpp
44 )
5 add_dependencies(LLVMARMAsmPrinter ARMCodeGenTable_gen)
5 add_dependencies(LLVMARMAsmPrinter ARMCommonTableGen)
55 ARMMCExpr.cpp
66 ARMMachObjectWriter.cpp
77 )
8 add_dependencies(LLVMARMDesc ARMCommonTableGen)
89
910 # Hack: we need to include 'main' target directory to grab private headers
1011 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/..)
55 tablegen(AlphaGenDAGISel.inc -gen-dag-isel)
66 tablegen(AlphaGenCallingConv.inc -gen-callingconv)
77 tablegen(AlphaGenSubtargetInfo.inc -gen-subtarget)
8 add_public_tablegen_target(AlphaCommonTableGen)
89
910 add_llvm_target(AlphaCodeGen
1011 AlphaAsmPrinter.cpp
11 AlphaMCTargetDesc.cpp
22 AlphaMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMAlphaDesc AlphaCommonTableGen)
22 add_llvm_library(LLVMAlphaInfo
33 AlphaTargetInfo.cpp
44 )
5
6 add_dependencies(LLVMAlphaInfo AlphaCodeGenTable_gen)
5 add_dependencies(LLVMAlphaInfo AlphaCommonTableGen)
66 tablegen(BlackfinGenSubtargetInfo.inc -gen-subtarget)
77 tablegen(BlackfinGenCallingConv.inc -gen-callingconv)
88 tablegen(BlackfinGenIntrinsics.inc -gen-tgt-intrinsic)
9 add_public_tablegen_target(BlackfinCommonTableGen)
910
1011 add_llvm_target(BlackfinCodeGen
1112 BlackfinAsmPrinter.cpp
11 BlackfinMCTargetDesc.cpp
22 BlackfinMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMBlackfinDesc BlackfinCommonTableGen)
66 tablegen(SPUGenDAGISel.inc -gen-dag-isel)
77 tablegen(SPUGenSubtargetInfo.inc -gen-subtarget)
88 tablegen(SPUGenCallingConv.inc -gen-callingconv)
9 add_public_tablegen_target(CellSPUCommonTableGen)
910
1011 add_llvm_target(CellSPUCodeGen
1112 SPUAsmPrinter.cpp
11 SPUMCTargetDesc.cpp
22 SPUMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMCellSPUDesc CellSPUCommonTableGen)
44 MBlazeAsmLexer.cpp
55 MBlazeAsmParser.cpp
66 )
7 add_dependencies(LLVMMBlazeAsmParser MBlazeCommonTableGen)
78
99 tablegen(MBlazeGenSubtargetInfo.inc -gen-subtarget)
1010 tablegen(MBlazeGenIntrinsics.inc -gen-tgt-intrinsic)
1111 tablegen(MBlazeGenEDInfo.inc -gen-enhanced-disassembly-info)
12 add_public_tablegen_target(MBlazeCommonTableGen)
1213
1314 add_llvm_target(MBlazeCodeGen
1415 MBlazeDelaySlotFiller.cpp
1212 )
1313 endif()
1414
15 add_dependencies(LLVMMBlazeDisassembler MBlazeCodeGenTable_gen)
15 add_dependencies(LLVMMBlazeDisassembler MBlazeCommonTableGen)
44 MBlazeInstPrinter.cpp
55 )
66
7 add_dependencies(LLVMMBlazeAsmPrinter MBlazeCodeGenTable_gen)
7 add_dependencies(LLVMMBlazeAsmPrinter MBlazeCommonTableGen)
33 MBlazeMCCodeEmitter.cpp
44 MBlazeMCTargetDesc.cpp
55 )
6 add_dependencies(LLVMMBlazeDesc MBlazeCommonTableGen)
55 tablegen(MSP430GenDAGISel.inc -gen-dag-isel)
66 tablegen(MSP430GenCallingConv.inc -gen-callingconv)
77 tablegen(MSP430GenSubtargetInfo.inc -gen-subtarget)
8 add_public_tablegen_target(MSP430CommonTableGen)
89
910 add_llvm_target(MSP430CodeGen
1011 MSP430BranchSelector.cpp
22 add_llvm_library(LLVMMSP430AsmPrinter
33 MSP430InstPrinter.cpp
44 )
5 add_dependencies(LLVMMSP430AsmPrinter MSP430CodeGenTable_gen)
5 add_dependencies(LLVMMSP430AsmPrinter MSP430CommonTableGen)
11 MSP430MCTargetDesc.cpp
22 MSP430MCAsmInfo.cpp
33 )
4 add_dependencies(LLVMMSP430Desc MSP430CommonTableGen)
55 tablegen(MipsGenDAGISel.inc -gen-dag-isel)
66 tablegen(MipsGenCallingConv.inc -gen-callingconv)
77 tablegen(MipsGenSubtargetInfo.inc -gen-subtarget)
8 add_public_tablegen_target(MipsCommonTableGen)
89
910 add_llvm_target(MipsCodeGen
1011 MipsAsmPrinter.cpp
22 add_llvm_library(LLVMMipsAsmPrinter
33 MipsInstPrinter.cpp
44 )
5 add_dependencies(LLVMMipsAsmPrinter MipsCodeGenTable_gen)
5 add_dependencies(LLVMMipsAsmPrinter MipsCommonTableGen)
11 MipsMCTargetDesc.cpp
22 MipsMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMMipsDesc MipsCommonTableGen)
55 tablegen(PTXGenInstrInfo.inc -gen-instr-info)
66 tablegen(PTXGenRegisterInfo.inc -gen-register-info)
77 tablegen(PTXGenSubtargetInfo.inc -gen-subtarget)
8 add_public_tablegen_target(PTXCommonTableGen)
89
910 add_llvm_target(PTXCodeGen
1011 PTXAsmPrinter.cpp
11 PTXMCTargetDesc.cpp
22 PTXMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMPTXDesc PTXCommonTableGen)
77 tablegen(PPCGenDAGISel.inc -gen-dag-isel)
88 tablegen(PPCGenCallingConv.inc -gen-callingconv)
99 tablegen(PPCGenSubtargetInfo.inc -gen-subtarget)
10 add_public_tablegen_target(PowerPCCommonTableGen)
1011
1112 add_llvm_target(PowerPCCodeGen
1213 PPCAsmPrinter.cpp
22 add_llvm_library(LLVMPowerPCAsmPrinter
33 PPCInstPrinter.cpp
44 )
5 add_dependencies(LLVMPowerPCAsmPrinter PowerPCCodeGenTable_gen)
5 add_dependencies(LLVMPowerPCAsmPrinter PowerPCCommonTableGen)
33 PPCMCAsmInfo.cpp
44 PPCMCCodeEmitter.cpp
55 )
6 add_dependencies(LLVMPowerPCDesc PowerPCCommonTableGen)
55 tablegen(SparcGenDAGISel.inc -gen-dag-isel)
66 tablegen(SparcGenSubtargetInfo.inc -gen-subtarget)
77 tablegen(SparcGenCallingConv.inc -gen-callingconv)
8 add_public_tablegen_target(SparcCommonTableGen)
89
910 add_llvm_target(SparcCodeGen
1011 DelaySlotFiller.cpp
11 SparcMCTargetDesc.cpp
22 SparcMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMSparcDesc SparcCommonTableGen)
55 tablegen(SystemZGenDAGISel.inc -gen-dag-isel)
66 tablegen(SystemZGenCallingConv.inc -gen-callingconv)
77 tablegen(SystemZGenSubtargetInfo.inc -gen-subtarget)
8 add_public_tablegen_target(SystemZCommonTableGen)
89
910 add_llvm_target(SystemZCodeGen
1011 SystemZAsmPrinter.cpp
11 SystemZMCTargetDesc.cpp
22 SystemZMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMSystemZDesc SystemZCommonTableGen)
45
56 # Hack: we need to include 'main' target directory to grab private headers
67 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/..)
33 X86AsmLexer.cpp
44 X86AsmParser.cpp
55 )
6 add_dependencies(LLVMX86AsmParser X86CodeGenTable_gen)
6 add_dependencies(LLVMX86AsmParser X86CommonTableGen)
1010 tablegen(X86GenCallingConv.inc -gen-callingconv)
1111 tablegen(X86GenSubtargetInfo.inc -gen-subtarget)
1212 tablegen(X86GenEDInfo.inc -gen-enhanced-disassembly-info)
13 add_public_tablegen_target(X86CommonTableGen)
1314
1415 set(sources
1516 SSEDomainFix.cpp
1010 PROPERTY COMPILE_FLAGS "/Od"
1111 )
1212 endif()
13 add_dependencies(LLVMX86Disassembler X86CodeGenTable_gen)
13 add_dependencies(LLVMX86Disassembler X86CommonTableGen)
44 X86IntelInstPrinter.cpp
55 X86InstComments.cpp
66 )
7 add_dependencies(LLVMX86AsmPrinter X86CodeGenTable_gen)
7 add_dependencies(LLVMX86AsmPrinter X86CommonTableGen)
44 X86MCCodeEmitter.cpp
55 X86MachObjectWriter.cpp
66 )
7 add_dependencies(LLVMX86Desc X86CommonTableGen)
78
89 # Hack: we need to include 'main' target directory to grab private headers
910 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/..)
55 tablegen(XCoreGenDAGISel.inc -gen-dag-isel)
66 tablegen(XCoreGenCallingConv.inc -gen-callingconv)
77 tablegen(XCoreGenSubtargetInfo.inc -gen-subtarget)
8 add_public_tablegen_target(XCoreCommonTableGen)
89
910 add_llvm_target(XCoreCodeGen
1011 XCoreAsmPrinter.cpp
11 XCoreMCTargetDesc.cpp
22 XCoreMCAsmInfo.cpp
33 )
4 add_dependencies(LLVMXCoreDesc XCoreCommonTableGen)
45
56 # Hack: we need to include 'main' target directory to grab private headers
67 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR}/..)