From 937d25be2fae96c5f68a0f53152aa83a736ebbd2 Mon Sep 17 00:00:00 2001
From: David Bauer <mail@david-bauer.net>
Date: Sun, 2 Mar 2025 01:33:45 +0100
Subject: [PATCH] build: use host LLVM toolchain

OpenWrt now employs eBPF components. These are built as we select all
non-shared packages.

Configure teh OpenWrt buildsystem to use the hots BPF toolchain and add
the required llvm compiler to the dependencies. This avoids increasing
the build-time as no eBPF toolchain needs to be built.

Signed-off-by: David Bauer <mail@david-bauer.net>
---
 contrib/docker/Dockerfile     | 2 ++
 docs/user/getting_started.rst | 2 ++
 targets/generic               | 1 +
 3 files changed, 5 insertions(+)

diff --git a/contrib/docker/Dockerfile b/contrib/docker/Dockerfile
index 98e14415..ca0903ad 100644
--- a/contrib/docker/Dockerfile
+++ b/contrib/docker/Dockerfile
@@ -7,6 +7,7 @@ ARG DEBIAN_FRONTEND=noninteractive
 RUN apt-get update && apt-get install -y --no-install-recommends \
     build-essential \
     ca-certificates \
+    clang \
     ecdsautils \
     file \
     gawk \
@@ -15,6 +16,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
     libncurses5-dev \
     libnss-unknown \
     libssl-dev \
+    llvm \
     lua-check \
     openssh-client \
     python3 \
diff --git a/docs/user/getting_started.rst b/docs/user/getting_started.rst
index 010d605f..cdddc3f9 100644
--- a/docs/user/getting_started.rst
+++ b/docs/user/getting_started.rst
@@ -27,6 +27,7 @@ Dependencies
 To build Gluon, several packages need to be installed on the system. On a
 freshly installed Debian Bullseye system the following packages are required:
 
+* `clang`
 * `git` (to get Gluon and other dependencies)
 * `python3`
 * `build-essential`
@@ -37,6 +38,7 @@ freshly installed Debian Bullseye system the following packages are required:
 * `libz-dev` (actually `zlib1g-dev`)
 * `libssl-dev`
 * `libelf-dev` (to build x86-64)
+* `llvm`
 * `wget`
 * `rsync`
 * `time` (built-in `time` doesn't work)
diff --git a/targets/generic b/targets/generic
index 7de3660a..4e59d341 100644
--- a/targets/generic
+++ b/targets/generic
@@ -37,6 +37,7 @@ config('TARGET_ROOTFS_INITRAMFS', false)
 
 config('DEVEL', true)
 config('ALL_NONSHARED', true)
+config('BPF_TOOLCHAIN_HOST', true)
 
 try_config('PACKAGE_usbip', false) -- fails to build
 try_config('PACKAGE_coova-chilli', false) -- fails to build
-- 
GitLab