Re: Avoiding llvm from ports on rpi4

From: Mark Millard <marklmi_at_yahoo.com>
Date: Sat, 22 Feb 2025 18:56:03 UTC
On Feb 22, 2025, at 08:06, Nuno Teixeira <eduardo@freebsd.org> wrote:

> Hello,
> 
> Building llvm19 as a dependency just for mesa-dri is something
> that I like to tweak to avoid waiting >15 hours building it.
> 
> pkg info -r llvm19
> llvm19-19.1.7_1:
>         mesa-dri-24.1.7_4
> 
> There is a PR about it, but I don't know the best way to hack it:
> https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238906

I added some notes that that bugzilla:

QUOTE
The system's clang/clang++ build (from based on
LLVM) does not include what mesa-dri uses from
LLVM.
END QUOTE

QUOTE
In fact, mesa-dri uses LLVM as a library, not
as a compiler (not clang/clang++):

USES+= llvm:lib,noexport

mesa-dri also uses other ports that are LLVM
based (at least when iris is to be supported):

devel/libclc@${LLVM_PORT:T}
spirv-llvm-translator@${LLVM_PORT:T}

Those references are from doing:

# grep -i llvm /usr/ports/graphics/mesa-dri/Makefile
USES+= llvm:lib,noexport
iris_BUILD_DEPENDS= libclc-${LLVM_PORT:T}>0:devel/libclc@${LLVM_PORT:T} \
spirv-llvm-translator-${LLVM_PORT:T}>0:devel/spirv-llvm-translator@${LLVM_PORT:T}
spirv-llvm-translator-${LLVM_PORT:T}>0:devel/spirv-llvm-translator@${LLVM_PORT:T}
iris_CONFIGURE_ENV= PKG_CONFIG_PATH="${LLVM_PREFIX}/libdata/pkgconfig"
libclc-${LLVM_PORT:T}>0:devel/libclc@${LLVM_PORT:T} \
spirv-llvm-translator-${LLVM_PORT:T}>0:devel/spirv-llvm-translator@${LLVM_PORT:T}
spirv-llvm-translator-${LLVM_PORT:T}>0:devel/spirv-llvm-translator@${LLVM_PORT:T}
anv_CONFIGURE_ENV= PKG_CONFIG_PATH="${LLVM_PREFIX}/libdata/pkgconfig"
END QUOTE

The notation suggests that devel/libclc and
devel/spirv-llvm-translator that mesa-dri
can have involved are somehow specific to
the same LLVM variant that mesa-dri uses.


A question is what llvm build options are you using
for LLVM?

Are you building MLIR? FLANG? POLLY? If yes, do you
need to for your context? (As I remember MLIR and
POLLY are built by default. FLANG is not but
requires MLIR if FLANG is listed as an option.)

The default options are set up for the official
builds to support all the different usage contexts
in the ports tree (or near it).

Are you building LLVM such that it supports
targeting powerpc*? riscv64? amd64 and i386?
There are ways to avoid building materials for
taretting those. You might be able to use
BE_NATIVE instead of BE_STANDARD and avoid
such.

Do you need to target aarch64 and/or armv7 for
your specific usage context for devel/llvm*?
(It likely would take Makefile changes to avoid
building to support those.)

A similar set of question goes for mesa-dri:
Do you need all of:

OPTIONS_DEFINE= ZSTD
OPTIONS_GROUP= GALLIUM PLATFORM VULKAN
OPTIONS_GROUP_PLATFORM= X11 WAYLAND
OPTIONS_GROUP_GALLIUM= crocus i915 iris panfrost r300 r600 radeonsi svga swrast zink
OPTIONS_GROUP_VULKAN= anv radv swrast_vk

For example avoiding iris looks to avoid the
devel/libclc@${LLVM_PORT:T} and
devel/spirv-llvm-translator@${LLVM_PORT:T}
involvement.

Out of the above, what do you actually need
for your RPi4 activity? Which do not need to
be supported for your activity?


===
Mark Millard
marklmi at yahoo.com