diff mbox series

[4/6] llvm: allow building libllvm in native builds, subject to PACKAGECONFIG

Message ID 20230316094102.2628727-4-alex@linutronix.de
State New
Headers show
Series [1/6] runqemu: direct mesa to use its own drivers, rather than ones provided by host distro | expand

Commit Message

Alexander Kanavin March 16, 2023, 9:41 a.m. UTC
Also, enable that, if opengl is in native DISTRO_FEATURES: this allows
mesa-native to build drivers that rely on libllvm, particularly llvmpipe,
which is a (sort of) accelerated software renderer that is the only
option on build hosts without dedicated or supported GPUs.

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/recipes-devtools/llvm/llvm_git.bb | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Ross Burton March 20, 2023, 4:20 p.m. UTC | #1
On 16 Mar 2023, at 09:41, Alexander Kanavin via lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org> wrote:
> +PACKAGECONFIG:class-native = "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'libllvm', '', d)}"

Currently the llvm drivers in Mesa are the only known user of libllvm in oe-core, but I don’t like making that a hard assertion in the recipe and the subsequent native/target specific changes to the recipe.

What’s the build impact on llvm-native of enabling/disabling libllvm and why shouldn’t we just do it always?

Ross
Alexander Kanavin March 20, 2023, 5:36 p.m. UTC | #2
On Mon, 20 Mar 2023 at 17:20, Ross Burton <Ross.Burton@arm.com> wrote:
> Currently the llvm drivers in Mesa are the only known user of libllvm in oe-core, but I don’t like making that a hard assertion in the recipe and the subsequent native/target specific changes to the recipe.
>
> What’s the build impact on llvm-native of enabling/disabling libllvm and why shouldn’t we just do it always?

I think that's answered elsewhere in the series. It's still 4 times
quicker than rust-native. Maybe we should just embrace this brave new
world of toolchains with heavy build times.

Alex
diff mbox series

Patch

diff --git a/meta/recipes-devtools/llvm/llvm_git.bb b/meta/recipes-devtools/llvm/llvm_git.bb
index b4e983d2d0..f133653903 100644
--- a/meta/recipes-devtools/llvm/llvm_git.bb
+++ b/meta/recipes-devtools/llvm/llvm_git.bb
@@ -57,9 +57,11 @@  def get_llvm_arch(bb, d, arch_var):
 def get_llvm_host_arch(bb, d):
     return get_llvm_arch(bb, d, 'HOST_ARCH')
 
-PACKAGECONFIG ??= ""
+PACKAGECONFIG ??= "libllvm"
+PACKAGECONFIG:class-native = "${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'libllvm', '', d)}"
 # if optviewer OFF, force the modules to be not found or the ones on the host would be found
 PACKAGECONFIG[optviewer] = ",-DPY_PYGMENTS_FOUND=OFF -DPY_PYGMENTS_LEXERS_C_CPP_FOUND=OFF -DPY_YAML_FOUND=OFF,python3-pygments python3-pyyaml,python3-pygments python3-pyyaml"
+PACKAGECONFIG[libllvm] = ""
 
 #
 # Default to build all OE-Core supported target arches (user overridable).
@@ -102,14 +104,15 @@  do_compile:prepend:class-target() {
 }
 
 do_compile() {
+    if ${@bb.utils.contains('PACKAGECONFIG', 'libllvm', 'true', 'false', d)}; then
 	ninja -v ${PARALLEL_MAKE}
-}
-
-do_compile:class-native() {
+    else
 	ninja -v ${PARALLEL_MAKE} llvm-config llvm-tblgen
+    fi
 }
 
 do_install() {
+    if ${@bb.utils.contains('PACKAGECONFIG', 'libllvm', 'true', 'false', d)}; then
 	DESTDIR=${D} ninja -v install
 
         # llvm harcodes usr/lib as install path, so this corrects it to actual libdir
@@ -121,9 +124,10 @@  do_install() {
 
         # reproducibility
         sed -i -e 's,${WORKDIR},,g' ${D}/${libdir}/cmake/llvm/LLVMConfig.cmake
+    fi
 }
 
-do_install:class-native() {
+do_install:append:class-native() {
 	install -D -m 0755 ${B}/bin/llvm-tblgen ${D}${bindir}/llvm-tblgen${PV}
 	install -D -m 0755 ${B}/bin/llvm-config ${D}${bindir}/llvm-config${PV}
 	ln -sf llvm-config${PV} ${D}${bindir}/llvm-config