Ensure .inc files are regenerated when llvm/clang tblgen binaries change

When doing a fully incremental build (with WITHOUT_CLEAN enabled), from
a commit before llvm 15 was merged (3264f6b88f), to a commit after
that, a number of .inc files were not regenerated. This could lead to
unexpected compilation errors when these .inc files were included from
llvm-project sources, similar to:

  In file included from /usr/src/contrib/llvm-project/clang/lib/CodeGen/CGBuiltin.cpp:8268:
  /usr/obj/usr/src/amd64.amd64/lib/clang/libclang/clang/Basic/arm_mve_builtin_cg.inc:279:18: error: no matching constructor for initialization of 'clang::CodeGen::Address'
    Address Val2 = Address(Val1, CharUnits::fromQuantity(2));
                   ^       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Work around this by making the .inc files dependent on the tblgen binary
used for generating them. E.g., we can relatively safely assume that if
the binary gets updated, the .inc files must also be updated. (Although
this is not 100% optimal, the gain by complicating things even more is
probaby not worth the effort.)

MFC after:	3 days
Reviewed by:	emaste
Differential Revision: https://reviews.freebsd.org/D38770
This commit is contained in:
Dimitry Andric 2023-02-25 16:25:57 +01:00
parent 5ff7fb76cb
commit ab80f0b21f
18 changed files with 48 additions and 7 deletions

View File

@ -5,3 +5,4 @@
CLANG_SRCS= ${LLVM_BASE}/clang CLANG_SRCS= ${LLVM_BASE}/clang
CLANG_TBLGEN?= clang-tblgen CLANG_TBLGEN?= clang-tblgen
CLANG_TBLGEN_BIN!= which ${CLANG_TBLGEN}

View File

@ -214,6 +214,8 @@ riscv_${hdr:H}.h: ${CLANG_SRCS}/include/clang/Basic/riscv_${hdr:H}.td
GENINCS+= riscv_${hdr:H}.h GENINCS+= riscv_${hdr:H}.h
.endfor .endfor
${GENINCS}: ${CLANG_TBLGEN_BIN}
CLEANFILES= ${GENINCS} ${GENINCS:C/$/.d/} CLEANFILES= ${GENINCS} ${GENINCS:C/$/.d/}
.include <bsd.prog.mk> .include <bsd.prog.mk>

View File

@ -1037,13 +1037,6 @@ clang/Basic/riscv_vector_builtin_sema.inc: \
-o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
TGHDRS+= clang/Basic/riscv_vector_builtin_sema.inc TGHDRS+= clang/Basic/riscv_vector_builtin_sema.inc
clang/Driver/Options.inc: ${CLANG_SRCS}/include/clang/Driver/Options.td
${LLVM_TBLGEN} -gen-opt-parser-defs \
-I ${LLVM_SRCS}/include -I ${CLANG_SRCS}/include/clang/Driver \
-d ${.TARGET:C/$/.d/} -o ${.TARGET} \
${CLANG_SRCS}/include/clang/Driver/Options.td
TGHDRS+= clang/Driver/Options.inc
clang/Parse/AttrParserStringSwitches.inc: \ clang/Parse/AttrParserStringSwitches.inc: \
${CLANG_SRCS}/include/clang/Basic/Attr.td ${CLANG_SRCS}/include/clang/Basic/Attr.td
${CLANG_TBLGEN} -gen-clang-attr-parser-string-switches \ ${CLANG_TBLGEN} -gen-clang-attr-parser-string-switches \
@ -1121,10 +1114,25 @@ OpenCLBuiltins.inc: ${CLANG_SRCS}/lib/Sema/OpenCLBuiltins.td
${CLANG_SRCS}/lib/Sema/OpenCLBuiltins.td ${CLANG_SRCS}/lib/Sema/OpenCLBuiltins.td
TGHDRS+= OpenCLBuiltins.inc TGHDRS+= OpenCLBuiltins.inc
${TGHDRS}: ${CLANG_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}
clang/Driver/Options.inc: ${CLANG_SRCS}/include/clang/Driver/Options.td
${LLVM_TBLGEN} -gen-opt-parser-defs \
-I ${LLVM_SRCS}/include -I ${CLANG_SRCS}/include/clang/Driver \
-d ${.TARGET:C/$/.d/} -o ${.TARGET} \
${CLANG_SRCS}/include/clang/Driver/Options.td
LTGHDRS+= clang/Driver/Options.inc
${LTGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${LTGHDRS:C/$/.d/}
DPSRCS+= ${LTGHDRS}
CLEANFILES+= ${LTGHDRS} ${LTGHDRS:C/$/.d/}
.include "../clang.build.mk" .include "../clang.build.mk"
INTERNALLIB= INTERNALLIB=

View File

@ -701,6 +701,7 @@ SRCS+= Utility/XcodeSDK.cpp
SRCS+= Version/Version.cpp SRCS+= Version/Version.cpp
LLDB_TBLGEN?= lldb-tblgen LLDB_TBLGEN?= lldb-tblgen
LLDB_TBLGEN_BIN!= which ${LLDB_TBLGEN}
CommandOptions.inc: ${LLDB_SRCS}/source/Commands/Options.td CommandOptions.inc: ${LLDB_SRCS}/source/Commands/Options.td
${LLDB_TBLGEN} -gen-lldb-option-defs \ ${LLDB_TBLGEN} -gen-lldb-option-defs \
@ -728,6 +729,8 @@ ${path:T}PropertiesEnum.inc: ${LLDB_SRCS}/source/${path}Properties.td
TGHDRS+= ${path:T}PropertiesEnum.inc TGHDRS+= ${path:T}PropertiesEnum.inc
.endfor .endfor
${TGHDRS}: ${LLDB_TBLGEN_BIN}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -2128,6 +2128,8 @@ TGHDRS+= X86GenRegisterInfo.inc
TGHDRS+= X86GenSubtargetInfo.inc TGHDRS+= X86GenSubtargetInfo.inc
.endif # MK_LLVM_TARGET_X86 .endif # MK_LLVM_TARGET_X86
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -5,3 +5,4 @@ LLVM_BASE= ${SRCTOP}/contrib/llvm-project
LLVM_SRCS= ${LLVM_BASE}/llvm LLVM_SRCS= ${LLVM_BASE}/llvm
LLVM_TBLGEN?= llvm-tblgen LLVM_TBLGEN?= llvm-tblgen
LLVM_TBLGEN_BIN!= which ${LLVM_TBLGEN}

View File

@ -95,6 +95,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -37,6 +37,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -30,6 +30,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -21,6 +21,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -18,6 +18,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -19,6 +19,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -23,6 +23,8 @@ ${hdr}.inc: ${LLVM_BASE}/${SRCDIR}/${hdr}.td
TGHDRS+= ${hdr}.inc TGHDRS+= ${hdr}.inc
.endfor .endfor
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -26,6 +26,8 @@ ${hdr}.inc: ${LLVM_BASE}/${SRCDIR}/${hdr}.td
TGHDRS+= ${hdr}.inc TGHDRS+= ${hdr}.inc
.endfor .endfor
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -30,6 +30,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -19,6 +19,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -17,6 +17,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}

View File

@ -20,6 +20,8 @@ ${INCFILE}: ${TDFILE}
-o ${.TARGET} ${TDFILE} -o ${.TARGET} ${TDFILE}
TGHDRS+= ${INCFILE} TGHDRS+= ${INCFILE}
${TGHDRS}: ${LLVM_TBLGEN_BIN}
DEPENDFILES+= ${TGHDRS:C/$/.d/} DEPENDFILES+= ${TGHDRS:C/$/.d/}
DPSRCS+= ${TGHDRS} DPSRCS+= ${TGHDRS}
CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/} CLEANFILES+= ${TGHDRS} ${TGHDRS:C/$/.d/}