llvm-bpf: support creating a tarball in bin
authorFelix Fietkau <nbd@nbd.name>
Thu, 4 Nov 2021 14:16:07 +0000 (15:16 +0100)
committerFelix Fietkau <nbd@nbd.name>
Thu, 4 Nov 2021 15:59:22 +0000 (16:59 +0100)
This can be used for adding the toolchain to an existing tree without having
to build it from scratch.
Enable building the toolchain + tarball by default on buildbot

Signed-off-by: Felix Fietkau <nbd@nbd.name>
target/sdk/Config.in
target/sdk/Makefile
toolchain/Config.in
tools/llvm-bpf/Makefile

index 0c8a61d247f9061e168655d32346a91a98cc3d6d..1984e242e721b5165490faa55596d0606bf93973 100644 (file)
@@ -7,4 +7,11 @@ config SDK
          with a precompiled toolchain. It can be used to develop and
          test packages for OpenWrt before including them in the buildroot
 
-
+config SDK_LLVM_BPF
+       bool "Build the LLVM-BPF toolchain tarball"
+       depends on BPF_TOOLCHAIN_BUILD_LLVM
+       default BUILDBOT
+       help
+         This is a tarball of the precompiled LLVM toolchain suitable
+         for unpacking into the buildroot/SDK. It is used to build packages
+         that ship with eBPF kernel modules
index 0606621192c7508fc7a470eff0173dc62ff70ded..7d7f09b514f300408b66bc693f844410f4527169 100644 (file)
@@ -34,7 +34,8 @@ EXCLUDE_DIRS:= \
        *.install.flags \
        *.install \
        */doc \
-       */share/locale
+       */share/locale \
+       */llvm-bpf*
 
 SDK_DIRS = \
                $(STAGING_SUBDIR_HOST) \
index b8b4cfeb885f7fc3051ae9fe3a888148c4b73d3b..a7da2a1f732535d3c1ac56545728ad725860d012 100644 (file)
@@ -40,6 +40,7 @@ menuconfig TARGET_OPTIONS
 
        choice BPF_TOOLCHAIN
                prompt "BPF toolchain" if DEVEL
+               default BPF_TOOLCHAIN_BUILD_LLVM if BUILDBOT
                default BPF_TOOLCHAIN_NONE
 
                config BPF_TOOLCHAIN_NONE
@@ -302,6 +303,7 @@ config USE_LLVM_HOST
        bool
 
 config USE_LLVM_BUILD
+       default y if !DEVEL && BUILDBOT
        select HAS_BPF_TOOLCHAIN
        bool
 
index ae279d26d2ae8c0b6f8250db90350c876f0168c4..a9fcc0449587fe2ce6a6e8a3b4b2e1d2011b3460 100644 (file)
@@ -24,7 +24,9 @@ CMAKE_SOURCE_SUBDIR := llvm
 include $(INCLUDE_DIR)/host-build.mk
 include $(INCLUDE_DIR)/cmake.mk
 
-CMAKE_HOST_INSTALL_PREFIX = $(STAGING_DIR_HOST)/llvm-bpf
+LLVM_BPF_PREFIX = llvm-bpf-$(PKG_VERSION).$(HOST_OS)-$(HOST_ARCH)
+
+CMAKE_HOST_INSTALL_PREFIX = $(STAGING_DIR_HOST)/$(LLVM_BPF_PREFIX)
 
 CMAKE_HOST_OPTIONS += \
        -DLLVM_ENABLE_BINDINGS=OFF \
@@ -39,4 +41,25 @@ CMAKE_HOST_OPTIONS += \
        -DLLVM_TOOLCHAIN_TOOLS="llvm-objcopy;llvm-objdump;llvm-readelf;llvm-strip;llvm-ar;llvm-as;llvm-dis;llvm-link;llvm-nm;llvm-ranlib;llc;opt" \
        -DCMAKE_SKIP_RPATH=OFF
 
+ifneq ($(CONFIG_SDK_LLVM_BPF),)
+  define Host/Install/Bin
+       echo "$(PKG_VERSION)" > $(CMAKE_HOST_INSTALL_PREFIX)/.llvm-version
+       STRIP_KMOD= PATCHELF= STRIP=strip $(SCRIPT_DIR)/rstrip.sh $(STAGING_DIR_HOST)/llvm-bpf
+       tar -C $(STAGING_DIR_HOST) \
+               -I '$(STAGING_DIR_HOST)/bin/xz -7e -T$(if $(filter 1,$(NPROC)),2,0)' \
+               -cf $(BIN_DIR)/llvm-bpf-$(PKG_VERSION).tar.xz llvm-bpf $(LLVM_BPF_PREFIX)
+  endef
+endif
+
+define Host/Install
+       rm -rf $(STAGING_DIR_HOST)/llvm-bpf*
+       $(Host/Install/Default)
+       ln -s $(LLVM_BPF_PREFIX) $(STAGING_DIR_HOST)/llvm-bpf
+       $(Host/Install/Bin)
+endef
+
+define Host/Uninstall
+       rm -rf $(STAGING_DIR_HOST)/llvm-bpf*
+endef
+
 $(eval $(call HostBuild))