Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Mar 2023 18:24:36 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 3912f99ecae6 - stable/13 - Ensure .inc files are regenerated when llvm/clang tblgen binaries change
Message-ID:  <202303011824.321IOaY8083959@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=3912f99ecae61dc7fe89c076a654332e3adb1bdc

commit 3912f99ecae61dc7fe89c076a654332e3adb1bdc
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-02-25 15:25:57 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-03-01 18:24:18 +0000

    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 (3264f6b88fce), 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
    
    (cherry picked from commit ab80f0b21fbb9c44d40e6f7a99090188f4ed2f71)
---
 lib/clang/clang.pre.mk                 |  1 +
 lib/clang/headers/Makefile             |  2 ++
 lib/clang/libclang/Makefile            | 22 +++++++++++++++-------
 lib/clang/liblldb/Makefile             |  3 +++
 lib/clang/libllvm/Makefile             |  2 ++
 lib/clang/llvm.pre.mk                  |  1 +
 usr.bin/clang/lld/Makefile             |  2 ++
 usr.bin/clang/lldb-server/Makefile     |  2 ++
 usr.bin/clang/lldb/Makefile            |  2 ++
 usr.bin/clang/llvm-cxxfilt/Makefile    |  2 ++
 usr.bin/clang/llvm-nm/Makefile         |  2 ++
 usr.bin/clang/llvm-objcopy/Makefile    |  2 ++
 usr.bin/clang/llvm-objdump/Makefile    |  2 ++
 usr.bin/clang/llvm-readobj/Makefile    |  2 ++
 usr.bin/clang/llvm-size/Makefile       |  2 ++
 usr.bin/clang/llvm-strings/Makefile    |  2 ++
 usr.bin/clang/llvm-symbolizer/Makefile |  2 ++
 17 files changed, 46 insertions(+), 7 deletions(-)

diff --git a/lib/clang/clang.pre.mk b/lib/clang/clang.pre.mk
index 520a9300e6ce..9ef401645f14 100644
--- a/lib/clang/clang.pre.mk
+++ b/lib/clang/clang.pre.mk
@@ -5,3 +5,4 @@
 CLANG_SRCS=	${LLVM_BASE}/clang
 
 CLANG_TBLGEN?=	clang-tblgen
+CLANG_TBLGEN_BIN!= which ${CLANG_TBLGEN}
diff --git a/lib/clang/headers/Makefile b/lib/clang/headers/Makefile
index 80a1250f6366..c4643e9353e6 100644
--- a/lib/clang/headers/Makefile
+++ b/lib/clang/headers/Makefile
@@ -200,6 +200,8 @@ riscv_${hdr:H}.h: ${CLANG_SRCS}/include/clang/Basic/riscv_${hdr:H}.td
 GENINCS+=	riscv_${hdr:H}.h
 .endfor
 
+${GENINCS}: ${CLANG_TBLGEN_BIN}
+
 CLEANFILES=	${GENINCS} ${GENINCS:C/$/.d/}
 
 .include <bsd.prog.mk>
diff --git a/lib/clang/libclang/Makefile b/lib/clang/libclang/Makefile
index a2612bc9d894..cdffedfe3d36 100644
--- a/lib/clang/libclang/Makefile
+++ b/lib/clang/libclang/Makefile
@@ -1010,13 +1010,6 @@ clang/Basic/riscv_vector_builtin_cg.inc: \
 	    -o ${.TARGET} ${CLANG_SRCS}/include/clang/Basic/riscv_vector.td
 TGHDRS+=	clang/Basic/riscv_vector_builtin_cg.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_SRCS}/include/clang/Basic/Attr.td
 	${CLANG_TBLGEN} -gen-clang-attr-parser-string-switches \
@@ -1094,10 +1087,25 @@ OpenCLBuiltins.inc: ${CLANG_SRCS}/lib/Sema/OpenCLBuiltins.td
 	    ${CLANG_SRCS}/lib/Sema/OpenCLBuiltins.td
 TGHDRS+=	OpenCLBuiltins.inc
 
+${TGHDRS}: ${CLANG_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 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"
 
 INTERNALLIB=
diff --git a/lib/clang/liblldb/Makefile b/lib/clang/liblldb/Makefile
index 28778cb04c57..dbf9c6d696e7 100644
--- a/lib/clang/liblldb/Makefile
+++ b/lib/clang/liblldb/Makefile
@@ -693,6 +693,7 @@ SRCS+=		Utility/VMRange.cpp
 SRCS+=		Version/Version.cpp
 
 LLDB_TBLGEN?=	lldb-tblgen
+LLDB_TBLGEN_BIN!= which ${LLDB_TBLGEN}
 
 CommandOptions.inc: ${LLDB_SRCS}/source/Commands/Options.td
 	${LLDB_TBLGEN} -gen-lldb-option-defs \
@@ -720,6 +721,8 @@ ${path:T}PropertiesEnum.inc: ${LLDB_SRCS}/source/${path}Properties.td
 TGHDRS+=	${path:T}PropertiesEnum.inc
 .endfor
 
+${TGHDRS}: ${LLDB_TBLGEN_BIN}
+
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
 
diff --git a/lib/clang/libllvm/Makefile b/lib/clang/libllvm/Makefile
index 868f9aa48964..ef9d87dd7d2f 100644
--- a/lib/clang/libllvm/Makefile
+++ b/lib/clang/libllvm/Makefile
@@ -2026,6 +2026,8 @@ TGHDRS+=	X86GenRegisterInfo.inc
 TGHDRS+=	X86GenSubtargetInfo.inc
 .endif # MK_LLVM_TARGET_X86
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/lib/clang/llvm.pre.mk b/lib/clang/llvm.pre.mk
index 774d7d47ea37..92124a7bf092 100644
--- a/lib/clang/llvm.pre.mk
+++ b/lib/clang/llvm.pre.mk
@@ -5,3 +5,4 @@ LLVM_BASE=	${SRCTOP}/contrib/llvm-project
 LLVM_SRCS=	${LLVM_BASE}/llvm
 
 LLVM_TBLGEN?=	llvm-tblgen
+LLVM_TBLGEN_BIN!= which ${LLVM_TBLGEN}
diff --git a/usr.bin/clang/lld/Makefile b/usr.bin/clang/lld/Makefile
index 9f114dbb81bf..1113072e4e9d 100644
--- a/usr.bin/clang/lld/Makefile
+++ b/usr.bin/clang/lld/Makefile
@@ -95,6 +95,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/lldb-server/Makefile b/usr.bin/clang/lldb-server/Makefile
index 9c3883984618..efe8529f3611 100644
--- a/usr.bin/clang/lldb-server/Makefile
+++ b/usr.bin/clang/lldb-server/Makefile
@@ -37,6 +37,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/lldb/Makefile b/usr.bin/clang/lldb/Makefile
index 10ffd3b90057..8e160b18eaa5 100644
--- a/usr.bin/clang/lldb/Makefile
+++ b/usr.bin/clang/lldb/Makefile
@@ -30,6 +30,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-cxxfilt/Makefile b/usr.bin/clang/llvm-cxxfilt/Makefile
index a61e32db9aa7..073316b7b4a7 100644
--- a/usr.bin/clang/llvm-cxxfilt/Makefile
+++ b/usr.bin/clang/llvm-cxxfilt/Makefile
@@ -19,6 +19,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-nm/Makefile b/usr.bin/clang/llvm-nm/Makefile
index 0df48744632d..d3099e5a75be 100644
--- a/usr.bin/clang/llvm-nm/Makefile
+++ b/usr.bin/clang/llvm-nm/Makefile
@@ -19,6 +19,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-objcopy/Makefile b/usr.bin/clang/llvm-objcopy/Makefile
index 80aa29949edf..995a8b461344 100644
--- a/usr.bin/clang/llvm-objcopy/Makefile
+++ b/usr.bin/clang/llvm-objcopy/Makefile
@@ -36,6 +36,8 @@ ${hdr}.inc: ${LLVM_BASE}/${SRCDIR}/${hdr}.td
 TGHDRS+=	${hdr}.inc
 .endfor
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-objdump/Makefile b/usr.bin/clang/llvm-objdump/Makefile
index 443128460f99..8a9587129f36 100644
--- a/usr.bin/clang/llvm-objdump/Makefile
+++ b/usr.bin/clang/llvm-objdump/Makefile
@@ -25,6 +25,8 @@ ${hdr}.inc: ${LLVM_BASE}/${SRCDIR}/${hdr}.td
 TGHDRS+=	${hdr}.inc
 .endfor
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-readobj/Makefile b/usr.bin/clang/llvm-readobj/Makefile
index 4b547d81c583..8926eb03bdbf 100644
--- a/usr.bin/clang/llvm-readobj/Makefile
+++ b/usr.bin/clang/llvm-readobj/Makefile
@@ -30,6 +30,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-size/Makefile b/usr.bin/clang/llvm-size/Makefile
index 20bd5de61192..f39e5db6f872 100644
--- a/usr.bin/clang/llvm-size/Makefile
+++ b/usr.bin/clang/llvm-size/Makefile
@@ -19,6 +19,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-strings/Makefile b/usr.bin/clang/llvm-strings/Makefile
index 1438aa847997..253766ba084d 100644
--- a/usr.bin/clang/llvm-strings/Makefile
+++ b/usr.bin/clang/llvm-strings/Makefile
@@ -17,6 +17,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}
diff --git a/usr.bin/clang/llvm-symbolizer/Makefile b/usr.bin/clang/llvm-symbolizer/Makefile
index c4677169f912..ae417356df6b 100644
--- a/usr.bin/clang/llvm-symbolizer/Makefile
+++ b/usr.bin/clang/llvm-symbolizer/Makefile
@@ -20,6 +20,8 @@ ${INCFILE}: ${TDFILE}
 	    -o ${.TARGET} ${TDFILE}
 TGHDRS+=	${INCFILE}
 
+${TGHDRS}: ${LLVM_TBLGEN_BIN}
+
 DEPENDFILES+=	${TGHDRS:C/$/.d/}
 DPSRCS+=	${TGHDRS}
 CLEANFILES+=	${TGHDRS} ${TGHDRS:C/$/.d/}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202303011824.321IOaY8083959>