Skip to content
7 changes: 7 additions & 0 deletions llvm/utils/TableGen/Basic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ set(LLVM_LINK_COMPONENTS
)

add_llvm_library(LLVMTableGenBasic OBJECT EXCLUDE_FROM_ALL DISABLE_LLVM_LINK_LLVM_DYLIB
ARMTargetDefEmitter.cpp
Attributes.cpp
CodeGenIntrinsics.cpp
DirectiveEmitter.cpp
IntrinsicEmitter.cpp
RISCVTargetDefEmitter.cpp
SDNodeProperties.cpp
TableGen.cpp
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest TableGen.cpp may be individual. IIRC, some cmake generators don't like add_executable w/o any source files.

Copy link
Member Author

@Meinersbur Meinersbur Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CMake has a problem to identify which linker to use (C or C++) when there is no .c/.cpp file in the list. A strategy used elsewhere also in LLVM adds an empty dummy.cpp into the list.

Keeping TableGen.cpp (or using the same dummy.cpp) in both executables would defeat the entire purpose of this patch: The same timestamp issue still occurs with even just a single file which causes all .td files to be processed again in a no-change build (see summary).

I instead applied the usual source structure of an executable: One file per executable which named after the executable name containing the (in this case trivial) main function, which just calls the tblgen_main in TableGen.cpp. This should also clear up any confusion (including mine) of where each executable's main function is.

VTEmitter.cpp
)

# Users may include its headers as "Basic/*.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
//
//===----------------------------------------------------------------------===//

#include "Basic/CodeGenIntrinsics.h"
#include "Basic/SequenceToOffsetTable.h"
#include "CodeGenIntrinsics.h"
#include "SequenceToOffsetTable.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
Expand Down
19 changes: 3 additions & 16 deletions llvm/utils/TableGen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,14 @@ add_subdirectory(Basic)
# code needed by the backends.
add_subdirectory(Common)

set(LLVM_LINK_COMPONENTS Support)

# llvm-min-tablegen only contains a subset of backends necessary to
# build llvm/include. It must not depend on TableGenCommon, as
# TableGenCommon depends on this already to generate things such as
# ValueType definitions.
# Sources included in both, llvm-min-tblgen and llvm-tblgen, must be included
# into LLVMTableGenBasic to avoid redundant compilation and problems with build
# caches.
add_tablegen(llvm-min-tblgen LLVM_HEADERS
TableGen.cpp
ARMTargetDefEmitter.cpp
Attributes.cpp
DirectiveEmitter.cpp
IntrinsicEmitter.cpp
RISCVTargetDefEmitter.cpp
VTEmitter.cpp
$<TARGET_OBJECTS:obj.LLVMTableGenBasic>

PARTIAL_SOURCES_INTENDED
Expand All @@ -32,10 +26,8 @@ set(LLVM_LINK_COMPONENTS
add_tablegen(llvm-tblgen LLVM
DESTINATION "${LLVM_TOOLS_INSTALL_DIR}"
EXPORT LLVM
ARMTargetDefEmitter.cpp
AsmMatcherEmitter.cpp
AsmWriterEmitter.cpp
Attributes.cpp
CallingConvEmitter.cpp
CodeEmitterGen.cpp
CodeGenMapTable.cpp
Expand All @@ -48,7 +40,6 @@ add_tablegen(llvm-tblgen LLVM
DecoderEmitter.cpp
DFAEmitter.cpp
DFAPacketizerEmitter.cpp
DirectiveEmitter.cpp
DisassemblerEmitter.cpp
DXILEmitter.cpp
ExegesisEmitter.cpp
Expand All @@ -57,18 +48,14 @@ add_tablegen(llvm-tblgen LLVM
GlobalISelEmitter.cpp
InstrDocsEmitter.cpp
InstrInfoEmitter.cpp
IntrinsicEmitter.cpp
MacroFusionPredicatorEmitter.cpp
OptionParserEmitter.cpp
OptionRSTEmitter.cpp
PseudoLoweringEmitter.cpp
RegisterBankEmitter.cpp
RegisterInfoEmitter.cpp
RISCVTargetDefEmitter.cpp
SearchableTableEmitter.cpp
SubtargetEmitter.cpp
TableGen.cpp
VTEmitter.cpp
WebAssemblyDisassemblerEmitter.cpp
X86InstrMappingEmitter.cpp
X86DisassemblerTables.cpp
Expand Down
Loading