]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
llvm-tblgen-native: add new recipe
authorRoss Burton <ross.burton@arm.com>
Fri, 11 Jul 2025 15:51:35 +0000 (16:51 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 14 Jul 2025 16:49:06 +0000 (17:49 +0100)
Building the LLVM projects often means using the TableGen tools
(llvm-tblgen etc).

We currently build them as part of clang-native, but I am teasing the
clang recipe into its component parts and having to build llvm-native
or lldb-native simply for one tool isn't ideal.

Instead, add a native recipe that simply builds the tablegen binaries
for llvm, clang, and lldb

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/conf/distro/include/maintainers.inc
meta/recipes-devtools/clang/clang_git.bb
meta/recipes-devtools/clang/llvm-tblgen-native_git.bb [new file with mode: 0644]

index 60f04da6089476fc72be9c0532409755d00d523c..331c438fd677c0904a2d2856de431a1393f3cf42 100644 (file)
@@ -480,6 +480,7 @@ RECIPE_MAINTAINER:pn-linux-yocto-dev = "Bruce Ashfield <bruce.ashfield@gmail.com
 RECIPE_MAINTAINER:pn-linux-yocto-rt = "Bruce Ashfield <bruce.ashfield@gmail.com>"
 RECIPE_MAINTAINER:pn-linux-yocto-tiny = "Bruce Ashfield <bruce.ashfield@gmail.com>"
 RECIPE_MAINTAINER:pn-llvm-project-source-20.1.7 = "Khem Raj <raj.khem@gmail.com>"
+RECIPE_MAINTAINER:pn-llvm-tblgen-native = "Khem Raj <raj.khem@gmail.com>"
 RECIPE_MAINTAINER:pn-logrotate = "Yi Zhao <yi.zhao@windriver.com>"
 RECIPE_MAINTAINER:pn-log4cplus = "Unassigned <unassigned@yoctoproject.org>"
 RECIPE_MAINTAINER:pn-lrzsz = "Anuj Mittal <anuj.mittal@intel.com>"
index 2b5d3a275249fb153f9cf8da4a8c10d094e21264..0f1b950cc637c750243eab7330468f0dfc3c1c36 100644 (file)
@@ -207,7 +207,7 @@ EXTRA_OECMAKE:append:class-target = "\
                   -DLLDB_PYTHON_EXT_SUFFIX=${SOLIBSDEV} \
 "
 
-DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native ninja-native swig-native spirv-tools-native"
+DEPENDS = "binutils zlib zstd libffi libxml2 libxml2-native ninja-native swig-native spirv-tools-native llvm-tblgen-native"
 DEPENDS:append:class-nativesdk = " clang-crosssdk-${SDK_SYS} virtual/nativesdk-cross-binutils nativesdk-python3"
 DEPENDS:append:class-target = " clang-cross-${TARGET_ARCH} python3 ${@bb.utils.contains('TC_CXX_RUNTIME', 'llvm', 'compiler-rt libcxx', '', d)} spirv-llvm-translator-native"
 
@@ -276,18 +276,16 @@ do_install:append:class-native () {
         install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clangd-indexer ${D}${bindir}/clangd-indexer
     fi
     install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tidy-confusable-chars-gen ${D}${bindir}/clang-tidy-confusable-chars-gen
-    install -Dm 0755 ${B}${BINPATHPREFIX}/bin/clang-tblgen ${D}${bindir}/clang-tblgen
-    install -Dm 0755 ${B}${BINPATHPREFIX}/bin/lldb-tblgen ${D}${bindir}/lldb-tblgen
-    install -Dm 0755 ${B}${BINPATHPREFIX}/bin/llvm-min-tblgen ${D}${bindir}/llvm-min-tblgen
     install -Dm 0755 ${B}${BINPATHPREFIX}/bin/prepare_builtins ${D}${bindir}/prepare_builtins
 
     for f in `find ${D}${bindir} -executable -type f -not -type l`; do
         test -n "`file -b $f|grep -i ELF`" && ${STRIP} $f
         echo "stripped $f"
     done
-    ln -sf clang-tblgen ${D}${bindir}/clang-tblgen${PV}
-    ln -sf llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
     ln -sf llvm-config ${D}${bindir}/llvm-config${PV}
+
+    # These are provided by llvm-tblgen-native
+    rm ${D}${bindir}/*-tblgen
 }
 
 do_install:append:class-nativesdk () {
diff --git a/meta/recipes-devtools/clang/llvm-tblgen-native_git.bb b/meta/recipes-devtools/clang/llvm-tblgen-native_git.bb
new file mode 100644 (file)
index 0000000..be04c1a
--- /dev/null
@@ -0,0 +1,27 @@
+SUMMARY = "LLVM TableGen binaries, for the build host"
+SECTION = "devel"
+
+# Building the LLVM projects often means using the TableGen tools (llvm-tblgen,
+# etc). We could build these as part of llvm-native, but there are cases where
+# this would be overkill. For example, building a target LLDB needs native
+# tablegen binaries and a target libllvm so having to build a complete native
+# llvm is not needed.
+
+require common-clang.inc
+require common-source.inc
+
+inherit cmake pkgconfig native
+
+OECMAKE_SOURCEPATH = "${S}/llvm"
+
+EXTRA_OECMAKE += "-DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS='llvm;clang;lldb'"
+
+BINARIES = "llvm-min-tblgen llvm-tblgen clang-tblgen lldb-tblgen"
+
+OECMAKE_TARGET_COMPILE = "${BINARIES}"
+
+do_install() {
+    for f in ${BINARIES}; do
+        install -D ${B}/bin/$f ${D}${bindir}/$f
+    done
+}