From 3d76e1cb5e848fe93ef442d7141320c106999558 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sat, 8 Aug 2020 08:50:39 -0700 Subject: [PATCH 01/39] [SKIFF] .github: setup CI workflow configurations automated build + check-package + legal-info. Signed-off-by: Christian Stewart --- .github/renovate.json | 21 ++++++++ .github/workflows/buildroot-e2e.yml | 65 +++++++++++++++++++++++ .github/workflows/buildroot-e2e_defconfig | 21 ++++++++ .gitignore | 1 + 4 files changed, 108 insertions(+) create mode 100644 .github/renovate.json create mode 100644 .github/workflows/buildroot-e2e.yml create mode 100644 .github/workflows/buildroot-e2e_defconfig diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 00000000000..1fd258ab67f --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + ":semanticPrefixFixDepsChoreOthers", + ":ignoreModulesAndTests", + "group:all", + "workarounds:all" + ], + "forkProcessing": "enabled", + "branchConcurrentLimit": 0, + "ignorePaths": [ + "docs/**" + ], + "packageRules": [ + { + "matchManagers": ["gomod"], + "matchDepTypes": ["replace"], + "enabled": false + } + ] +} diff --git a/.github/workflows/buildroot-e2e.yml b/.github/workflows/buildroot-e2e.yml new file mode 100644 index 00000000000..7b6c09845ab --- /dev/null +++ b/.github/workflows/buildroot-e2e.yml @@ -0,0 +1,65 @@ +name: CI + +# Controls when the action will run. +on: + push: + branches: [master, skiff, skiff-next] + pull_request: + branches: [skiff, skiff-next, upstream-master] + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains a single job called "build" + build: + # The type of runner that the job will run on + runs-on: ubuntu-latest + + env: + # for add-env below + ACTIONS_ALLOW_UNSECURE_COMMANDS: 'true' + + # Steps represent a sequence of tasks + steps: + # Checks-out the repo under $GITHUB_WORKSPACE + - uses: actions/checkout@v5 + + - name: Cache build cache and downloads + uses: actions/cache@v4 + env: + cache-name: cache-buildroot + with: + path: ~/br-cache/ + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Makefile') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + # Detect changes vs upstream-master + - name: Detect changes vs upstream + run: | + cd $GITHUB_WORKSPACE + git fetch + git remote add upstream https://github.com/buildroot/buildroot.git + git fetch upstream + export BUILDROOT_UPSTREAM=$(cat .github/buildroot-upstream) + echo "::set-env name=CHANGED_VS_UPSTREAM::$(git diff --diff-filter=ACM --name-only $BUILDROOT_UPSTREAM | xargs)" + + # Installing buildroot deps + - name: Install buildroot apt deps + run: | + sudo apt-get install -y libelf-dev python3-magic python3-flake8 + + # Run check-package on changed files + - name: Run check-package on all changed files and setup env + run: | + cd $GITHUB_WORKSPACE + ./utils/check-package $CHANGED_VS_UPSTREAM + + # Test a build + - name: Run a generic build + run: | + cd $GITHUB_WORKSPACE + make defconfig BR2_DEFCONFIG=$(pwd)/.github/workflows/buildroot-e2e_defconfig + make -s all legal-info BR2_CCACHE_DIR=${HOME}/br-cache/ccache BR2_DL_DIR=${HOME}/br-cache/dl + diff --git a/.github/workflows/buildroot-e2e_defconfig b/.github/workflows/buildroot-e2e_defconfig new file mode 100644 index 00000000000..e4dcd411e64 --- /dev/null +++ b/.github/workflows/buildroot-e2e_defconfig @@ -0,0 +1,21 @@ +BR2_x86_64=y +BR2_x86_core_avx2=y +BR2_CCACHE=y +BR2_TOOLCHAIN_BUILDROOT_GLIBC=y +BR2_TOOLCHAIN_BUILDROOT_CXX=y +BR2_GCC_ENABLE_LTO=n +BR2_INIT_SYSTEMD=y +# BR2_TARGET_ENABLE_ROOT_LOGIN is not set +BR2_SYSTEM_BIN_SH_BASH=y +BR2_ENABLE_LOCALE_WHITELIST="C en_US en_US.UTF-8" +BR2_GENERATE_LOCALE="en_US.UTF-8" +BR2_LINUX_KERNEL=y +BR2_LINUX_KERNEL_DEFCONFIG="x86_64" +BR2_LINUX_KERNEL_NEEDS_HOST_OPENSSL=y +BR2_PACKAGE_CA_CERTIFICATES=y +BR2_PACKAGE_DELVE=y +BR2_PACKAGE_DOCKER_CLI=y +BR2_PACKAGE_DOCKER_CLI_STATIC=y +BR2_PACKAGE_DOCKER_ENGINE_EXPERIMENTAL=y +BR2_PACKAGE_MENDER=y +BR2_PACKAGE_HOST_MENDER_ARTIFACT=y diff --git a/.gitignore b/.gitignore index fb20b03daf7..810b270a627 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ *~ *.pyc /br.log +*.swp From a99d567882be2d85db90fd67333f4da7ca07e5ff Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Thu, 20 Aug 2020 16:12:01 -0700 Subject: [PATCH 02/39] [SKIFF] .github: add per-branch upstream file Signed-off-by: Christian Stewart --- .github/buildroot-upstream | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/buildroot-upstream diff --git a/.github/buildroot-upstream b/.github/buildroot-upstream new file mode 100644 index 00000000000..9c9ac904630 --- /dev/null +++ b/.github/buildroot-upstream @@ -0,0 +1 @@ +upstream/master From 8cbf37dbc1f1a9823f7fa1f0e5806f161716417f Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 30 Jan 2023 15:24:21 -0800 Subject: [PATCH 03/39] [SKIFF] download: add additional skiffos mirror site Signed-off-by: Christian Stewart --- Config.in | 10 ++++++++++ package/pkg-download.mk | 4 ++++ 2 files changed, 14 insertions(+) diff --git a/Config.in b/Config.in index ac58c685d18..37180523c14 100644 --- a/Config.in +++ b/Config.in @@ -296,6 +296,16 @@ config BR2_BACKUP_SITE buildroot will fall back to download package sources from here if the normal location fails. +config BR2_SKIFFOS_BACKUP_SITE + string "SkiffOS backup download site" + default "https://github.com/skiffos/mirror/raw/master" + help + Backup site to download from. If this option is set then + buildroot will fall back to download package sources from here + if the normal location fails. + + This is an additional mirror used by SkiffOS. + config BR2_KERNEL_MIRROR string "Kernel.org mirror" default "https://cdn.kernel.org/pub" diff --git a/package/pkg-download.mk b/package/pkg-download.mk index b38f0c7053d..d573afe4ec8 100644 --- a/package/pkg-download.mk +++ b/package/pkg-download.mk @@ -84,6 +84,10 @@ DOWNLOAD_URIS += \ $(call getschemeplusuri,$(call qstrip,$(BR2_BACKUP_SITE)/$($(2)_DL_SUBDIR)),urlencode) \ $(call getschemeplusuri,$(call qstrip,$(BR2_BACKUP_SITE)),urlencode) endif +ifneq ($(call qstrip,$(BR2_SKIFFOS_BACKUP_SITE)),) +DOWNLOAD_URIS += \ + $(call getschemeplusuri,$(call qstrip,$(BR2_SKIFFOS_BACKUP_SITE)/$($(2)_DL_SUBDIR)),urlencode) +endif endif ################################################################################ From cd60ca421b612b5c10645791d5bdc8b533635da9 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 2 Oct 2023 12:20:33 -0700 Subject: [PATCH 04/39] [SKIFF] package/amlogic-boot-fip: copy device directory to images Signed-off-by: Christian Stewart --- package/amlogic-boot-fip/Config.in.host | 7 +++++-- package/amlogic-boot-fip/amlogic-boot-fip.mk | 11 ++--------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/package/amlogic-boot-fip/Config.in.host b/package/amlogic-boot-fip/Config.in.host index bccc6296d11..684c0713880 100644 --- a/package/amlogic-boot-fip/Config.in.host +++ b/package/amlogic-boot-fip/Config.in.host @@ -1,11 +1,12 @@ config BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP bool "host amlogic-boot-fip" - depends on BR2_HOSTARCH = "x86_64" help Firmware Image Package (FIP) sources used to sign Amlogic u-boot binaries in LibreELEC images - https://github.com/LibreELEC/amlogic-boot-fip + https://gitlab.com/LibreELEC/amlogic-boot-fip + +if BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP config BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE string "fip device" @@ -15,3 +16,5 @@ config BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE Device for which you want to use this package. See the list of supported SoCs: https://github.com/LibreELEC/amlogic-boot-fip + +endif # BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP diff --git a/package/amlogic-boot-fip/amlogic-boot-fip.mk b/package/amlogic-boot-fip/amlogic-boot-fip.mk index 552e785066d..1c67a301793 100644 --- a/package/amlogic-boot-fip/amlogic-boot-fip.mk +++ b/package/amlogic-boot-fip/amlogic-boot-fip.mk @@ -11,22 +11,15 @@ AMLOGIC_BOOT_FIP_LICENSE_FILES = LICENSE AMLOGIC_BOOT_FIP_REDISTRIBUTE = NO AMLOGIC_BOOT_FIP_INSTALL_DIR = $(BINARIES_DIR)/amlogic-boot-fip - AMLOGIC_BOOT_FIP_DEVICE = $(call qstrip,$(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE)) -AMLOGIC_BOOT_FIP_FILES_TO_INSTALL = build-fip.sh axg.inc g12a.inc gxbb.inc gxl.inc - define HOST_AMLOGIC_BOOT_FIP_INSTALL_CMDS - mkdir -p $(AMLOGIC_BOOT_FIP_INSTALL_DIR)/$(AMLOGIC_BOOT_FIP_DEVICE) - $(foreach f,$(AMLOGIC_BOOT_FIP_FILES_TO_INSTALL),\ - $(INSTALL) -D -m 0755 $(@D)/$(f) $(AMLOGIC_BOOT_FIP_INSTALL_DIR)/$(f) - ) - cp -rf $(@D)/$(AMLOGIC_BOOT_FIP_DEVICE) $(AMLOGIC_BOOT_FIP_INSTALL_DIR) + cp -dpfr $(@D)/$(AMLOGIC_BOOT_FIP_DEVICE)/. $(AMLOGIC_BOOT_FIP_INSTALL_DIR)/ endef # check for empty device string when we're building ifeq ($(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP)$(BR_BUILDING),yy) -ifeq ($(call qstrip,$(BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE)),) +ifeq ($(AMLOGIC_BOOT_FIP_DEVICE),) $(error No device specified for amlogic-boot-fip, please check your BR2_PACKAGE_HOST_AMLOGIC_BOOT_FIP_DEVICE setting) endif endif From eed3e6ec05c209d05cf0a75045c7ad56bda2622e Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 2 Jul 2023 19:56:44 -0700 Subject: [PATCH 05/39] [SKIFF] package/openvpn: add option to disable DCO features Add option to avoid build failures on older kernels. Signed-off-by: Christian Stewart --- package/openvpn/Config.in | 6 ++++++ package/openvpn/openvpn.mk | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/package/openvpn/Config.in b/package/openvpn/Config.in index e2735dae033..5178ee804fd 100644 --- a/package/openvpn/Config.in +++ b/package/openvpn/Config.in @@ -38,4 +38,10 @@ config BR2_PACKAGE_OPENVPN_SMALL You loose eurephia, debugging info, help messages and more. It saves around 100 KiB in binary file size. +config BR2_PACKAGE_OPENVPN_DCO + bool "Enable DCO" + default y + help + Enable DCO feature in OpenVPN + endif diff --git a/package/openvpn/openvpn.mk b/package/openvpn/openvpn.mk index d5fd308e63e..9b7788b0001 100644 --- a/package/openvpn/openvpn.mk +++ b/package/openvpn/openvpn.mk @@ -19,7 +19,7 @@ OPENVPN_CONF_ENV = NETSTAT=/bin/netstat # workaround for static_assert on uclibc-ng < 1.0.42 OPENVPN_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -Dstatic_assert=_Static_assert" -ifeq ($(BR2_PACKAGE_LIBNL)$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_16),yy) +ifeq ($(BR2_PACKAGE_LIBNL)$(BR2_TOOLCHAIN_HEADERS_AT_LEAST_4_16)$(BR2_PACKAGE_OPENVPN_DCO),yyy) OPENVPN_CONF_OPTS += --enable-dco OPENVPN_DEPENDENCIES += libnl else From 85a457cb4b1b51a0683ba49d6bd15af10f5861ec Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sat, 14 May 2022 21:09:36 -0700 Subject: [PATCH 06/39] [WIP] package/mkbootimg: new host package Android bootimg utilities: mkbootimg and unpackbootimg. Signed-off-by: Christian Stewart --- v1: CHANGES REQUESTED (Pending) https://patchwork.ozlabs.org/project/buildroot/patch/20220724235818.679881-1-christian@paral.in/ --- package/Config.in.host | 1 + ...akefile-remove-cc-and-ar-definitions.patch | 98 +++++++++++++++++++ package/mkbootimg/Config.in.host | 4 + package/mkbootimg/mkbootimg.hash | 3 + package/mkbootimg/mkbootimg.mk | 26 +++++ 5 files changed, 132 insertions(+) create mode 100644 package/mkbootimg/0001-makefile-remove-cc-and-ar-definitions.patch create mode 100644 package/mkbootimg/Config.in.host create mode 100644 package/mkbootimg/mkbootimg.hash create mode 100644 package/mkbootimg/mkbootimg.mk diff --git a/package/Config.in.host b/package/Config.in.host index df57cc0c17d..f4b00a1e285 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -70,6 +70,7 @@ menu "Host utilities" source "package/mfgtools/Config.in.host" source "package/microchip-hss-payload-generator/Config.in.host" source "package/minisign/Config.in.host" + source "package/mkbootimg/Config.in.host" source "package/mkpasswd/Config.in.host" source "package/moby-buildkit/Config.in.host" source "package/mosquitto/Config.in.host" diff --git a/package/mkbootimg/0001-makefile-remove-cc-and-ar-definitions.patch b/package/mkbootimg/0001-makefile-remove-cc-and-ar-definitions.patch new file mode 100644 index 00000000000..231f211d7f5 --- /dev/null +++ b/package/mkbootimg/0001-makefile-remove-cc-and-ar-definitions.patch @@ -0,0 +1,98 @@ +From 04a62922ce238f3106a916a30c0c2995ffa1526c Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Sat, 14 May 2022 20:58:14 -0700 +Subject: [PATCH] makefile: remove cc and ar definitions +Upstream: N/A + +Signed-off-by: Christian Stewart +--- + Makefile | 26 +------------------------- + libmincrypt/Makefile | 27 +++++---------------------- + 2 files changed, 6 insertions(+), 47 deletions(-) + +diff --git a/Makefile b/Makefile +index 6ee3a38c..39d0996b 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,29 +1,4 @@ + # Andrew Huang +-ifeq ($(CC),cc) +-CC = gcc +-endif +-AR = ar rcv +-ifeq ($(windir),) +-EXE = +-RM = rm -f +-else +-EXE = .exe +-RM = del +-endif +- +-CFLAGS = -ffunction-sections -O3 +- +-ifneq (,$(findstring darwin,$(CROSS_COMPILE))) +- UNAME_S := Darwin +-else +- UNAME_S := $(shell uname -s) +-endif +-ifeq ($(UNAME_S),Darwin) +- LDFLAGS += -Wl,-dead_strip +-else +- LDFLAGS += -Wl,--gc-sections -s +-endif +- + all:mkbootimg$(EXE) unpackbootimg$(EXE) + + static: +@@ -31,6 +6,7 @@ static: + + libmincrypt.a: + $(MAKE) -C libmincrypt ++ cp ./libmincrypt/libmincrypt.a ./libmincrypt.a + + mkbootimg$(EXE):mkbootimg.o libmincrypt.a + $(CROSS_COMPILE)$(CC) -o $@ $^ -L. -lmincrypt $(LDFLAGS) +diff --git a/libmincrypt/Makefile b/libmincrypt/Makefile +index ad482de9..c7c478ff 100755 +--- a/libmincrypt/Makefile ++++ b/libmincrypt/Makefile +@@ -1,31 +1,14 @@ +-ifeq ($(CC),cc) +-CC = gcc +-endif +-AR = ar rc +-ifeq ($(windir),) +-RM = rm -f +-CP = cp +-else +-RM = del +-CP = copy /y +-endif +- +-CFLAGS = -ffunction-sections -O3 +-EXT = a +-LIB = libmincrypt.$(EXT) ++LIB = libmincrypt.a + LIB_OBJS = dsa_sig.o p256.o p256_ec.o p256_ecdsa.o rsa.o sha.o sha256.o + INC = -I.. + +-all:$(LIB) ++all: $(LIB) + + clean: + $(RM) $(LIB_OBJS) $(LIB) + +-$(LIB):$(LIB_OBJS) +- $(CROSS_COMPILE)$(AR) $@ $^ +- $(CP) $@ .. +- ++$(LIB): $(LIB_OBJS) ++ $(CROSS_COMPILE)$(AR) rc $@ $^ + +-%.o:%.c ++%.o: %.c + $(CROSS_COMPILE)$(CC) -o $@ $(CFLAGS) -c $< $(INC) +- +-- +2.35.1 + diff --git a/package/mkbootimg/Config.in.host b/package/mkbootimg/Config.in.host new file mode 100644 index 00000000000..2ca7bcae001 --- /dev/null +++ b/package/mkbootimg/Config.in.host @@ -0,0 +1,4 @@ +config BR2_PACKAGE_HOST_MKBOOTIMG + bool "host mkbootimg" + help + Android Bootimg mkbootimg and unpackbootimg utils. diff --git a/package/mkbootimg/mkbootimg.hash b/package/mkbootimg/mkbootimg.hash new file mode 100644 index 00000000000..8beaf8d56cd --- /dev/null +++ b/package/mkbootimg/mkbootimg.hash @@ -0,0 +1,3 @@ +# locally computed +sha256 28ddd4a2e472e4e044c9b461fb8e3ce04ea9af0bbbafc8010958df28d27707a7 mkbootimg-d4a2677828fe9b60117af8996dcf1dea85d6b431.tar.gz +sha256 b220fd3c79e0906eda798b23699305ab05576e849f45810eca74afcb2c7f2311 NOTICE diff --git a/package/mkbootimg/mkbootimg.mk b/package/mkbootimg/mkbootimg.mk new file mode 100644 index 00000000000..460e50aa9e4 --- /dev/null +++ b/package/mkbootimg/mkbootimg.mk @@ -0,0 +1,26 @@ +################################################################################ +# +# mkbootimg +# +################################################################################ + +MKBOOTIMG_VERSION = d4a2677828fe9b60117af8996dcf1dea85d6b431 +MKBOOTIMG_SITE = $(call github,osm0sis,mkbootimg,$(MKBOOTIMG_VERSION)) + +MKBOOTIMG_LICENSE = BSD-3-Clause +MKBOOTIMG_LICENSE_FILES = NOTICE + +HOST_MKBOOTIMG_TARGETS = mkbootimg unpackbootimg + +define HOST_MKBOOTIMG_BUILD_CMDS + $(foreach t,$(HOST_MKBOOTIMG_TARGETS),\ + $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) $(MAKE) SRCDIR=$(@D) \ + -C $(@D) $(t)) +endef + +define HOST_MKBOOTIMG_INSTALL_CMDS + $(foreach t,$(HOST_MKBOOTIMG_TARGETS),\ + $(INSTALL) -D -m 0755 $(@D)/$(t) $(HOST_DIR)/bin/$(notdir $(t))$(sep)) +endef + +$(eval $(host-generic-package)) From 11be190fad3ec1132414e02240476941ce7b758e Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Fri, 10 Mar 2023 02:39:57 -0800 Subject: [PATCH 07/39] linux: run make prepare before make all Some Linux kernels do not correctly generate the include/generated path when running "make all" without first running "make prepare" Since running "make prepare" is always valid on any Linux kernel, take the extra step to explicitly run "make prepare" before "make all." Signed-off-by: Christian Stewart --- linux/linux.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/linux.mk b/linux/linux.mk index e790daff660..6589e922890 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -543,6 +543,7 @@ define LINUX_BUILD_CMDS cp -f $(dts) $(LINUX_ARCH_PATH)/boot/dts/ ) $(LINUX_COPY_CUSTOM_DTS_FILES) + $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) prepare $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) all $(LINUX_MAKE_ENV) $(BR2_MAKE) $(LINUX_MAKE_FLAGS) -C $(@D) $(LINUX_TARGET_NAME) $(LINUX_BUILD_DTB) From dbe16a0baac43fcaff807c4d990d5a63eb2637b1 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 16 May 2023 19:12:54 -0700 Subject: [PATCH 08/39] linux: add support for building device tree overlays Some kernels have device tree overlay files: make arch/arm64/boot/dts/amlogic/overlays/odroidn2/i2c0.dtbo Add an option to add these dtbo files to the LINUX_DTBS list. BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAME="amlogic/overlays/odroidn2/i2c0" Signed-off-by: Christian Stewart --- linux/Config.in | 19 +++++++++++++++++++ linux/linux.mk | 5 +++++ 2 files changed, 24 insertions(+) diff --git a/linux/Config.in b/linux/Config.in index a82aeb76b29..97112712847 100644 --- a/linux/Config.in +++ b/linux/Config.in @@ -509,6 +509,25 @@ config BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT Choose this option to support Device Tree overlays on the target system. +if BR2_LINUX_KERNEL_DTB_OVERLAY_SUPPORT + +config BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAME + string "In-tree Device Tree Overlay Source file names" + help + Name of in-tree device tree source file, without + the trailing .dts. You can provide a list of + dts overlay files to build, separated by spaces. + +config BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH + string "Out-of-tree Device Tree Overlay Source file paths" + help + Paths to out-of-tree Device Tree Source (.dts) and Device Tree + Source Include (.dtsi) files, separated by spaces. These files + will be copied to the kernel sources and the .dts files will + be compiled from there to dtb overlays (.dtbo). + +endif + endif config BR2_LINUX_KERNEL_INSTALL_TARGET diff --git a/linux/linux.mk b/linux/linux.mk index 6589e922890..3250334b248 100644 --- a/linux/linux.mk +++ b/linux/linux.mk @@ -227,6 +227,11 @@ endif LINUX_DTBS = $(addsuffix .dtb,$(LINUX_DTS_NAME)) $(addsuffix .dtbo,$(LINUX_DTSO_NAMES)) +LINUX_DTS_OVERLAY_NAME += $(call qstrip,$(BR2_LINUX_KERNEL_INTREE_DTS_OVERLAY_NAME)) +LINUX_DTS_OVERLAY_NAME += $(basename $(filter %.dts,$(notdir $(call qstrip,$(BR2_LINUX_KERNEL_CUSTOM_DTS_OVERLAY_PATH))))) + +LINUX_DTBS += $(addsuffix .dtbo,$(LINUX_DTS_OVERLAY_NAME)) + ifeq ($(BR2_LINUX_KERNEL_IMAGE_TARGET_CUSTOM),y) LINUX_IMAGE_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_NAME)) LINUX_TARGET_NAME = $(call qstrip,$(BR2_LINUX_KERNEL_IMAGE_TARGET_NAME)) From 85f1cd68379171cfe660639fb7320b0e7a83c9e7 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Fri, 5 Jun 2020 20:22:20 -0700 Subject: [PATCH 09/39] package/linux-firmware: add support for nvidia files Signed-off-by: Christian Stewart --- package/linux-firmware/Config.in | 5 +++++ package/linux-firmware/linux-firmware.mk | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/package/linux-firmware/Config.in b/package/linux-firmware/Config.in index 7533b3d8999..52ba01d5d44 100644 --- a/package/linux-firmware/Config.in +++ b/package/linux-firmware/Config.in @@ -54,6 +54,11 @@ config BR2_PACKAGE_LINUX_FIRMWARE_XE help Firmware files for the Intel Xe video cards. +config BR2_PACKAGE_LINUX_FIRMWARE_NVIDIA + bool "Nvidia video card firmware" + help + Firmware files for the Nvidia video cards. + config BR2_PACKAGE_LINUX_FIRMWARE_RADEON bool "AMD Radeon video card firmware" help diff --git a/package/linux-firmware/linux-firmware.mk b/package/linux-firmware/linux-firmware.mk index 3761c5c09b4..3c7e5a583af 100644 --- a/package/linux-firmware/linux-firmware.mk +++ b/package/linux-firmware/linux-firmware.mk @@ -40,6 +40,11 @@ LINUX_FIRMWARE_DIRS += xe LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENSE.xe endif +ifeq ($(BR2_PACKAGE_LINUX_FIRMWARE_NVIDIA),y) +LINUX_FIRMWARE_DIRS += nvidia +LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENCE.nvidia +endif + ifeq ($(BR2_PACKAGE_LINUX_FIRMWARE_RADEON),y) LINUX_FIRMWARE_DIRS += radeon LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENSE.radeon From 62c7ea5aaf27b223da0004f58494744c2ba74324 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sat, 14 Nov 2020 01:48:28 -0800 Subject: [PATCH 10/39] package/linux-firmware: add option for rockchip dptx Signed-off-by: Christian Stewart --- package/linux-firmware/Config.in | 5 +++++ package/linux-firmware/linux-firmware.mk | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/package/linux-firmware/Config.in b/package/linux-firmware/Config.in index 52ba01d5d44..93182d21ce5 100644 --- a/package/linux-firmware/Config.in +++ b/package/linux-firmware/Config.in @@ -79,6 +79,11 @@ config BR2_PACKAGE_LINUX_FIRMWARE_MFC_V8 help Firmware files for Samsung MFC video encoder/decoder driver v8 +config BR2_PACKAGE_LINUX_FIRMWARE_ROCKCHIP_DPTX + bool "Rockchip dptx" + help + Firmware files for RockChip dptx (DisplayPort). + endmenu # Video menu "Bluetooth firmware" diff --git a/package/linux-firmware/linux-firmware.mk b/package/linux-firmware/linux-firmware.mk index 3c7e5a583af..43291f507d8 100644 --- a/package/linux-firmware/linux-firmware.mk +++ b/package/linux-firmware/linux-firmware.mk @@ -786,6 +786,11 @@ LINUX_FIRMWARE_FILES += \ LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENCE.rtlwifi_firmware.txt endif +ifeq ($(BR2_PACKAGE_LINUX_FIRMWARE_ROCKCHIP_DPTX),y) +LINUX_FIRMWARE_FILES += rockchip/dptx.bin +LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENCE.rockchip +endif + ifeq ($(BR2_PACKAGE_LINUX_FIRMWARE_RTL_8169),y) LINUX_FIRMWARE_FILES += \ rtl_nic/rtl8105e-1.fw \ From 361d6b7c97ef760e2c8e1f6e732863e24ce31c3b Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 10 May 2022 05:53:25 -0700 Subject: [PATCH 11/39] package/linux-firmware: add support for ti vpdma Add a symlink to the expected location for vpdma-1ba in the root of the firmware directory. Signed-off-by: Christian Stewart --- ...i-tspa-add-link-to-vpdma-1ba-in-root.patch | 25 +++++++++++++++++++ package/linux-firmware/Config.in | 5 ++++ package/linux-firmware/linux-firmware.hash | 2 ++ package/linux-firmware/linux-firmware.mk | 5 ++++ 4 files changed, 37 insertions(+) create mode 100644 package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch diff --git a/package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch b/package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch new file mode 100644 index 00000000000..789c074ee1e --- /dev/null +++ b/package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch @@ -0,0 +1,25 @@ +From 25e53eaf9e766713bed499cfff6f43855cd35e61 Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Tue, 10 May 2022 06:21:46 -0700 +Subject: [PATCH] ti-tspa: add link to vpdma-1ba in root + +Signed-off-by: Christian Stewart +--- + WHENCE | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/WHENCE b/WHENCE +index eab2f22..6f08e79 100644 +--- a/WHENCE ++++ b/WHENCE +@@ -3034,6 +3034,7 @@ Licence: Redistributable. See LICENCE.tda7706-firmware.txt for details. + Driver: ti-vpe - Texas Instruments V4L2 driver for Video Processing Engine + + File: ti/vpdma-1b8.bin ++Link: vpdma-1b8.bin -> ti/vpdma-1b8.bin + + Licence: Redistributable. See LICENCE.ti-tspa for details. + +-- +2.35.1 + diff --git a/package/linux-firmware/Config.in b/package/linux-firmware/Config.in index 93182d21ce5..1ef2e6a2c54 100644 --- a/package/linux-firmware/Config.in +++ b/package/linux-firmware/Config.in @@ -84,6 +84,11 @@ config BR2_PACKAGE_LINUX_FIRMWARE_ROCKCHIP_DPTX help Firmware files for RockChip dptx (DisplayPort). +config BR2_PACKAGE_LINUX_FIRMWARE_TI_VPDMA + bool "TI VPDMA" + help + Firmware files for TI Video Port Direct Memory Engine. + endmenu # Video menu "Bluetooth firmware" diff --git a/package/linux-firmware/linux-firmware.hash b/package/linux-firmware/linux-firmware.hash index e707583e7ef..c19982c3b69 100644 --- a/package/linux-firmware/linux-firmware.hash +++ b/package/linux-firmware/linux-firmware.hash @@ -50,6 +50,8 @@ sha256 8542aeabf2761935122d693561e16766ce1bcc2b0d003204f9040b7d6d929f2e LICENS sha256 be904cd28cb292b80cdb6cf412ab0d9159d431671e987ad433c1f62e0988a9bc LICENSE.qcom sha256 fc6223d4bfe9f2f9e2eddc44b9fe5721d0caf49f01cb08d602906add686d8c6f LICENSE.radeon sha256 2bdd2e716f05d9737d3f9a20f9a3a3c0caee0e866100ddb0673f1178e42f92b9 LICENSE.sdma_firmware +sha256 5bc52a8ad08b531ee17fb3c35b8f83c8649c9aecfb6ce7a7975ee62d840f4c9b LICENCE.ti-tspa +sha256 bc5225a57f49c5249dcf238e4ae6437811677a2a8a7f579c3d839e058653ee44 LICENCE.nvidia sha256 93a059ebbd333245a587778663c17d3df09421da30ae6b3e2d18ac2741f506c0 WHENCE sha256 fa43e1b9a13b341a07adca9dbe73d0f9072d7966fdfe811c01f0dd2872d7309a qcom/NOTICE.txt sha256 bef9c828e84f21e7835b4de7daf954a327e1ff777871b58e116039b684c0d604 LICENCE.e100 diff --git a/package/linux-firmware/linux-firmware.mk b/package/linux-firmware/linux-firmware.mk index 43291f507d8..86bbd048593 100644 --- a/package/linux-firmware/linux-firmware.mk +++ b/package/linux-firmware/linux-firmware.mk @@ -791,6 +791,11 @@ LINUX_FIRMWARE_FILES += rockchip/dptx.bin LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENCE.rockchip endif +ifeq ($(BR2_PACKAGE_LINUX_FIRMWARE_TI_VPDMA),y) +LINUX_FIRMWARE_FILES += ti/vpdma-1b8.bin +LINUX_FIRMWARE_ALL_LICENSE_FILES += LICENCE.ti-tspa +endif + ifeq ($(BR2_PACKAGE_LINUX_FIRMWARE_RTL_8169),y) LINUX_FIRMWARE_FILES += \ rtl_nic/rtl8105e-1.fw \ From 89458aecd29d6f6efc7126f4b980797264c9c754 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 3 Nov 2025 17:17:19 -0800 Subject: [PATCH 12/39] package/linux-firmware: add missing Upstream header to patch Add required Upstream field to patch header to comply with buildroot patch documentation requirements. --- .../0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch | 1 + 1 file changed, 1 insertion(+) diff --git a/package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch b/package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch index 789c074ee1e..d7744114d5a 100644 --- a/package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch +++ b/package/linux-firmware/0001-ti-tspa-add-link-to-vpdma-1ba-in-root.patch @@ -2,6 +2,7 @@ From 25e53eaf9e766713bed499cfff6f43855cd35e61 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 10 May 2022 06:21:46 -0700 Subject: [PATCH] ti-tspa: add link to vpdma-1ba in root +Upstream: N/A Signed-off-by: Christian Stewart --- From 582d7775d1c8f0a04120b383b5b57da50916b3bf Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 23 Aug 2020 00:00:30 -0700 Subject: [PATCH 13/39] package/nvidia-driver: bump to version 510.73.05 This series is currently marked "stable" on the gentoo repo. Signed-off-by: Christian Stewart --- ...-mismatch-unconditonally-to-conftest.patch | 26 +++++++++++++++++++ package/nvidia-driver/nvidia-driver.hash | 3 +++ package/nvidia-driver/nvidia-driver.mk | 9 ++++++- 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 package/nvidia-driver/0001-Add-ignore-CC-mismatch-unconditonally-to-conftest.patch diff --git a/package/nvidia-driver/0001-Add-ignore-CC-mismatch-unconditonally-to-conftest.patch b/package/nvidia-driver/0001-Add-ignore-CC-mismatch-unconditonally-to-conftest.patch new file mode 100644 index 00000000000..65e8cb344e5 --- /dev/null +++ b/package/nvidia-driver/0001-Add-ignore-CC-mismatch-unconditonally-to-conftest.patch @@ -0,0 +1,26 @@ +From c4233ad92256006f7db42efe7cdaf08079d74977 Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Sat, 22 Aug 2020 23:58:51 -0700 +Subject: [PATCH] Add ignore CC mismatch unconditionally to conftest +Upstream: N/A + +Signed-off-by: Christian Stewart +--- + kernel/conftest.sh | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/kernel/conftest.sh b/kernel/conftest.sh +index a4ebf81..4ad452e 100755 +--- a/kernel/conftest.sh ++++ b/kernel/conftest.sh +@@ -3882,6 +3882,7 @@ case "$5" in + IGNORE_CC_MISMATCH=1 + fi + ++ IGNORE_CC_MISMATCH=1 + if [ -n "$IGNORE_CC_MISMATCH" ]; then + exit 0 + fi +-- +2.28.0 + diff --git a/package/nvidia-driver/nvidia-driver.hash b/package/nvidia-driver/nvidia-driver.hash index 620112e6c81..47086e19eeb 100644 --- a/package/nvidia-driver/nvidia-driver.hash +++ b/package/nvidia-driver/nvidia-driver.hash @@ -1,4 +1,7 @@ # Locally computed sha256 94e399b459659c12b1344e8c8f4f5eee1ed5915ff459fc8bb831c9e1d44677db NVIDIA-Linux-x86-390.151.run sha256 6e4fd2258465f5d5527fe80abd46de925a30348b4a84658498a6d75caf42c47c NVIDIA-Linux-x86_64-390.151-no-compat32.run +sha256 8087fa71bc73d2941dd55e1affc89b078c7bfc87461d996ac2edf269ae0857b2 NVIDIA-Linux-x86_64-510.73.05.run +sha256 595465d138a63071170ea1de20ebe9bdef59c9a97d7c4325c0a04abb4bc15719 NVIDIA-Linux-x86_64-510.73.05-no-compat32.run +sha256 6ac030d692d45c065ad88d30fb7358834df9ceb4f37caaad459a4d7c64877ea7 NVIDIA-Linux-x86_64-470.129.06-no-compat32.run sha256 bd28b0c5aeeb00eb11d3ec6f6f3449d4b3a40100914258332734a53527997526 LICENSE diff --git a/package/nvidia-driver/nvidia-driver.mk b/package/nvidia-driver/nvidia-driver.mk index f1217b00aa7..ef5b8ee5a8b 100644 --- a/package/nvidia-driver/nvidia-driver.mk +++ b/package/nvidia-driver/nvidia-driver.mk @@ -4,8 +4,15 @@ # ################################################################################ +# current stable (per gentoo) +NVIDIA_DRIVER_VERSION = 510.73.05 + +ifeq ($(BR2_x86_64),y) +NVIDIA_DRIVER_SUFFIX = _64 +else NVIDIA_DRIVER_VERSION = 390.151 -NVIDIA_DRIVER_SUFFIX = $(if $(BR2_x86_64),_64) +endif # BR2_x86_64 + NVIDIA_DRIVER_SITE = http://download.nvidia.com/XFree86/Linux-x86$(NVIDIA_DRIVER_SUFFIX)/$(NVIDIA_DRIVER_VERSION) NVIDIA_DRIVER_SOURCE = NVIDIA-Linux-x86$(NVIDIA_DRIVER_SUFFIX)-$(NVIDIA_DRIVER_VERSION)$(if $(BR2_x86_64),-no-compat32).run NVIDIA_DRIVER_LICENSE = NVIDIA Software License From b7d225d51a3bd6eed066a1b128335787d73b8261 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 16 Aug 2022 16:27:16 -0700 Subject: [PATCH 14/39] package/nvidia-driver: add latest version 525.125.06 Signed-off-by: Christian Stewart --- package/nvidia-driver/Config.in | 3 +++ package/nvidia-driver/nvidia-driver.hash | 4 ++++ package/nvidia-driver/nvidia-driver.mk | 5 ++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/package/nvidia-driver/Config.in b/package/nvidia-driver/Config.in index e4a9dde0a0e..3d714a1e523 100644 --- a/package/nvidia-driver/Config.in +++ b/package/nvidia-driver/Config.in @@ -14,6 +14,9 @@ config BR2_PACKAGE_NVIDIA_DRIVER if BR2_PACKAGE_NVIDIA_DRIVER +config BR2_PACKAGE_NVIDIA_DRIVER_LATEST + bool "use latest production branch version" + comment "nvidia-driver X.org drivers needs a modular Xorg server" depends on !BR2_PACKAGE_XSERVER_XORG_SERVER_MODULAR diff --git a/package/nvidia-driver/nvidia-driver.hash b/package/nvidia-driver/nvidia-driver.hash index 47086e19eeb..b0dbe43de5a 100644 --- a/package/nvidia-driver/nvidia-driver.hash +++ b/package/nvidia-driver/nvidia-driver.hash @@ -4,4 +4,8 @@ sha256 6e4fd2258465f5d5527fe80abd46de925a30348b4a84658498a6d75caf42c47c NVIDIA sha256 8087fa71bc73d2941dd55e1affc89b078c7bfc87461d996ac2edf269ae0857b2 NVIDIA-Linux-x86_64-510.73.05.run sha256 595465d138a63071170ea1de20ebe9bdef59c9a97d7c4325c0a04abb4bc15719 NVIDIA-Linux-x86_64-510.73.05-no-compat32.run sha256 6ac030d692d45c065ad88d30fb7358834df9ceb4f37caaad459a4d7c64877ea7 NVIDIA-Linux-x86_64-470.129.06-no-compat32.run +sha256 141777e1ca2f11e97d8d33260213f1be327eb73922ae22f4ddab404bb2ef4664 NVIDIA-Linux-x86_64-515.86.01.run +sha256 a16f2cba9c56d47a6c1fca14a80968b8fc4ce20f59330d265aad0fef56f19fb6 NVIDIA-Linux-x86_64-515.86.01-no-compat32.run +sha256 4605db4d77ebfc2ad282709c748fbd973f8f2599d3188f307b9327b168d507e5 NVIDIA-Linux-x86_64-525.125.06-no-compat32.run +sha256 b5275689f4a833c37a507717ac8f0ee2f1f5cd2b7e236ffa70aad8dfb7455b9d NVIDIA-Linux-x86_64-525.125.06.run sha256 bd28b0c5aeeb00eb11d3ec6f6f3449d4b3a40100914258332734a53527997526 LICENSE diff --git a/package/nvidia-driver/nvidia-driver.mk b/package/nvidia-driver/nvidia-driver.mk index ef5b8ee5a8b..016ac4b7568 100644 --- a/package/nvidia-driver/nvidia-driver.mk +++ b/package/nvidia-driver/nvidia-driver.mk @@ -4,9 +4,12 @@ # ################################################################################ -# current stable (per gentoo) NVIDIA_DRIVER_VERSION = 510.73.05 +ifeq ($(BR2_PACKAGE_NVIDIA_DRIVER_LATEST),y) +NVIDIA_DRIVER_VERSION = 525.125.06 +endif + ifeq ($(BR2_x86_64),y) NVIDIA_DRIVER_SUFFIX = _64 else From 82e97fffe477b6e1fe2e742de85493fa81ee87e4 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Fri, 30 Apr 2021 18:50:35 -0700 Subject: [PATCH 15/39] host-localedef: disable Werror to avoid build failures Signed-off-by: Christian Stewart --- package/localedef/localedef.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/package/localedef/localedef.mk b/package/localedef/localedef.mk index 732ed6d4ad1..307c43ddca6 100644 --- a/package/localedef/localedef.mk +++ b/package/localedef/localedef.mk @@ -40,6 +40,7 @@ define HOST_LOCALEDEF_CONFIGURE_CMDS --with-pkgversion="Buildroot" \ --without-cvs \ --disable-profile \ + --disable-werror \ --without-gd \ --enable-obsolete-rpc) endef From 37bb8f046521eaf101b0565cc6c2ead950572368 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 11 Jul 2022 08:11:39 -0700 Subject: [PATCH 16/39] arch/arm: add cortex-a77 armv8.2a core Signed-off-by: Christian Stewart --- arch/Config.in.arm | 8 ++++++++ package/kvm-unit-tests/Config.in | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/arch/Config.in.arm b/arch/Config.in.arm index 5c9037c9597..6fbad65f9e7 100644 --- a/arch/Config.in.arm +++ b/arch/Config.in.arm @@ -479,6 +479,14 @@ config BR2_cortex_a76_a55 select BR2_ARM_CPU_HAS_FP_ARMV8 select BR2_ARM_CPU_ARMV8A select BR2_ARCH_NEEDS_GCC_AT_LEAST_9 +config BR2_cortex_a77 + bool "cortex-A77" + select BR2_ARM_CPU_HAS_ARM if !BR2_ARCH_IS_64 + select BR2_ARM_CPU_HAS_NEON if !BR2_ARCH_IS_64 + select BR2_ARM_CPU_HAS_THUMB2 if !BR2_ARCH_IS_64 + select BR2_ARM_CPU_HAS_FP_ARMV8 + select BR2_ARM_CPU_ARMV8A + select BR2_ARCH_NEEDS_GCC_AT_LEAST_11 config BR2_cortex_a78 bool "cortex-A78" select BR2_ARM_CPU_HAS_ARM if !BR2_ARCH_IS_64 diff --git a/package/kvm-unit-tests/Config.in b/package/kvm-unit-tests/Config.in index 817d3c4a8fc..9829761471a 100644 --- a/package/kvm-unit-tests/Config.in +++ b/package/kvm-unit-tests/Config.in @@ -5,7 +5,9 @@ config BR2_PACKAGE_KVM_UNIT_TESTS_ARCH_SUPPORTS (BR2_cortex_a7 || BR2_cortex_a12 || \ BR2_cortex_a15 || BR2_cortex_a15_a7 || \ BR2_cortex_a17 || BR2_cortex_a17_a7 || \ - BR2_cortex_a76 || BR2_cortex_a76_a55) + BR2_cortex_a55 || BR2_cortex_a75 || \ + BR2_cortex_a75_a55 || BR2_cortex_a76 || \ + BR2_cortex_a76_a55 || BR2_cortex_a77) # For AArch64 we can assume all v8.0+ support virtualization default y if BR2_aarch64 default y if BR2_riscv From 9b9b7f4469ebecf25c1c60f6fc7f08a165601b63 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Thu, 2 Jul 2020 11:16:00 -0700 Subject: [PATCH 17/39] package/rngd: start rngd early in the boot process Lack of an RNG source can block boot-up on headless systems with few hardware entropy sources. This patch allows rngd to start earlier than the current "basic.target" when systemd is used. Removing the dependency on "basic.target" and by extension, "sockets.target" will allow rngd to start before, for example, docker.sock - which can take some time to become ready without entropy. This is a cherry-pick of a peer project patch: https://patchwork.openembedded.org/patch/163303/ Signed-off-by: Christian Stewart --- package/rng-tools/rngd.service | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/rng-tools/rngd.service b/package/rng-tools/rngd.service index 11386d1e5d6..28ef65a1294 100644 --- a/package/rng-tools/rngd.service +++ b/package/rng-tools/rngd.service @@ -1,5 +1,9 @@ [Unit] Description=Hardware RNG Entropy Gatherer Daemon +DefaultDependencies=no +After=systemd-udev-settle.service +Before=sysinit.target shutdown.target +Conflicts=shutdown.target [Service] ExecStart=/usr/sbin/rngd -f $DAEMON_ARGS From c5171a8776230c4c18fffcd40de6d386d1126f83 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 22 Jan 2023 18:45:02 -0800 Subject: [PATCH 18/39] boot/refind-bin: new package rEFInd is a user-friendly EFI GUI for boot selection. It can be used as an alternative to Grub with a user-friendly graphical and/or text interface for selecting a boot option. The default refind.conf interactively displays a list of boot options on startup, including detected Buildroot Linux kernel/initrd files. https://www.rodsbooks.com/refind/ Signed-off-by: Christian Stewart --- boot/Config.in | 1 + boot/refind-bin/Config.in | 28 +++++++++++++++ boot/refind-bin/readme.txt | 42 ++++++++++++++++++++++ boot/refind-bin/refind-bin.hash | 5 +++ boot/refind-bin/refind-bin.mk | 63 +++++++++++++++++++++++++++++++++ 5 files changed, 139 insertions(+) create mode 100644 boot/refind-bin/Config.in create mode 100644 boot/refind-bin/readme.txt create mode 100644 boot/refind-bin/refind-bin.hash create mode 100644 boot/refind-bin/refind-bin.mk diff --git a/boot/Config.in b/boot/Config.in index d73d221431f..d26ebadf7f8 100644 --- a/boot/Config.in +++ b/boot/Config.in @@ -21,6 +21,7 @@ source "boot/mxs-bootlets/Config.in" source "boot/optee-os/Config.in" source "boot/opensbi/Config.in" source "boot/palo/Config.in" +source "boot/refind-bin/Config.in" source "boot/shim/Config.in" source "boot/syslinux/Config.in" source "boot/ti-k3-boot-firmware/Config.in" diff --git a/boot/refind-bin/Config.in b/boot/refind-bin/Config.in new file mode 100644 index 00000000000..7bc19d00e68 --- /dev/null +++ b/boot/refind-bin/Config.in @@ -0,0 +1,28 @@ +config BR2_PACKAGE_REFIND_BIN_ARCH_SUPPORTS + bool + default y if BR2_i386 + default y if BR2_x86_64 + default y if BR2_aarch64 + depends on BR2_USE_MMU + +menuconfig BR2_TARGET_REFIND_BIN + bool "refind-bin" + depends on BR2_PACKAGE_REFIND_BIN_ARCH_SUPPORTS + help + rEFInd presents a user-friendly GUI for boot selection. + + For additional notes on using rEFInd with Buildroot, see + boot/refind/readme.txt + + This is the pre-compiled binary variant. + + https://www.rodsbooks.com/refind/ + +if BR2_TARGET_REFIND_BIN + +config BR2_TARGET_REFIND_BIN_RENAME_TO_BOOT + bool "rename refind efi files to BOOT" + help + Move refind EFI directory to the default BOOT path. + +endif diff --git a/boot/refind-bin/readme.txt b/boot/refind-bin/readme.txt new file mode 100644 index 00000000000..d4bc326e6f1 --- /dev/null +++ b/boot/refind-bin/readme.txt @@ -0,0 +1,42 @@ +Notes on using rEFInd +============================================= + +1. Create a disk image + dd if=/dev/zero of=disk.img bs=1M count=32 +2. Partition it (either legacy or GPT style partitions work) + - Create one fat16 partition, labeled BOOT, flags boot, lba. + - Create one ext4 partition, type Linux, for the root fs. +3. Setup loop device and loop partitions + sudo losetup -f disk.img + sudo partx -a /dev/loop0 +4. Prepare the partition contents + sudo mkfs.fat -F 16 -L BOOT /dev/loop0p1 + sudo mkfs.ext4 -L root /dev/loop0p2 + sudo mount /dev/loop0p1 /mnt + sudo tar -C /mnt -xf output/images/refind.tar + sudo umount /mnt + sudo mount /dev/loop0p2 /mnt + sudo tar -C /mnt -xf output/images/rootfs.tar + sudo umount /mnt +5. Cleanup loop device + sudo partx -d /dev/loop0 + sudo losetup -d /dev/loop0 +6. Your disk.img is ready! + +Configuring rEFInd +============================================= + +rEFInd will search for refind_linux.conf files. + +Place a refind_linux.conf file in the same location as your initrd: + +"Boot Buildroot" "initrd=/boot/initrd-%v root=/dev/initrd ro earlyprintk" + +rEFInd will find all files with prefix initrd- and display options on screen, +defaulting to the most recent build version. + +Example contents of /boot: + +bzImage-buildroot-2022.05.1-104-1 +initrd-buildroot-2022.05.1-104-1 +refind_linux.conf diff --git a/boot/refind-bin/refind-bin.hash b/boot/refind-bin/refind-bin.hash new file mode 100644 index 00000000000..a03cc826e7c --- /dev/null +++ b/boot/refind-bin/refind-bin.hash @@ -0,0 +1,5 @@ +# Locally computed +sha256 44a981538cf06e683bc095e11694ce8508826fcc6ca6229e116938575e7c4c54 refind-bin-0.13.3.1.zip +sha256 8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903 COPYING.txt +sha256 cebbc60079d3e79a1d94bf7c63482ca27d8ce58739d28c5e209bbd378337729b LICENSE.txt +sha256 4748f03ed2dbcc14cde6ebc30799899c403e356a7465dc30fcf2b80c45fc0059 docs/refind/FDL-1.3.txt diff --git a/boot/refind-bin/refind-bin.mk b/boot/refind-bin/refind-bin.mk new file mode 100644 index 00000000000..bc806558cb6 --- /dev/null +++ b/boot/refind-bin/refind-bin.mk @@ -0,0 +1,63 @@ +################################################################################ +# +# refind-bin +# +################################################################################ + +REFIND_BIN_VERSION = 0.13.3.1 +REFIND_BIN_SITE = http://downloads.sourceforge.net/project/refind/$(REFIND_BIN_VERSION) +REFIND_BIN_SOURCE = refind-bin-$(REFIND_BIN_VERSION).zip +REFIND_BIN_LICENSE = GPL-3.0+, GFDL-1.3+ (docs) +REFIND_BIN_LICENSE_FILES = COPYING.txt LICENSE.txt docs/refind/FDL-1.3.txt +REFIND_BIN_INSTALL_IMAGES = YES + +ifeq ($(BR2_x86_64),y) +REFIND_BIN_ARCH = x86_64 +REFIND_BIN_PLATFORM = x64 +else ifeq ($(BR2_aarch64),y) +REFIND_BIN_ARCH = aarch64 +REFIND_BIN_PLATFORM = aa64 +else +REFIND_BIN_ARCH = ia32 +REFIND_BIN_PLATFORM = ia32 +endif + +REFIND_BIN_EFI_PART_DIR = $(BINARIES_DIR)/efi-part +REFIND_BIN_BINARIES_DIR = $(REFIND_BIN_EFI_PART_DIR)/EFI/refind + +REFIND_BIN_EXTRACT_CMDS = \ + bsdtar --strip-components=1 \ + -C $(REFIND_BIN_DIR) \ + $(TAR_OPTIONS) $(REFIND_BIN_DL_DIR)/$(REFIND_BIN_SOURCE) - + +define REFIND_BIN_INSTALL_IMAGES_CMDS + if [ -d $(REFIND_BIN_BINARIES_DIR) ]; then \ + rm -rf $(REFIND_BIN_BINARIES_DIR); \ + fi + $(INSTALL) -m 0755 -D $(@D)/refind/refind_$(REFIND_BIN_PLATFORM).efi \ + $(REFIND_BIN_BINARIES_DIR)/refind_$(REFIND_BIN_PLATFORM).efi + cp -r $(@D)/refind/drivers_$(REFIND_BIN_PLATFORM) \ + $(REFIND_BIN_BINARIES_DIR)/drivers_$(REFIND_BIN_PLATFORM) + echo "refind_$(REFIND_BIN_PLATFORM).efi,rEFInd Boot Manager,,Entry for rEFInd" > \ + $(REFIND_BIN_BINARIES_DIR)/BOOT.CSV + echo "# rEFInd configuration\ntimeout 20\n" > \ + $(REFIND_BIN_BINARIES_DIR)/refind.conf + cp -r $(@D)/refind/icons $(REFIND_BIN_BINARIES_DIR)/icons + cp -r $(@D)/{fonts,banners,keys} $(REFIND_BIN_BINARIES_DIR)/ +endef + +ifeq ($(BR2_TARGET_REFIND_BIN_RENAME_TO_BOOT),y) +define REFIND_BIN_IMAGES_RENAME_TO_BOOT + if [ -d $(REFIND_BIN_EFI_PART_DIR)/EFI/BOOT ]; then \ + rm -rf $(REFIND_BIN_EFI_PART_DIR)/EFI/BOOT; \ + fi + mv $(REFIND_BIN_BINARIES_DIR)/ $(REFIND_BIN_EFI_PART_DIR)/EFI/BOOT/ + mv $(REFIND_BIN_EFI_PART_DIR)/EFI/BOOT/refind_$(REFIND_BIN_PLATFORM).efi \ + $(REFIND_BIN_EFI_PART_DIR)/EFI/BOOT/BOOT$(REFIND_BIN_PLATFORM).EFI + echo "BOOT$(REFIND_BIN_PLATFORM).EFI,rEFInd Boot Manager,,Entry for rEFInd" > \ + $(REFIND_BIN_EFI_PART_DIR)/EFI/BOOT/BOOT.CSV +endef +REFIND_BIN_POST_INSTALL_IMAGES_HOOKS += REFIND_BIN_IMAGES_RENAME_TO_BOOT +endif + +$(eval $(generic-package)) From f731ddd155e3be0e189aa814af6a03338234d619 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 15 Apr 2025 14:08:54 -0700 Subject: [PATCH 19/39] boot/refind-bin: update to version 0.14.2 Signed-off-by: Christian Stewart --- boot/refind-bin/refind-bin.hash | 2 +- boot/refind-bin/refind-bin.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/boot/refind-bin/refind-bin.hash b/boot/refind-bin/refind-bin.hash index a03cc826e7c..fbd9030bf1b 100644 --- a/boot/refind-bin/refind-bin.hash +++ b/boot/refind-bin/refind-bin.hash @@ -1,5 +1,5 @@ # Locally computed -sha256 44a981538cf06e683bc095e11694ce8508826fcc6ca6229e116938575e7c4c54 refind-bin-0.13.3.1.zip +sha256 410c7828c4fec2f2179bd956073522415831d27c00416381b8f71153c190a311 refind-bin-0.14.2.zip sha256 8ceb4b9ee5adedde47b31e975c1d90c73ad27b6b165a1dcd80c7c545eb65b903 COPYING.txt sha256 cebbc60079d3e79a1d94bf7c63482ca27d8ce58739d28c5e209bbd378337729b LICENSE.txt sha256 4748f03ed2dbcc14cde6ebc30799899c403e356a7465dc30fcf2b80c45fc0059 docs/refind/FDL-1.3.txt diff --git a/boot/refind-bin/refind-bin.mk b/boot/refind-bin/refind-bin.mk index bc806558cb6..705a7c7a2f4 100644 --- a/boot/refind-bin/refind-bin.mk +++ b/boot/refind-bin/refind-bin.mk @@ -4,7 +4,7 @@ # ################################################################################ -REFIND_BIN_VERSION = 0.13.3.1 +REFIND_BIN_VERSION = 0.14.2 REFIND_BIN_SITE = http://downloads.sourceforge.net/project/refind/$(REFIND_BIN_VERSION) REFIND_BIN_SOURCE = refind-bin-$(REFIND_BIN_VERSION).zip REFIND_BIN_LICENSE = GPL-3.0+, GFDL-1.3+ (docs) From 34574309e7ec9696bdd977d623b03dcdcded459b Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Wed, 26 Oct 2022 11:38:11 -0700 Subject: [PATCH 20/39] package/docker-engine: add netcgo build tag Force Docker Engine to use the C DNS resolver. Fixes some issues related to the Go DNS resolver. Signed-off-by: Christian Stewart --- package/docker-engine/docker-engine.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package/docker-engine/docker-engine.mk b/package/docker-engine/docker-engine.mk index 2df260e1e53..cb764517248 100644 --- a/package/docker-engine/docker-engine.mk +++ b/package/docker-engine/docker-engine.mk @@ -23,7 +23,7 @@ DOCKER_ENGINE_LDFLAGS = \ -X $(DOCKER_ENGINE_GOMOD)/dockerversion.InitCommitID="" \ -X $(DOCKER_ENGINE_GOMOD)/dockerversion.Version="$(DOCKER_ENGINE_VERSION)" -DOCKER_ENGINE_TAGS = cgo exclude_graphdriver_zfs +DOCKER_ENGINE_TAGS = cgo netcgo exclude_graphdriver_zfs DOCKER_ENGINE_BUILD_TARGETS = cmd/dockerd cmd/docker-proxy ifeq ($(BR2_PACKAGE_LIBAPPARMOR),y) From a63091d84ad90d6adecd8f99f2a4e375dc7cf150 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 2 May 2021 19:19:27 -0700 Subject: [PATCH 21/39] package/genuinetools-img: new host and target package Img is a standalone, daemon-less, unprivileged Dockerfile and OCI compatible container image builder. It uses the moby-buildkit solver internally. The commands/UX mirror the Docker CLI for workflow compatibility. Using the genuinetools- prefix due to the generic nature of the "img" name. Adds both host and target variants. fuse-overlayfs can be used as an unprivileged and rootless overlay filesystem backend. https://github.com/genuinetools/img Signed-off-by: Christian Stewart --- TODO: https://patchwork.ozlabs.org/project/buildroot/patch/20210516010521.1375959-1-christian@aperture.us/ - changes to patch to add libfuse3 as host package requested. --- package/Config.in | 1 + package/Config.in.host | 1 + package/genuinetools-img/Config.in | 23 ++++++++++++++++ package/genuinetools-img/Config.in.host | 9 +++++++ .../genuinetools-img/genuinetools-img.hash | 3 +++ package/genuinetools-img/genuinetools-img.mk | 26 +++++++++++++++++++ 6 files changed, 63 insertions(+) create mode 100644 package/genuinetools-img/Config.in create mode 100644 package/genuinetools-img/Config.in.host create mode 100644 package/genuinetools-img/genuinetools-img.hash create mode 100644 package/genuinetools-img/genuinetools-img.mk diff --git a/package/Config.in b/package/Config.in index b6f23308aff..0d22251c889 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2816,6 +2816,7 @@ menu "System tools" source "package/emlog/Config.in" source "package/fluent-bit/Config.in" source "package/ftop/Config.in" + source "package/genuinetools-img/Config.in" source "package/getent/Config.in" source "package/gkrellm/Config.in" source "package/htop/Config.in" diff --git a/package/Config.in.host b/package/Config.in.host index f4b00a1e285..0366578fd2f 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -48,6 +48,7 @@ menu "Host utilities" source "package/genext2fs/Config.in.host" source "package/genimage/Config.in.host" source "package/genpart/Config.in.host" + source "package/genuinetools-img/Config.in.host" source "package/gnupg/Config.in.host" source "package/gnupg2/Config.in.host" source "package/go/Config.in.host" diff --git a/package/genuinetools-img/Config.in b/package/genuinetools-img/Config.in new file mode 100644 index 00000000000..eb4992db074 --- /dev/null +++ b/package/genuinetools-img/Config.in @@ -0,0 +1,23 @@ +config BR2_PACKAGE_GENUINETOOLS_IMG + bool "genuinetools-img" + depends on BR2_USE_MMU # fuse-overlayfs libfuse3 + depends on !BR2_STATIC_LIBS # fuse-overlayfs libfuse3 + depends on BR2_TOOLCHAIN_HAS_THREADS # fuse-overlayfs libfuse3 + depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15 # fuse-overlayfs + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + depends on BR2_TOOLCHAIN_HAS_THREADS + depends on !BR2_TOOLCHAIN_USES_UCLIBC + select BR2_PACKAGE_CGROUPFS_MOUNT if !BR2_PACKAGE_SYSTEMD # runtime dependency + select BR2_PACKAGE_FUSE_OVERLAYFS # runtime dependency + select BR2_PACKAGE_LIBFUSE3 # fuse-overlayfs + help + Img is a standalone, daemon-less, unprivileged Dockerfile + and OCI compatible container image builder. + + https://github.com/genuinetools/img + +comment "genuinetools-img needs a toolchain w/ threads, dynamic library, headers >= 3.15" + depends on BR2_USE_MMU + depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS || \ + !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_15 diff --git a/package/genuinetools-img/Config.in.host b/package/genuinetools-img/Config.in.host new file mode 100644 index 00000000000..bbef88acf6d --- /dev/null +++ b/package/genuinetools-img/Config.in.host @@ -0,0 +1,9 @@ +config BR2_PACKAGE_HOST_GENUINETOOLS_IMG + bool "host genuinetools-img" + depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_FUSE_OVERLAYFS # runtime dependency + help + Img is a standalone, daemon-less, unprivileged Dockerfile + and OCI compatible container image builder. + + https://github.com/genuinetools/img diff --git a/package/genuinetools-img/genuinetools-img.hash b/package/genuinetools-img/genuinetools-img.hash new file mode 100644 index 00000000000..6610d34eead --- /dev/null +++ b/package/genuinetools-img/genuinetools-img.hash @@ -0,0 +1,3 @@ +# Locally calculated +sha256 c6d805ab899db639fa08f0e33fe6673593be8336d288bb1cb4cb81a3229a916f genuinetools-img-0.5.11-go2.tar.gz +sha256 c696614021eafe355c7fb0af3e724fc7fa8729a0c10c27cbed2505bf30a853ce LICENSE diff --git a/package/genuinetools-img/genuinetools-img.mk b/package/genuinetools-img/genuinetools-img.mk new file mode 100644 index 00000000000..5b2373eca39 --- /dev/null +++ b/package/genuinetools-img/genuinetools-img.mk @@ -0,0 +1,26 @@ +################################################################################ +# +# genuinetools-img +# +################################################################################ + +GENUINETOOLS_IMG_VERSION = 0.5.11 +GENUINETOOLS_IMG_SITE = $(call github,genuinetools,img,v$(GENUINETOOLS_IMG_VERSION)) + +GENUINETOOLS_IMG_LICENSE = MIT +GENUINETOOLS_IMG_LICENSE_FILES = LICENSE + +GENUINETOOLS_IMG_DEPENDENCIES = host-pkgconf +GENUINETOOLS_IMG_GOMOD = github.com/genuinetools/img + +GENUINETOOLS_IMG_TAGS = cgo noembed +GENUINETOOLS_IMG_LDFLAGS = \ + -X $(GENUINETOOLS_IMG_GOMOD)/version.VERSION="$(GENUINETOOLS_IMG_VERSION)" + +HOST_GENUINETOOLS_IMG_TAGS = $(GENUINETOOLS_IMG_TAGS) +HOST_GENUINETOOLS_IMG_LDFLAGS = $(GENUINETOOLS_IMG_LDFLAGS) + +HOST_GENUINETOOLS_IMG_BIN_NAME = genuinetools-img + +$(eval $(golang-package)) +$(eval $(host-golang-package)) From cb7191d64e819a00f229c44ed0d6b5ef75aa86c4 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 24 Jan 2021 02:20:30 -0800 Subject: [PATCH 22/39] package/daemonize: new package Daemonize is a command line utility to run a program as a Unix daemon. Signed-off-by: Christian Stewart --- TODO: Changes requested for v2: https://patchwork.ozlabs.org/project/buildroot/patch/20210124102241.1207866-1-christian@paral.in/ --- package/Config.in | 1 + ...de-setpgrp-to-enable-cross-compiling.patch | 56 +++++++++++++++++++ package/daemonize/Config.in | 4 ++ package/daemonize/daemonize.hash | 1 + package/daemonize/daemonize.mk | 12 ++++ 5 files changed, 74 insertions(+) create mode 100644 package/daemonize/0001-configure-override-setpgrp-to-enable-cross-compiling.patch create mode 100644 package/daemonize/Config.in create mode 100644 package/daemonize/daemonize.hash create mode 100644 package/daemonize/daemonize.mk diff --git a/package/Config.in b/package/Config.in index 0d22251c889..65045bac1e9 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2797,6 +2797,7 @@ menu "System tools" source "package/cpuload/Config.in" source "package/crun/Config.in" source "package/daemon/Config.in" + source "package/daemonize/Config.in" source "package/dc3dd/Config.in" source "package/dcron/Config.in" source "package/ddrescue/Config.in" diff --git a/package/daemonize/0001-configure-override-setpgrp-to-enable-cross-compiling.patch b/package/daemonize/0001-configure-override-setpgrp-to-enable-cross-compiling.patch new file mode 100644 index 00000000000..be083d3c5b6 --- /dev/null +++ b/package/daemonize/0001-configure-override-setpgrp-to-enable-cross-compiling.patch @@ -0,0 +1,56 @@ +From db172f4d7028c648f66f3c1db6202e6a5d62636d Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Sun, 24 Jan 2021 02:16:36 -0800 +Subject: [PATCH] configure: override setpgrp to enable cross-compiling +Upstream: N/A + +Signed-off-by: Christian Stewart +--- + configure | 30 +----------------------------- + 1 file changed, 1 insertion(+), 29 deletions(-) + +diff --git a/configure b/configure +index ab7c0d4..209e165 100755 +--- a/configure ++++ b/configure +@@ -4147,36 +4147,8 @@ fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether setpgrp takes no argument" >&5 + $as_echo_n "checking whether setpgrp takes no argument... " >&6; } +-if ${ac_cv_func_setpgrp_void+:} false; then : +- $as_echo_n "(cached) " >&6 +-else +- if test "$cross_compiling" = yes; then : +- as_fn_error $? "cannot check setpgrp when cross compiling" "$LINENO" 5 +-else +- cat confdefs.h - <<_ACEOF >conftest.$ac_ext +-/* end confdefs.h. */ +-$ac_includes_default +-int +-main () +-{ +-/* If this system has a BSD-style setpgrp which takes arguments, +- setpgrp(1, 1) will fail with ESRCH and return -1, in that case +- exit successfully. */ +- return setpgrp (1,1) != -1; +- ; +- return 0; +-} +-_ACEOF +-if ac_fn_c_try_run "$LINENO"; then : +- ac_cv_func_setpgrp_void=no +-else +- ac_cv_func_setpgrp_void=yes +-fi +-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ +- conftest.$ac_objext conftest.beam conftest.$ac_ext +-fi ++ac_cv_func_setpgrp_void=yes + +-fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setpgrp_void" >&5 + $as_echo "$ac_cv_func_setpgrp_void" >&6; } + if test $ac_cv_func_setpgrp_void = yes; then +-- +2.30.0 + diff --git a/package/daemonize/Config.in b/package/daemonize/Config.in new file mode 100644 index 00000000000..6c38a7a4a4c --- /dev/null +++ b/package/daemonize/Config.in @@ -0,0 +1,4 @@ +menuconfig BR2_PACKAGE_DAEMONIZE + bool "daemonize" + help + Command line utility to run a daemon. diff --git a/package/daemonize/daemonize.hash b/package/daemonize/daemonize.hash new file mode 100644 index 00000000000..8bf58e96f41 --- /dev/null +++ b/package/daemonize/daemonize.hash @@ -0,0 +1 @@ +sha256 20c4fc9925371d1ddf1b57947f8fb93e2036eb9ccc3b43a1e3678ea8471c4c60 daemonize-1.7.8.tar.gz diff --git a/package/daemonize/daemonize.mk b/package/daemonize/daemonize.mk new file mode 100644 index 00000000000..9a86ae95d5e --- /dev/null +++ b/package/daemonize/daemonize.mk @@ -0,0 +1,12 @@ +################################################################################ +# +# daemonize +# +################################################################################ + +DAEMONIZE_VERSION = 1.7.8 +DAEMONIZE_SITE = $(call github,bmc,daemonize,release-$(DAEMONIZE_VERSION)) +DAEMONIZE_LICENSE = BSD-3-Clause +DAEMONIZE_LICENSE_FILES = LICENSE.md + +$(eval $(autotools-package)) From 4cc9163ad3b3bb0f1f17fad06cdbb88e53dda1cf Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Wed, 26 Jan 2022 19:35:00 -0800 Subject: [PATCH 23/39] package/buildah: new package Adds both host and target packages for buildah. Buildah is a tool that facilitates building OCI images. https://github.com/containers/buildah The buildah tree does not ship with a default policy.json file, and instead relies on packagers to provide one. A patch is added to create a basic barebones policy.json which is installed to /etc/containers/policy.json with a hook. Signed-off-by: Christian Stewart --- v1 -> v2: - add package to developers - add host runc dependency for host package - add libgpgme runtime dependency v2 -> v3: - add policy.json to target: required by some commands - example: buildah pull docker.io/library/alpine - pull: tested on raspberry pi 4 v3 -> v4: - TODO: move policy.json to package dir - https://lists.buildroot.org/pipermail/buildroot/2022-January/634936.html - bump to version v1.32.1 - https://github.com/containers/buildah/releases/tag/v1.32.1 v4 -> v5: - bump to version 1.35.x Signed-off-by: Christian Stewart --- DEVELOPERS | 1 + package/Config.in | 1 + package/Config.in.host | 1 + ...01-contrib-add-buildroot-policy-json.patch | 39 ++++++++++++++++++ package/buildah/Config.in | 22 ++++++++++ package/buildah/Config.in.host | 8 ++++ package/buildah/buildah.hash | 3 ++ package/buildah/buildah.mk | 40 +++++++++++++++++++ 8 files changed, 115 insertions(+) create mode 100644 package/buildah/0001-contrib-add-buildroot-policy-json.patch create mode 100644 package/buildah/Config.in create mode 100644 package/buildah/Config.in.host create mode 100644 package/buildah/buildah.hash create mode 100644 package/buildah/buildah.mk diff --git a/DEVELOPERS b/DEVELOPERS index fdfab8b4899..5753917ea39 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -635,6 +635,7 @@ F: package/python-pylibftdi/ N: Christian Stewart F: package/balena-engine/ F: package/batman-adv/ +F: package/buildah/ F: package/catatonit/ F: package/cni-plugins/ F: package/conmon/ diff --git a/package/Config.in b/package/Config.in index 65045bac1e9..c1e3d4d17ad 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2786,6 +2786,7 @@ menu "System tools" source "package/audit/Config.in" source "package/balena-engine/Config.in" source "package/bubblewrap/Config.in" + source "package/buildah/Config.in" source "package/cgroupfs-mount/Config.in" source "package/cgroupfs-v2-mount/Config.in" source "package/circus/Config.in" diff --git a/package/Config.in.host b/package/Config.in.host index 0366578fd2f..b082c760f64 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -14,6 +14,7 @@ menu "Host utilities" source "package/bmap-writer/Config.in.host" source "package/bootgen/Config.in.host" source "package/btrfs-progs/Config.in.host" + source "package/buildah/Config.in.host" source "package/ca-certificates/Config.in.host" source "package/casync-nano/Config.in.host" source "package/cbootimage/Config.in.host" diff --git a/package/buildah/0001-contrib-add-buildroot-policy-json.patch b/package/buildah/0001-contrib-add-buildroot-policy-json.patch new file mode 100644 index 00000000000..12a5798bbb7 --- /dev/null +++ b/package/buildah/0001-contrib-add-buildroot-policy-json.patch @@ -0,0 +1,39 @@ +From 6808cfa788f03fca36a41202d9475ee5bc9feac7 Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Wed, 26 Jan 2022 22:07:09 -0800 +Subject: [PATCH] contrib: add buildroot policy json +Upstream: N/A + +Buildah does not ship a default policy.json in-tree. + +Signed-off-by: Christian Stewart +--- + contrib/buildroot/policy.json | 16 ++++++++++++++++ + 1 file changed, 16 insertions(+) + create mode 100644 contrib/buildroot/policy.json + +diff --git a/contrib/buildroot/policy.json b/contrib/buildroot/policy.json +new file mode 100644 +index 00000000..d8c638a0 +--- /dev/null ++++ b/contrib/buildroot/policy.json +@@ -0,0 +1,16 @@ ++{ ++ "default": [ ++ { ++ "type": "insecureAcceptAnything" ++ } ++ ], ++ "transports": { ++ "docker-daemon": { ++ "": [ ++ { ++ "type": "insecureAcceptAnything" ++ } ++ ] ++ } ++ } ++} +-- +2.35.0 + diff --git a/package/buildah/Config.in b/package/buildah/Config.in new file mode 100644 index 00000000000..254593c5ebe --- /dev/null +++ b/package/buildah/Config.in @@ -0,0 +1,22 @@ +config BR2_PACKAGE_BUILDAH + bool "buildah" + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libgpgme -> libgpg-error + depends on BR2_TOOLCHAIN_HAS_THREADS # runc + depends on BR2_USE_MMU # libgpgme -> libassuan + depends on !BR2_TOOLCHAIN_USES_UCLIBC # runc -> no fexecve + # libgpgme selects the appropriate GnuPG provider; runc is runtime-only. + select BR2_PACKAGE_LIBGPGME + select BR2_PACKAGE_LIBGPG_ERROR + select BR2_PACKAGE_LIBASSUAN + select BR2_PACKAGE_RUNC + help + Buildah is a tool that facilitates building OCI images. + + https://github.com/containers/buildah + +comment "buildah needs a glibc or musl toolchain w/ threads" + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS && \ + BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_TOOLCHAIN_USES_UCLIBC diff --git a/package/buildah/Config.in.host b/package/buildah/Config.in.host new file mode 100644 index 00000000000..67fee6d7ac9 --- /dev/null +++ b/package/buildah/Config.in.host @@ -0,0 +1,8 @@ +config BR2_PACKAGE_HOST_BUILDAH + bool "host buildah" + depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_RUNC + help + Buildah is a tool that facilitates building OCI images. + + https://github.com/containers/buildah diff --git a/package/buildah/buildah.hash b/package/buildah/buildah.hash new file mode 100644 index 00000000000..13934ee47d2 --- /dev/null +++ b/package/buildah/buildah.hash @@ -0,0 +1,3 @@ +# Locally calculated +sha256 7d655453d6ff150503a4ecd61481622d83735f89fc69cf1805f0d3a1619c8c2c buildah-1.35.4-go2.tar.gz +sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1 LICENSE diff --git a/package/buildah/buildah.mk b/package/buildah/buildah.mk new file mode 100644 index 00000000000..66d298d110b --- /dev/null +++ b/package/buildah/buildah.mk @@ -0,0 +1,40 @@ +################################################################################ +# +# buildah +# +################################################################################ + +BUILDAH_VERSION = 1.35.4 +BUILDAH_SITE = $(call github,containers,buildah,v$(BUILDAH_VERSION)) + +BUILDAH_LICENSE = Apache-2.0 +BUILDAH_LICENSE_FILES = LICENSE + +BUILDAH_DEPENDENCIES = libgpgme + +BUILDAH_TAGS = \ + cgo \ + exclude_graphdriver_aufs \ + exclude_graphdriver_btrfs \ + exclude_graphdriver_devicemapper \ + exclude_graphdriver_zfs +BUILDAH_BUILD_TARGETS = cmd/buildah +BUILDAH_GOMOD = github.com/containers/buildah + +BUILDAH_LDFLAGS = \ + -X $(BUILDAH_GOMOD)/cmd/buildah.GitCommit=v$(BUILDAH_VERSION) \ + -X $(BUILDAH_GOMOD)/define.Version=v$(BUILDAH_VERSION) + +define BUILDAH_INSTALL_CONFIG + $(INSTALL) -D -m 644 $(@D)/contrib/buildroot/policy.json \ + $(TARGET_DIR)/etc/containers/policy.json +endef + +BUILDAH_POST_INSTALL_TARGET_HOOKS += BUILDAH_INSTALL_CONFIG + +HOST_BUILDAH_BUILD_TARGETS = $(BUILDAH_BUILD_TARGETS) +HOST_BUILDAH_TAGS = $(BUILDAH_TAGS) +HOST_BUILDAH_LDFLAGS = $(BUILDAH_LDFLAGS) + +$(eval $(golang-package)) +$(eval $(host-golang-package)) From a212b3f01e4da9b5058923be295c7477cd6d9973 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Thu, 11 May 2023 17:59:04 -0700 Subject: [PATCH 24/39] package/crio: new package crio implements the Kubelet Container Runtime Interface (CRI) using OCI conformant runtimes like runc or podman. https://github.com/cri-o/cri-o/ Signed-off-by: Christian Stewart --- package/Config.in | 1 + package/crio/Config.in | 54 ++++++++++++++++++++++++++++ package/crio/crio.hash | 3 ++ package/crio/crio.mk | 82 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 140 insertions(+) create mode 100644 package/crio/Config.in create mode 100644 package/crio/crio.hash create mode 100644 package/crio/crio.mk diff --git a/package/Config.in b/package/Config.in index c1e3d4d17ad..260b072512e 100644 --- a/package/Config.in +++ b/package/Config.in @@ -2796,6 +2796,7 @@ menu "System tools" source "package/coreutils/Config.in" source "package/cpulimit/Config.in" source "package/cpuload/Config.in" + source "package/crio/Config.in" source "package/crun/Config.in" source "package/daemon/Config.in" source "package/daemonize/Config.in" diff --git a/package/crio/Config.in b/package/crio/Config.in new file mode 100644 index 00000000000..35a38c587eb --- /dev/null +++ b/package/crio/Config.in @@ -0,0 +1,54 @@ +config BR2_PACKAGE_CRIO + bool "crio" + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + depends on BR2_TOOLCHAIN_HAS_THREADS + depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_4 # iproute2, __kernel_{u,}long_t + depends on !BR2_TOOLCHAIN_USES_UCLIBC # no fexecve + depends on BR2_USE_MMU # libgpgme, iproute2, fork() + select BR2_PACKAGE_IPROUTE2 + select BR2_PACKAGE_IPTABLES + select BR2_PACKAGE_LIBGPGME + help + crio implements the Kubelet Container Runtime Interface (CRI) + using OCI conformant runtimes like runc or podman. + + https://github.com/cri-o/cri-o/ + +if BR2_PACKAGE_CRIO + +config BR2_PACKAGE_CRIO_DRIVER_BTRFS + bool "btrfs filesystem driver" + depends on BR2_USE_MMU # btrfs-progs + depends on BR2_TOOLCHAIN_HAS_THREADS # btrfs-progs + select BR2_PACKAGE_BTRFS_PROGS + help + Build the btrfs filesystem driver. + +config BR2_PACKAGE_CRIO_DRIVER_DEVICEMAPPER + bool "devicemapper filesystem driver" + depends on BR2_TOOLCHAIN_HAS_THREADS # lvm2 + depends on BR2_USE_MMU # lvm2 + depends on !BR2_STATIC_LIBS # lvm2 + select BR2_PACKAGE_LVM2 + help + Build the devicemapper filesystem driver. + +config BR2_PACKAGE_CRIO_DRIVER_OSTREE + bool "ostree storage driver" + depends on BR2_PACKAGE_LIBGPG_ERROR_ARCH_SUPPORTS # libostree, libgpgme, libgpg-error + depends on BR2_TOOLCHAIN_HAS_THREADS # libostree, libglib2 + depends on BR2_USE_WCHAR # libostree, libglib2 + depends on BR2_USE_MMU # libostree, e2fsprogs, libglib2, libgpgme + # doesn't build with musl due to lack of TEMP_FAILURE_RETRY() + depends on !BR2_TOOLCHAIN_USES_MUSL # libostree + select BR2_PACKAGE_LIBOSTREE + help + Build the ostree storage driver. + +endif + +comment "crio needs a glibc or musl toolchain w/ threads" + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS && \ + BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS + depends on !BR2_TOOLCHAIN_HAS_THREADS || BR2_TOOLCHAIN_USES_UCLIBC diff --git a/package/crio/crio.hash b/package/crio/crio.hash new file mode 100644 index 00000000000..2cad8f8bb8c --- /dev/null +++ b/package/crio/crio.hash @@ -0,0 +1,3 @@ +# Locally computed +sha256 8fd7c84ff74eff0a65e090bb9619f36508e461f6925f92a5b8886b759f2347d9 crio-1.27.0.tar.gz +sha256 b40930bbcf80744c86c46a12bc9da056641d722716c378f5659b9e555ef833e1 LICENSE diff --git a/package/crio/crio.mk b/package/crio/crio.mk new file mode 100644 index 00000000000..042c3697997 --- /dev/null +++ b/package/crio/crio.mk @@ -0,0 +1,82 @@ +################################################################################ +# +# crio +# +################################################################################ + +CRIO_VERSION = 1.27.0 +CRIO_SITE = $(call github,cri-o,cri-o,v$(CRIO_VERSION)) +CRIO_LICENSE = Apache-2.0 +CRIO_LICENSE_FILES = LICENSE + +CRIO_CPE_ID_VENDOR = kubernetes +CRIO_CPE_ID_PRODUCT = cri-o + +CRIO_BUILD_TARGETS = cmd/crio cmd/crio-status +CRIO_DEPENDENCIES += libgpgme +CRIO_LDFLAGS = \ + -X $(CRIO_GOMOD)/internal/version.Version=$(CRIO_VERSION) +CRIO_TAGS = exclude_graphdriver_zfs + +ifeq ($(BR2_INIT_SYSTEMD),y) +CRIO_TAGS += systemd +endif + +ifeq ($(BR2_PACKAGE_LIBAPPARMOR),y) +CRIO_DEPENDENCIES += libapparmor +CRIO_TAGS += apparmor +endif + +ifeq ($(BR2_PACKAGE_LIBSECCOMP),y) +CRIO_TAGS += seccomp +CRIO_DEPENDENCIES += libseccomp host-pkgconf +endif + +ifeq ($(BR2_PACKAGE_LIBSELINUX),y) +CRIO_TAGS += selinux +CRIO_DEPENDENCIES += libselinux +endif + +ifeq ($(BR2_PACKAGE_CRIO_DRIVER_BTRFS),y) +CRIO_DEPENDENCIES += btrfs-progs +else +CRIO_TAGS += exclude_graphdriver_btrfs +endif + +ifeq ($(BR2_PACKAGE_CRIO_DRIVER_DEVICEMAPPER),y) +CRIO_DEPENDENCIES += lvm2 +else +CRIO_TAGS += exclude_graphdriver_devicemapper +endif + +ifeq ($(BR2_PACKAGE_CRIO_DRIVER_OSTREE),y) +CRIO_DEPENDENCIES += libostree +CRIO_TAGS += ostree +endif + +define CRIO_BUILD_PINNS + $(TARGET_MAKE_ENV) $(MAKE) CC="$(TARGET_CC)" CFLAGS="$(TARGET_CFLAGS)" \ + LDFLAGS="$(TARGET_LDFLAGS)" STRIP="$(TARGET_STRIP)" \ + -C $(@D)/pinns ../bin/pinns +endef +CRIO_POST_BUILD_HOOKS += CRIO_BUILD_PINNS + +define CRIO_INSTALL_TARGET_CMDS + $(HOST_GO_COMMON_ENV) $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \ + DESTDIR=$(TARGET_DIR) PREFIX=$(TARGET_DIR)/usr ETCDIR=$(TARGET_DIR)/etc \ + OPT_CNI_BIN_DIR=$(TARGET_DIR)/opt/cni/bin install.bin-nobuild + $(INSTALL) -d -m 700 $(TARGET_DIR)/etc/cni + $(INSTALL) -d -m 700 $(TARGET_DIR)/etc/cni/net.d + $(INSTALL) -D -m 644 $(@D)/contrib/cni/10-crio-bridge.conflist \ + $(TARGET_DIR)/etc/cni/net.d/10-crio-bridge.conflist +endef + +define CRIO_INSTALL_INIT_SYSTEMD + $(HOST_GO_COMMON_ENV) $(TARGET_MAKE_ENV) $(MAKE) -C $(@D) \ + DESTDIR=$(TARGET_DIR) PREFIX=$(TARGET_DIR)/usr ETCDIR=$(TARGET_DIR)/etc \ + OPT_CNI_BIN_DIR=$(TARGET_DIR)/opt/cni/bin install.systemd + $(SED) 's,/usr/local/bin,/usr/bin,g' \ + $(TARGET_DIR)/usr/lib/systemd/system/{crio,crio-wipe}.service +endef + +$(eval $(golang-package)) From d49d315229566b75d7ae20e237727731c1ee0d7b Mon Sep 17 00:00:00 2001 From: Jan Havran Date: Sun, 20 Feb 2022 15:08:11 +0100 Subject: [PATCH 25/39] package/rtklib: new package RTKLIB is an open source program package for standard and precise positioning with GNSS. Version used here is from rtkexplorer, which is better optimized and more frequently updated than original version by Tomoji Takasu. Signed-off-by: Jan Havran --- v1: WIP: For SkiffOS: - https://patchwork.ozlabs.org/project/buildroot/patch/YhJLS73VW3szIXR+@arch-zen.localdomain/ - Changes applied from Thomas's review. - There are still Changes Requested before submitting upstream. - Updated to latest revision of the pkg. - Skip building the fortran files, need to investigate when this is necessary. Tested-by: Christian Stewart --- DEVELOPERS | 1 + package/Config.in | 1 + package/rtklib/Config.in | 38 ++++++++++++++++++++++++++++++++++++++ package/rtklib/rtklib.hash | 3 +++ package/rtklib/rtklib.mk | 38 ++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 package/rtklib/Config.in create mode 100644 package/rtklib/rtklib.hash create mode 100644 package/rtklib/rtklib.mk diff --git a/DEVELOPERS b/DEVELOPERS index 5753917ea39..f796917e23d 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1567,6 +1567,7 @@ F: package/microchip-hss-payload-generator/ N: Jan Havran F: board/pine64/pinecube/ F: configs/pine64_pinecube_defconfig +F: package/rtklib/ N: Jan Kraval F: board/orangepi/orangepi-lite diff --git a/package/Config.in b/package/Config.in index 260b072512e..8cf7fdb7bd7 100644 --- a/package/Config.in +++ b/package/Config.in @@ -589,6 +589,7 @@ endmenu source "package/rockchip-rkbin/Config.in" source "package/rs485conf/Config.in" source "package/rtc-tools/Config.in" + source "package/rtklib/Config.in" source "package/rtl8188eu/Config.in" source "package/rtl8189es/Config.in" source "package/rtl8189fs/Config.in" diff --git a/package/rtklib/Config.in b/package/rtklib/Config.in new file mode 100644 index 00000000000..dc694d6b7de --- /dev/null +++ b/package/rtklib/Config.in @@ -0,0 +1,38 @@ +comment "rtklib needs a toolchain w/ threads" + depends on !BR2_TOOLCHAIN_HAS_THREADS + +config BR2_PACKAGE_RTKLIB + bool "rtklib" + depends on BR2_TOOLCHAIN_HAS_THREADS + help + RTKLIB is an open source program package for standard and + precise positioning with GNSS (global navigation satellite + system). + + This is a version of RTKLIB optimized for single and dual + frequency low cost GPS receivers, especially u-blox receivers. + + https://rtkexplorer.com/ + +if BR2_PACKAGE_RTKLIB + +config BR2_PACKAGE_RTKLIB_CONVBIN + bool "convbin" + +config BR2_PACKAGE_RTKLIB_POS2KML + bool "pos2kml" + +comment "rnx2rtkp needs Fortran" + depends on !BR2_TOOLCHAIN_HAS_FORTRAN + +config BR2_PACKAGE_RTKLIB_RNX2RTKP + bool "rnx2rtkp" + depends on BR2_TOOLCHAIN_HAS_FORTRAN + +config BR2_PACKAGE_RTKLIB_RTKRCV + bool "rtkrcv" + +config BR2_PACKAGE_RTKLIB_STR2STR + bool "str2str" + +endif diff --git a/package/rtklib/rtklib.hash b/package/rtklib/rtklib.hash new file mode 100644 index 00000000000..d892fa774f9 --- /dev/null +++ b/package/rtklib/rtklib.hash @@ -0,0 +1,3 @@ +# Locally computed +sha256 f10efd2cc9e22d9e4a0c950ab86660747241d8b8a34d657952b5d2b9d14cb81b rtklib-620fa2873ce9182ab3ceab223170a3a2b7c3d651.tar.gz +sha256 219747832d49ee958457b2934080ab8d94bd9d8e45fcb1c36f89776fd2c5ed8a license.txt diff --git a/package/rtklib/rtklib.mk b/package/rtklib/rtklib.mk new file mode 100644 index 00000000000..ef12741df33 --- /dev/null +++ b/package/rtklib/rtklib.mk @@ -0,0 +1,38 @@ +################################################################################ +# +# rtklib +# +################################################################################ + +RTKLIB_VERSION = 620fa2873ce9182ab3ceab223170a3a2b7c3d651 +RTKLIB_SITE = $(call github,rtklibexplorer,RTKLIB,$(RTKLIB_VERSION)) +RTKLIB_LICENSE = BSD-2-Clause +RTKLIB_LICENSE_FILES = license.txt + +RTKLIB_APPS = \ + $(if $(BR2_PACKAGE_RTKLIB_CONVBIN),convbin) \ + $(if $(BR2_PACKAGE_RTKLIB_POS2KML),pos2kml) \ + $(if $(BR2_PACKAGE_RTKLIB_RNX2RTKP),rnx2rtkp) \ + $(if $(BR2_PACKAGE_RTKLIB_RTKRCV),rtkrcv) \ + $(if $(BR2_PACKAGE_RTKLIB_STR2STR),str2str) + +define RTKLIB_BUILD_CMDS + find $(@D) -name '*.a' | xargs rm -f + # TODO: Requires fortran compiler. Build conditional on RNX2RTKP. + # $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/lib/iers/gcc \ + # CC="$(TARGET_CC)" \ + # F77="$(TARGET_FC)" + $(foreach app,$(RTKLIB_APPS),\ + $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/app/consapp/$(app)/gcc \ + CC="$(TARGET_CC)" + ) +endef + +define RTKLIB_INSTALL_TARGET_CMDS + $(foreach app,$(RTKLIB_APPS), \ + $(INSTALL) -m 0755 $(@D)/app/consapp/$(app)/gcc/$(app) \ + $(TARGET_DIR)/usr/bin/$(app) + ) +endef + +$(eval $(generic-package)) From 1ba82a86c1015385a7c6ae9b51b262f6687341ce Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Wed, 27 Dec 2023 15:04:33 -0800 Subject: [PATCH 26/39] package/rtl8812au-aircrack-ng: ignore implicit-int warning Fixes a build failure against some older toolchains. Signed-off-by: Christian Stewart --- package/rtl8812au-aircrack-ng/rtl8812au-aircrack-ng.mk | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package/rtl8812au-aircrack-ng/rtl8812au-aircrack-ng.mk b/package/rtl8812au-aircrack-ng/rtl8812au-aircrack-ng.mk index 1308508e000..d243f900d45 100644 --- a/package/rtl8812au-aircrack-ng/rtl8812au-aircrack-ng.mk +++ b/package/rtl8812au-aircrack-ng/rtl8812au-aircrack-ng.mk @@ -15,7 +15,8 @@ RTL8812AU_AIRCRACK_NG_EXTRA_CFLAGS = \ -DRTW_USE_CFG80211_STA_EVENT \ -Wno-error=address \ -Wno-error=array-bounds \ - -Wno-error=cast-function-type + -Wno-error=cast-function-type \ + -Wno-error=implicit-int RTL8812AU_AIRCRACK_NG_MODULE_MAKE_OPTS = \ CONFIG_PLATFORM_I386_PC=n \ From 116bf22898bbc40c8b5eb74a5b902984d50ef434 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Wed, 2 Apr 2025 02:56:41 -0700 Subject: [PATCH 27/39] package/pkg-cmake.mk: force config version >=3.5 Some packages have CMakeLists.txt requiring CMake <3.5. Newer CMake forces at minimum version 3.5, leading to build failures: https://github.com/skiffos/SkiffOS/actions/runs/14208988354/job/39812576139#step:8:638 https://github.com/skiffos/SkiffOS/actions/runs/14211566256/job/39819600184#step:8:26664 Add the suggested build flag to force version 3.5.x and fix the error: -DCMAKE_POLICY_VERSION_MINIMUM=3.5 This is applied to all cmake packages to force 3.5 as a minimum. Signed-off-by: Christian Stewart --- package/pkg-cmake.mk | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/package/pkg-cmake.mk b/package/pkg-cmake.mk index f572bdebb3d..b377f2491f4 100644 --- a/package/pkg-cmake.mk +++ b/package/pkg-cmake.mk @@ -53,6 +53,10 @@ define inner-cmake-package $(3)_SUPPORTS_IN_SOURCE_BUILD ?= YES +# Some packages requires CMake 3.0.0 but latest CMake requires >=3.5 +# Set the policy version minimum to force these packages to 3.5 or greater. +$(2)_CONF_OPTS += -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + # The default backend, unless specified by the package $(3)_CMAKE_BACKEND ?= make From b1ae8cec0900629cb251b8e5ab955174a1a42858 Mon Sep 17 00:00:00 2001 From: James Hilliard Date: Mon, 28 Oct 2024 10:15:06 -0600 Subject: [PATCH 28/39] package/pkg-golang.mk: make GOPROXY configurable BR2_GOPROXY now configures the Go module proxy URL used to download Go modules specified in project go.mod and go.sum files. By default, it uses Google's official Go module mirror at proxy.golang.org, falling back to direct downloads if the module is not found in the mirror. This change sets the default GOPROXY value to match Go's built-in default of "https://proxy.golang.org,direct" which provides several benefits: - Avoid package breakages due to missing module sources - Better alignment with upstream Go toolchain defaults - Faster downloads via the proxy compared to direct Git clones - Maintains reproducible builds through Go's module checksum validation The default value from the toolchain can be read with "go env GOPROXY" We rely on package developers to audit their dependencies in go.mod and go.sum. The value can be configured to: - A comma-separated list of proxy URLs - "off" to disable all downloads - "direct" to download directly from source repositories For more details on Go module proxies: https://go.dev/ref/mod#module-proxy Discussion: https://lore.kernel.org/all/CADvTj4pXO2rwJ8oCzzGNY+OxLuo3uJnDT2PAxbyquw0L6dhfiA@mail.gmail.com/T/#t Signed-off-by: James Hilliard Signed-off-by: Christian Stewart --- v1 -> v2: - added more context and links - renamed to GOPROXY instead of GOPROXY_LIST - moved into the !BR2_PRIMARY_SITE_ONLY section --- Config.in | 16 ++++++++++++++++ package/pkg-golang.mk | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Config.in b/Config.in index 37180523c14..583708e2fc2 100644 --- a/Config.in +++ b/Config.in @@ -336,6 +336,22 @@ config BR2_GNU_MIRROR http://ftp.gnu.org/pub/gnu http://mirror.aarnet.edu.au/pub/gnu +config BR2_GOPROXY + string "Go module proxy" + default "https://proxy.golang.org,direct" + depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + help + The Go module proxy URL used to download Go modules. By default, + it uses the official Go module mirror, falling back to direct + downloads if the module is not found in the mirror. + + The value can be one of: + - Comma-separated list of proxy URLs + - "off" to disable all downloads + - "direct" to download directly from source repositories + + See https://go.dev/ref/mod#module-proxy + config BR2_LUAROCKS_MIRROR string "LuaRocks mirror" default "http://rocks.moonscript.org" diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk index ffd50adecce..3e388cb2573 100644 --- a/package/pkg-golang.mk +++ b/package/pkg-golang.mk @@ -101,7 +101,7 @@ $(2)_POST_PATCH_HOOKS += $(2)_GEN_GOMOD $(2)_DOWNLOAD_POST_PROCESS = go $(2)_DL_ENV += \ $$(HOST_GO_COMMON_ENV) \ - GOPROXY=direct \ + GOPROXY=$$(call qstrip,$$(BR2_GOPROXY)) \ $$($(2)_GO_ENV) # If building in a sub directory, do the vendoring in there From 88efd97eefbbfe62ddb2055ed7ada36ab2a59978 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 3 Nov 2025 17:16:44 -0800 Subject: [PATCH 29/39] Config.in: fix help text line length at line 345 Rewrap help text to comply with buildroot requirement of max 62 characters per line in help text. Signed-off-by: Christian Stewart --- Config.in | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Config.in b/Config.in index 583708e2fc2..7c55d78e5d0 100644 --- a/Config.in +++ b/Config.in @@ -341,11 +341,10 @@ config BR2_GOPROXY default "https://proxy.golang.org,direct" depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS help - The Go module proxy URL used to download Go modules. By default, - it uses the official Go module mirror, falling back to direct - downloads if the module is not found in the mirror. - - The value can be one of: + The Go module proxy URL used to download Go modules. By + default, it uses the official Go module mirror, falling + back to direct downloads if the module is not found in the + mirror. The value can be one of: - Comma-separated list of proxy URLs - "off" to disable all downloads - "direct" to download directly from source repositories From 75a3c32c1b86c7d2020162c151d721dab0306e31 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 3 Nov 2025 19:06:36 -0800 Subject: [PATCH 30/39] [SKIFF] package/dbus-forwarding-proxy: new package Signed-off-by: Christian Stewart --- package/Config.in | 1 + package/dbus-forwarding-proxy/Config.in | 16 ++++++++++++++++ .../dbus-forwarding-proxy.hash | 5 +++++ .../dbus-forwarding-proxy.mk | 13 +++++++++++++ 4 files changed, 35 insertions(+) create mode 100644 package/dbus-forwarding-proxy/Config.in create mode 100644 package/dbus-forwarding-proxy/dbus-forwarding-proxy.hash create mode 100644 package/dbus-forwarding-proxy/dbus-forwarding-proxy.mk diff --git a/package/Config.in b/package/Config.in index 8cf7fdb7bd7..a47986cc19a 100644 --- a/package/Config.in +++ b/package/Config.in @@ -483,6 +483,7 @@ endmenu source "package/dbus-broker/Config.in" source "package/dbus-cpp/Config.in" source "package/dbus-cxx/Config.in" + source "package/dbus-forwarding-proxy/Config.in" source "package/dbus-glib/Config.in" source "package/dbus-python/Config.in" source "package/dfu-programmer/Config.in" diff --git a/package/dbus-forwarding-proxy/Config.in b/package/dbus-forwarding-proxy/Config.in new file mode 100644 index 00000000000..1723fe88068 --- /dev/null +++ b/package/dbus-forwarding-proxy/Config.in @@ -0,0 +1,16 @@ +config BR2_PACKAGE_DBUS_FORWARDING_PROXY + bool "dbus-forwarding-proxy" + depends on BR2_USE_WCHAR # libglib2 -> gettext + depends on BR2_TOOLCHAIN_HAS_THREADS # libglib2, systemd + depends on BR2_USE_MMU # libglib2, systemd + depends on !BR2_STATIC_LIBS # systemd + select BR2_PACKAGE_LIBGLIB2 + select BR2_PACKAGE_SYSTEMD + help + D-Bus forwarding proxy for connecting multiple namespaces. + + https://github.com/igo95862/dbus-forwarding-proxy + +comment "dbus-forwarding-proxy needs a toolchain w/ wchar, threads, dynamic library" + depends on BR2_USE_MMU + depends on !BR2_USE_WCHAR || !BR2_TOOLCHAIN_HAS_THREADS || BR2_STATIC_LIBS diff --git a/package/dbus-forwarding-proxy/dbus-forwarding-proxy.hash b/package/dbus-forwarding-proxy/dbus-forwarding-proxy.hash new file mode 100644 index 00000000000..c9a876a30ec --- /dev/null +++ b/package/dbus-forwarding-proxy/dbus-forwarding-proxy.hash @@ -0,0 +1,5 @@ +# Locally computed +sha256 18817f10f114d7c9a2c9f432f96a1c9d7fd7bcb3461c6089f1d5622296f08791 dbus-forwarding-proxy-97fd27e6cad9b2dd4502663667a95e5e7cc887e2.tar.gz + +# Hash for license file: +sha256 fa6f36630bb1e0c571d34b2bbdf188d08495c9dbf58f28cac112f303fc1f58fb LICENSES/LGPL-2.1-or-later.txt diff --git a/package/dbus-forwarding-proxy/dbus-forwarding-proxy.mk b/package/dbus-forwarding-proxy/dbus-forwarding-proxy.mk new file mode 100644 index 00000000000..cd1be95a07c --- /dev/null +++ b/package/dbus-forwarding-proxy/dbus-forwarding-proxy.mk @@ -0,0 +1,13 @@ +################################################################################ +# +# dbus-forwarding-proxy +# +################################################################################ + +DBUS_FORWARDING_PROXY_VERSION = 97fd27e6cad9b2dd4502663667a95e5e7cc887e2 +DBUS_FORWARDING_PROXY_SITE = $(call github,igo95862,dbus-forwarding-proxy,$(DBUS_FORWARDING_PROXY_VERSION)) +DBUS_FORWARDING_PROXY_DEPENDENCIES = host-pkgconf libglib2 systemd +DBUS_FORWARDING_PROXY_LICENSE = LGPL-2.1-or-later +DBUS_FORWARDING_PROXY_LICENSE_FILES = LICENSES/LGPL-2.1-or-later.txt + +$(eval $(meson-package)) From e97e48f93802eb0e8a847820df7648356bfa3c94 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 1 Mar 2026 22:03:04 -0800 Subject: [PATCH 31/39] arch: add wasm32-wasi architecture with wasi-sdk toolchain Add wasm32 (WebAssembly) as a buildroot architecture target using wasi-sdk 30 (clang/LLVM) as the external toolchain. This enables cross-compilation of userspace packages to wasm32-wasi. Architecture support: - Config.in.wasm32: Kconfig definition (little-endian, no MMU) - arch.mk.wasm32: wasi-libc emulation flags (-D_WASI_EMULATED_SIGNAL, -D_WASI_EMULATED_MMAN, etc.), setjmp/longjmp via -mllvm -wasm-enable-sjlj, force-include of wasi-posix-fixups.h - Flags guarded by ifeq ($(BR2_wasm32),y) to avoid leaking into other architecture builds Toolchain (toolchain-external-wasi-sdk): - Downloads wasi-sdk 30 for host arch (x86_64 or aarch64) - Installs wasi-sysroot to staging with symlink conflict resolution - Post-eval overrides: sets CC/CXX/LD to clang, AR/RANLIB to llvm-ar/llvm-ranlib, disables FORTIFY_SOURCE and relro (N/A for WASM) POSIX stub headers (51 files in wasi-stubs/): - wasi-posix-fixups.h (~460 lines): master compatibility header with ~80 POSIX function declarations, struct definitions (sigaction, rlimit, sockaddr_un with sun_path), and constants (signals, socket options, ioctls). Wrapped in #ifndef __ASSEMBLER__ guard. - Stub headers for linux/ (rtnetlink, netlink, capability, if_addr, if_link, if_arp, etc.), net/ (if, route, ethernet), sys/ (epoll, mount, wait, personality, etc.), and top-level (netdb, pwd, grp, termios, syslog, etc.) Busybox linker patch (0015-trylink): - Detects wasm-ld limitations via check_cc tests: --start-group/ --end-group, --warn-common, --verbose, -Map - Follows existing --sort-section/--sort-common detection pattern Replace -mllvm -wasm-enable-sjlj with __wasm_exception_handling__ define in wasi-posix-fixups.h (suppresses setjmp.h errors without requiring LLVM-level sjlj which caused issues). Add __posix_fcntl3 host import declaration so libc.a replacement can forward fcntl calls to the wasivm kernel. Patch wasi-libc static libraries as part of the toolchain install to fix conflicts with the wasivm kernel host imports. Without these patches, wasi-libc maintains internal state (signal handler tables, exit paths, CWD tracking) that bypasses the kernel, causing crashes. libc.a patches: fcntl.c.obj - replaced: forwards to env.__posix_fcntl3 chdir.c.obj - removed: env.chdir handles kernel CWD abort.c.obj - removed: env.abort delivers SIGABRT cleanly exit.c.obj - replaced: fflush(NULL) + env.__posix_exit (vfork-aware) _Exit.c.obj - replaced: env.__posix_exit directly libwasi-emulated-signal.a: signal.c.obj - removed: env.signal/raise/sigaction via kernel Set --export=__errno_location so host runtimes can set errno. Enable BR2_USE_MMU for wasm32 since the wasivm kernel implements vfork/exec. Add ~100 autoconf function cache overrides to TARGET_CONFIGURE_ARGS so configure scripts detect wasi-posix-fixups.h functions correctly despite the type mismatch with autoconf test patterns. Add -L$(STAGING_DIR)/usr/lib to TARGET_LDFLAGS for ncurses. Patch pselect.c.obj in libc.a: the original wasi-libc pselect returns ENOSYS when errorfds is non-empty, breaking any program using select() with exceptfds (standard POSIX pattern for EOF monitoring). The replacement converts fd_sets to pollfd arrays and calls poll(). Add wasi-posix-fixups.h declarations for sigaltstack, sigpending, setitimer/getitimer, killpg, WCOREDUMP, and SO_RCVBUFFORCE/ SO_SNDBUFFORCE socket options needed by vim and ncurses. Tested: busybox 1.37.0 compiles to 71 KB WebAssembly binary with 134 applets. Full buildroot rootfs.tar generated (550 KB). Signed-off-by: Christian Stewart --- arch/Config.in | 19 + arch/Config.in.wasm32 | 11 + arch/arch.mk.wasm32 | 133 +++++ toolchain/toolchain-external/Config.in | 6 + .../pkg-toolchain-external.mk | 6 + .../toolchain-external-wasi-sdk/Config.in | 11 + .../Config.in.options | 15 + .../toolchain-external-wasi-sdk/src/_Exit.c | 9 + .../toolchain-external-wasi-sdk/src/exit.c | 13 + .../toolchain-external-wasi-sdk/src/fcntl.c | 15 + .../toolchain-external-wasi-sdk/src/fstat.c | 51 ++ .../toolchain-external-wasi-sdk/src/fstatat.c | 61 +++ .../toolchain-external-wasi-sdk/src/poll.c | 135 +++++ .../toolchain-external-wasi-sdk/src/pselect.c | 109 ++++ .../toolchain-external-wasi-sdk.hash | 3 + .../toolchain-external-wasi-sdk.mk | 122 +++++ .../wasi-stubs/asm/types.h | 12 + .../wasi-stubs/grp.h | 11 + .../wasi-stubs/linux/capability.h | 37 ++ .../wasi-stubs/linux/fd.h | 16 + .../wasi-stubs/linux/filter.h | 16 + .../wasi-stubs/linux/fs.h | 21 + .../wasi-stubs/linux/hdreg.h | 10 + .../wasi-stubs/linux/i2c.h | 23 + .../wasi-stubs/linux/if_addr.h | 48 ++ .../wasi-stubs/linux/if_arp.h | 17 + .../wasi-stubs/linux/if_link.h | 92 ++++ .../wasi-stubs/linux/if_packet.h | 9 + .../wasi-stubs/linux/if_vlan.h | 35 ++ .../wasi-stubs/linux/loop.h | 41 ++ .../wasi-stubs/linux/netlink.h | 48 ++ .../wasi-stubs/linux/random.h | 13 + .../wasi-stubs/linux/rtnetlink.h | 182 +++++++ .../wasi-stubs/linux/types.h | 11 + .../wasi-stubs/linux/version.h | 5 + .../wasi-stubs/mntent.h | 22 + .../wasi-stubs/net/ethernet.h | 21 + .../wasi-stubs/net/if.h | 112 ++++ .../wasi-stubs/net/if_arp.h | 39 ++ .../wasi-stubs/net/route.h | 41 ++ .../wasi-stubs/netdb.h | 57 ++ .../wasi-stubs/netinet/if_ether.h | 60 +++ .../wasi-stubs/paths.h | 30 ++ .../wasi-stubs/pty.h | 7 + .../wasi-stubs/pwd.h | 15 + .../wasi-stubs/shadow.h | 26 + .../wasi-stubs/sys/epoll.h | 27 + .../wasi-stubs/sys/inotify.h | 26 + .../wasi-stubs/sys/klog.h | 6 + .../wasi-stubs/sys/mount.h | 28 + .../wasi-stubs/sys/personality.h | 8 + .../wasi-stubs/sys/prctl.h | 11 + .../wasi-stubs/sys/reboot.h | 12 + .../wasi-stubs/sys/sendfile.h | 8 + .../wasi-stubs/sys/signalfd.h | 9 + .../wasi-stubs/sys/statfs.h | 26 + .../wasi-stubs/sys/swap.h | 10 + .../wasi-stubs/sys/sysmacros.h | 8 + .../wasi-stubs/sys/timerfd.h | 10 + .../wasi-stubs/sys/vfs.h | 4 + .../wasi-stubs/sys/wait.h | 14 + .../wasi-stubs/sys/xattr.h | 18 + .../wasi-stubs/syslog.h | 41 ++ .../wasi-stubs/termios.h | 161 ++++++ .../wasi-stubs/utmp.h | 20 + .../wasi-stubs/utmpx.h | 22 + .../wasi-stubs/wasi-posix-fixups.h | 495 ++++++++++++++++++ .../wasi-stubs/wordexp.h | 18 + 68 files changed, 2778 insertions(+) create mode 100644 arch/Config.in.wasm32 create mode 100644 arch/arch.mk.wasm32 create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in.options create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/src/_Exit.c create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/src/exit.c create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fcntl.c create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstat.c create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstatat.c create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/src/poll.c create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/src/pselect.c create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.hash create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.mk create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/asm/types.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/grp.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/capability.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fd.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/filter.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fs.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/hdreg.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/i2c.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_addr.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_arp.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_link.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_packet.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_vlan.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/loop.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/netlink.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/random.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/rtnetlink.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/types.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/version.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/mntent.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/ethernet.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if_arp.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/route.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netdb.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netinet/if_ether.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/paths.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pty.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pwd.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/shadow.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/epoll.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/inotify.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/klog.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/mount.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/personality.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/prctl.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/reboot.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sendfile.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/signalfd.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/statfs.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/swap.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sysmacros.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/timerfd.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/vfs.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/wait.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/xattr.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/syslog.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/termios.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmp.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmpx.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wasi-posix-fixups.h create mode 100644 toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wordexp.h diff --git a/arch/Config.in b/arch/Config.in index 863a1eed345..aa104c92e15 100644 --- a/arch/Config.in +++ b/arch/Config.in @@ -266,6 +266,14 @@ config BR2_x86_64 architecture compatible microprocessor). http://en.wikipedia.org/wiki/X86_64 +config BR2_wasm32 + bool "WebAssembly (wasm32)" + select BR2_ARCH_HAS_NO_TOOLCHAIN_BUILDROOT + select BR2_USE_MMU + help + WebAssembly 32-bit target using wasi-sdk external toolchain. + Produces .wasm binaries for WASI-compatible runtimes. + config BR2_xtensa bool "Xtensa" depends on !BR2_HIDE_SECONDARY_TARGET_OPTIONS @@ -464,6 +472,10 @@ if BR2_i386 || BR2_x86_64 source "arch/Config.in.x86" endif +if BR2_wasm32 +source "arch/Config.in.wasm32" +endif + if BR2_xtensa source "arch/Config.in.xtensa" endif @@ -471,6 +483,7 @@ endif # Set up target binary format choice prompt "Target Binary Format" + default BR2_BINFMT_WASM if BR2_wasm32 default BR2_BINFMT_ELF if BR2_USE_MMU default BR2_BINFMT_FLAT @@ -501,6 +514,12 @@ config BR2_BINFMT_FLAT format based on the original a.out format. It is widely used in environment where no MMU is available. +config BR2_BINFMT_WASM + bool "WASM" + depends on BR2_wasm32 + help + WebAssembly binary format. WASM binaries are executed by a + host runtime (e.g. wazero) rather than the OS kernel directly. endchoice endmenu # Target options diff --git a/arch/Config.in.wasm32 b/arch/Config.in.wasm32 new file mode 100644 index 00000000000..75898bd7b78 --- /dev/null +++ b/arch/Config.in.wasm32 @@ -0,0 +1,11 @@ +config BR2_ARCH + default "wasm32" + +config BR2_NORMALIZED_ARCH + default "wasm32" + +config BR2_ENDIAN + default "LITTLE" + +config BR2_READELF_ARCH_NAME + default "WebAssembly" diff --git a/arch/arch.mk.wasm32 b/arch/arch.mk.wasm32 new file mode 100644 index 00000000000..23ad29656d8 --- /dev/null +++ b/arch/arch.mk.wasm32 @@ -0,0 +1,133 @@ +# wasi-libc emulation flags for wasm32-wasi targets. +ifeq ($(BR2_wasm32),y) +ARCH_TOOLCHAIN_WRAPPER_OPTS += \ + -D_WASI_EMULATED_SIGNAL \ + -D_WASI_EMULATED_MMAN \ + -D_WASI_EMULATED_PROCESS_CLOCKS \ + -D_WASI_EMULATED_GETPID \ + -include wasi-posix-fixups.h + +# Export __errno_location so host runtimes can set errno in WASM memory. +# Add usr/lib to search path (wasi-sdk sysroot only has lib/wasm32-wasi). +TARGET_LDFLAGS += -Wl,--export=__errno_location -L$(STAGING_DIR)/usr/lib + +# Autoconf function detection cache overrides for wasm32-wasi. +# +# wasi-posix-fixups.h is force-included via -include into every compilation +# unit, including autoconf test programs. Autoconf detects functions by +# compiling `char FUNC(void); int main() { return FUNC(); }` -- which +# conflicts with the proper prototypes in wasi-posix-fixups.h and the +# wasi-libc headers. Pre-seeding these cache variables tells configure +# the functions exist without running the (broken) compile test. +TARGET_CONFIGURE_ARGS += \ + ac_cv_func__exit=yes \ + ac_cv_func_accept=yes \ + ac_cv_func_access=yes \ + ac_cv_func_bind=yes \ + ac_cv_func_chdir=yes \ + ac_cv_func_chown=yes \ + ac_cv_func_chroot=yes \ + ac_cv_func_clock_gettime=yes \ + ac_cv_func_clock_settime=yes \ + ac_cv_func_connect=yes \ + ac_cv_func_dup=yes \ + ac_cv_func_dup2=yes \ + ac_cv_func_dup3=yes \ + ac_cv_func_execl=yes \ + ac_cv_func_execle=yes \ + ac_cv_func_execlp=yes \ + ac_cv_func_execv=yes \ + ac_cv_func_execve=yes \ + ac_cv_func_execvp=yes \ + ac_cv_func_fchdir=yes \ + ac_cv_func_fchown=yes \ + ac_cv_func_fork=yes \ + ac_cv_func_fpathconf=yes \ + ac_cv_func_ftruncate=yes \ + ac_cv_func_getcwd=yes \ + ac_cv_func_getegid=yes \ + ac_cv_func_geteuid=yes \ + ac_cv_func_getgid=yes \ + ac_cv_func_getgroups=yes \ + ac_cv_func_gethostname=yes \ + ac_cv_func_getpeername=yes \ + ac_cv_func_getpgid=yes \ + ac_cv_func_getpgrp=yes \ + ac_cv_func_getppid=yes \ + ac_cv_func_getpriority=yes \ + ac_cv_func_getrlimit=yes \ + ac_cv_func_getsid=yes \ + ac_cv_func_getsockname=yes \ + ac_cv_func_getsockopt=yes \ + ac_cv_func_gettimeofday=yes \ + ac_cv_func_getuid=yes \ + ac_cv_func_initgroups=yes \ + ac_cv_func_isatty=yes \ + ac_cv_func_kill=yes \ + ac_cv_func_killpg=yes \ + ac_cv_func_lchown=yes \ + ac_cv_func_link=yes \ + ac_cv_func_listen=yes \ + ac_cv_func_mkdtemp=yes \ + ac_cv_func_mkfifo=yes \ + ac_cv_func_mknod=yes \ + ac_cv_func_mkstemp=yes \ + ac_cv_func_nice=yes \ + ac_cv_func_pathconf=yes \ + ac_cv_func_pause=yes \ + ac_cv_func_pipe=yes \ + ac_cv_func_pipe2=yes \ + ac_cv_func_readlink=yes \ + ac_cv_func_recv=yes \ + ac_cv_func_recvfrom=yes \ + ac_cv_func_select=yes \ + ac_cv_func_send=yes \ + ac_cv_func_sendto=yes \ + ac_cv_func_setegid=yes \ + ac_cv_func_seteuid=yes \ + ac_cv_func_setgid=yes \ + ac_cv_func_setgroups=yes \ + ac_cv_func_sethostname=yes \ + ac_cv_func_setpgid=yes \ + ac_cv_func_setpgrp=yes \ + ac_cv_func_setpriority=yes \ + ac_cv_func_setregid=yes \ + ac_cv_func_setreuid=yes \ + ac_cv_func_setrlimit=yes \ + ac_cv_func_setsid=yes \ + ac_cv_func_setsockopt=yes \ + ac_cv_func_settimeofday=yes \ + ac_cv_func_setuid=yes \ + ac_cv_func_shutdown=yes \ + ac_cv_func_sigaction=yes \ + ac_cv_func_sigaddset=yes \ + ac_cv_func_sigdelset=yes \ + ac_cv_func_sigemptyset=yes \ + ac_cv_func_sigfillset=yes \ + ac_cv_func_sigismember=yes \ + ac_cv_func_sigpending=yes \ + ac_cv_func_sigprocmask=yes \ + ac_cv_func_sigaltstack=yes \ + ac_cv_func_setitimer=yes \ + ac_cv_func_getitimer=yes \ + ac_cv_func_socket=yes \ + ac_cv_func_symlink=yes \ + ac_cv_func_sync=yes \ + ac_cv_func_sysconf=yes \ + ac_cv_func_tcgetpgrp=yes \ + ac_cv_func_tcsetpgrp=yes \ + ac_cv_func_truncate=yes \ + ac_cv_func_ttyname=yes \ + ac_cv_func_ttyname_r=yes \ + ac_cv_func_tzset=yes \ + ac_cv_func_umask=yes \ + ac_cv_func_vfork=yes \ + ac_cv_func_wait=yes \ + ac_cv_func_waitpid=yes + +# Functions falsely detected due to -Wl,--allow-undefined (link always +# succeeds). These do NOT exist in wasi-libc or our host imports. +TARGET_CONFIGURE_ARGS += \ + ac_cv_func_tcgetwinsize=no \ + ac_cv_func_tcsetwinsize=no +endif diff --git a/toolchain/toolchain-external/Config.in b/toolchain/toolchain-external/Config.in index 831387bc4ed..ddf1d5586fc 100644 --- a/toolchain/toolchain-external/Config.in +++ b/toolchain/toolchain-external/Config.in @@ -23,6 +23,9 @@ source "toolchain/toolchain-external/toolchain-external-arm-arm/Config.in" # Bootlin toolchains, available for virtually all architectures source "toolchain/toolchain-external/toolchain-external-bootlin/Config.in" +# WebAssembly (wasi-sdk) +source "toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in" + # Kept last, so it remains the non-default choice, unless there isn't # any available toolchain profile for the currently selected # architecture, but before toolchains from br2-external trees. @@ -111,6 +114,9 @@ source "toolchain/toolchain-external/toolchain-external-arm-arm/Config.in.option # Bootlin toolchains source "toolchain/toolchain-external/toolchain-external-bootlin/Config.in.options" +# WebAssembly (wasi-sdk) +source "toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in.options" + # Custom toolchains source "toolchain/toolchain-external/toolchain-external-custom/Config.in.options" diff --git a/toolchain/toolchain-external/pkg-toolchain-external.mk b/toolchain/toolchain-external/pkg-toolchain-external.mk index 270cf814ed7..b7811a2aaf9 100644 --- a/toolchain/toolchain-external/pkg-toolchain-external.mk +++ b/toolchain/toolchain-external/pkg-toolchain-external.mk @@ -97,6 +97,12 @@ TOOLCHAIN_EXTERNAL_GDC = $(TOOLCHAIN_EXTERNAL_CROSS)gdc$(TOOLCHAIN_EXTERNAL_SUFF TOOLCHAIN_EXTERNAL_FC = $(TOOLCHAIN_EXTERNAL_CROSS)gfortran$(TOOLCHAIN_EXTERNAL_SUFFIX) TOOLCHAIN_EXTERNAL_READELF = $(TOOLCHAIN_EXTERNAL_CROSS)readelf +# For wasm32 (wasi-sdk), use clang instead of gcc. +ifeq ($(BR2_wasm32),y) +TOOLCHAIN_EXTERNAL_CC = $(TOOLCHAIN_EXTERNAL_CROSS)clang +TOOLCHAIN_EXTERNAL_CXX = $(TOOLCHAIN_EXTERNAL_CROSS)clang++ +endif + # Normal handling of downloaded toolchain tarball extraction. ifeq ($(BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD),y) # As a regular package, the toolchain gets extracted in $(@D), but diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in b/toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in new file mode 100644 index 00000000000..c00b7413266 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in @@ -0,0 +1,11 @@ +config BR2_TOOLCHAIN_EXTERNAL_WASI_SDK + bool "wasi-sdk 30" + depends on BR2_wasm32 + depends on BR2_HOSTARCH = "x86_64" || BR2_HOSTARCH = "aarch64" + select BR2_TOOLCHAIN_EXTERNAL_MUSL + select BR2_TOOLCHAIN_HAS_NO_GDBSERVER + help + wasi-sdk toolchain for WebAssembly (wasm32-wasi) targets. + Based on Clang/LLVM with wasi-libc (musl-based). + + https://github.com/WebAssembly/wasi-sdk diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in.options b/toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in.options new file mode 100644 index 00000000000..435a0b0a6c7 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/Config.in.options @@ -0,0 +1,15 @@ +if BR2_TOOLCHAIN_EXTERNAL_WASI_SDK + +config BR2_TOOLCHAIN_EXTERNAL_PREFIX + default "wasm32-wasi" + +config BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX + default "wasm32-wasi" + +config BR2_PACKAGE_PROVIDES_TOOLCHAIN_EXTERNAL + default "toolchain-external-wasi-sdk" + +config BR2_TOOLCHAIN_EXTERNAL_HAS_NO_GDBSERVER + default y + +endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/_Exit.c b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/_Exit.c new file mode 100644 index 00000000000..ed8700770e3 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/_Exit.c @@ -0,0 +1,9 @@ +// Replacement _Exit that calls the wasivm kernel host import directly. +// Skips atexit handlers per POSIX but must still be vfork-aware. + +extern void __posix_exit(int status) __attribute__((noreturn)); + +void _Exit(int status) { + __posix_exit(status); + __builtin_unreachable(); +} diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/exit.c b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/exit.c new file mode 100644 index 00000000000..3040f4be093 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/exit.c @@ -0,0 +1,13 @@ +// Replacement exit that flushes stdio then calls the wasivm kernel +// host import. wasi-libc's exit calls __wasi_proc_exit directly, +// bypassing the kernel's vfork-aware exit handling. + +typedef struct __FILE FILE; +extern int fflush(FILE *); +extern void __posix_exit(int status) __attribute__((noreturn)); + +void exit(int status) { + fflush((FILE *)0); + __posix_exit(status); + __builtin_unreachable(); +} diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fcntl.c b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fcntl.c new file mode 100644 index 00000000000..2b9dfc86a36 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fcntl.c @@ -0,0 +1,15 @@ +// Replacement fcntl that forwards to the wasivm kernel host import. +// wasi-libc's fcntl only handles F_GETFL/F_SETFL and returns EINVAL +// for F_DUPFD and others needed by busybox job control. + +#include + +extern int __posix_fcntl3(int fd, int cmd, int arg); + +int fcntl(int fd, int cmd, ...) { + __builtin_va_list ap; + __builtin_va_start(ap, cmd); + int arg = __builtin_va_arg(ap, int); + __builtin_va_end(ap); + return __posix_fcntl3(fd, cmd, arg); +} diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstat.c b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstat.c new file mode 100644 index 00000000000..6e1fd6c242a --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstat.c @@ -0,0 +1,51 @@ +// Replacement fstat that adds default permissions and st_blocks. +// Same rationale as fstatat.c but for file descriptor stat. + +#include +#include +#include + +int fstat(int fildes, struct stat *buf) { + __wasi_filestat_t st; + __wasi_errno_t error = __wasi_fd_filestat_get(fildes, &st); + if (error != 0) { + errno = error; + return -1; + } + *buf = (struct stat){ + .st_dev = st.dev, + .st_ino = st.ino, + .st_nlink = st.nlink, + .st_size = st.size, + .st_atim = {.tv_sec = st.atim / 1000000000ULL, + .tv_nsec = st.atim % 1000000000ULL}, + .st_mtim = {.tv_sec = st.mtim / 1000000000ULL, + .tv_nsec = st.mtim % 1000000000ULL}, + .st_ctim = {.tv_sec = st.ctim / 1000000000ULL, + .tv_nsec = st.ctim % 1000000000ULL}, + .st_blksize = 4096, + }; + switch (st.filetype) { + case __WASI_FILETYPE_BLOCK_DEVICE: + break; + case __WASI_FILETYPE_CHARACTER_DEVICE: + buf->st_mode |= S_IFCHR; + break; + case __WASI_FILETYPE_DIRECTORY: + buf->st_mode |= S_IFDIR; + break; + case __WASI_FILETYPE_REGULAR_FILE: + buf->st_mode |= S_IFREG; + break; + case __WASI_FILETYPE_SOCKET_DGRAM: + case __WASI_FILETYPE_SOCKET_STREAM: + buf->st_mode |= S_IFSOCK; + break; + case __WASI_FILETYPE_SYMBOLIC_LINK: + buf->st_mode |= S_IFLNK; + break; + } + buf->st_mode |= 0755; + buf->st_blocks = (buf->st_size + 511) / 512; + return 0; +} diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstatat.c b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstatat.c new file mode 100644 index 00000000000..d19f7e0fa8a --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/fstatat.c @@ -0,0 +1,61 @@ +// Replacement fstatat that adds default permissions and st_blocks. +// +// WASI's __wasi_filestat_t has no permission bits, st_blocks, or +// st_blksize. wasi-libc's to_public_stat() only sets file type bits, +// leaving mode as 0 (shown as "----------" by ls). This replacement +// adds 0755 default permissions and calculates st_blocks from st_size. + +#include +#include +#include +#include + +int __wasilibc_nocwd_fstatat(int fd, const char *restrict path, + struct stat *restrict buf, int flag) { + __wasi_lookupflags_t lookup_flags = 0; + if ((flag & AT_SYMLINK_NOFOLLOW) == 0) + lookup_flags |= __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW; + __wasi_filestat_t st; + __wasi_errno_t error = + __wasi_path_filestat_get(fd, lookup_flags, path, &st); + if (error != 0) { + errno = error; + return -1; + } + *buf = (struct stat){ + .st_dev = st.dev, + .st_ino = st.ino, + .st_nlink = st.nlink, + .st_size = st.size, + .st_atim = {.tv_sec = st.atim / 1000000000ULL, + .tv_nsec = st.atim % 1000000000ULL}, + .st_mtim = {.tv_sec = st.mtim / 1000000000ULL, + .tv_nsec = st.mtim % 1000000000ULL}, + .st_ctim = {.tv_sec = st.ctim / 1000000000ULL, + .tv_nsec = st.ctim % 1000000000ULL}, + .st_blksize = 4096, + }; + switch (st.filetype) { + case __WASI_FILETYPE_BLOCK_DEVICE: + break; + case __WASI_FILETYPE_CHARACTER_DEVICE: + buf->st_mode |= S_IFCHR; + break; + case __WASI_FILETYPE_DIRECTORY: + buf->st_mode |= S_IFDIR; + break; + case __WASI_FILETYPE_REGULAR_FILE: + buf->st_mode |= S_IFREG; + break; + case __WASI_FILETYPE_SOCKET_DGRAM: + case __WASI_FILETYPE_SOCKET_STREAM: + buf->st_mode |= S_IFSOCK; + break; + case __WASI_FILETYPE_SYMBOLIC_LINK: + buf->st_mode |= S_IFLNK; + break; + } + buf->st_mode |= 0755; + buf->st_blocks = (buf->st_size + 511) / 512; + return 0; +} diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/poll.c b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/poll.c new file mode 100644 index 00000000000..5646ce21cff --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/poll.c @@ -0,0 +1,135 @@ +// Replacement poll with POLLPRI handling for WASI. +// +// WASI has no out-of-band data, so POLLPRI can never fire. If all fds +// exclusively request POLLPRI, return ENOSYS since there is nothing +// useful to wait on. Otherwise strip POLLPRI and proceed normally. +// +// Upstream fix: https://github.com/WebAssembly/wasi-libc/pull/754 + +#include +#include +#include +#include + +// POLLPRI is not in wasi-libc headers (no OOB data in WASI). +#ifndef POLLPRI +#define POLLPRI 0x0200 +#endif + +int poll(struct pollfd *fds, nfds_t nfds, int timeout) { + size_t maxevents = 2 * nfds + 1; + __wasi_subscription_t subscriptions[maxevents]; + size_t nsubscriptions = 0; + + // Check if POLLPRI is the only event requested across all fds. + { + bool has_pri_only = false; + bool has_non_pri = false; + for (size_t i = 0; i < nfds; ++i) { + if (fds[i].fd < 0 || fds[i].events == 0) + continue; + if (fds[i].events & ~POLLPRI) + has_non_pri = true; + else + has_pri_only = true; + } + if (has_pri_only && !has_non_pri) { + errno = ENOSYS; + return -1; + } + } + + for (size_t i = 0; i < nfds; ++i) { + struct pollfd *pollfd = &fds[i]; + if (pollfd->fd < 0) + continue; + // Strip POLLPRI; it is never reported in WASI. + short events = pollfd->events & ~POLLPRI; + bool created_events = false; + if ((events & POLLRDNORM) != 0) { + __wasi_subscription_t *s = &subscriptions[nsubscriptions++]; + *s = (__wasi_subscription_t){ + .userdata = (uintptr_t)pollfd, + .u.tag = __WASI_EVENTTYPE_FD_READ, + .u.u.fd_read.file_descriptor = pollfd->fd, + }; + created_events = true; + } + if ((events & POLLWRNORM) != 0) { + __wasi_subscription_t *s = &subscriptions[nsubscriptions++]; + *s = (__wasi_subscription_t){ + .userdata = (uintptr_t)pollfd, + .u.tag = __WASI_EVENTTYPE_FD_WRITE, + .u.u.fd_write.file_descriptor = pollfd->fd, + }; + created_events = true; + } + // Entries with only POLLPRI (stripped above) produce no + // subscriptions; skip them silently. + if (!created_events && events != 0) { + errno = ENOSYS; + return -1; + } + } + + if (timeout >= 0) { + __wasi_subscription_t *s = &subscriptions[nsubscriptions++]; + *s = (__wasi_subscription_t){ + .u.tag = __WASI_EVENTTYPE_CLOCK, + .u.u.clock.id = __WASI_CLOCKID_REALTIME, + .u.u.clock.timeout = (__wasi_timestamp_t)timeout * 1000000, + }; + } + + size_t nevents; + __wasi_event_t events[nsubscriptions]; + __wasi_errno_t error = + __wasi_poll_oneoff(subscriptions, events, nsubscriptions, &nevents); + if (error != 0) { + if (nsubscriptions == 0) + errno = ENOTSUP; + else + errno = error; + return -1; + } + + for (size_t i = 0; i < nfds; ++i) + fds[i].revents = 0; + + for (size_t i = 0; i < nevents; ++i) { + const __wasi_event_t *event = &events[i]; + if (event->type == __WASI_EVENTTYPE_FD_READ || + event->type == __WASI_EVENTTYPE_FD_WRITE) { + struct pollfd *pollfd = + (struct pollfd *)(uintptr_t)event->userdata; + if (event->error == __WASI_ERRNO_BADF) + pollfd->revents |= POLLNVAL; + else if (event->error == __WASI_ERRNO_PIPE) + pollfd->revents |= POLLHUP; + else if (event->error != 0) + pollfd->revents |= POLLERR; + else { + if (event->type == __WASI_EVENTTYPE_FD_READ) { + pollfd->revents |= POLLRDNORM; + if (event->fd_readwrite.flags & + __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) + pollfd->revents |= POLLHUP; + } else { + pollfd->revents |= POLLWRNORM; + if (event->fd_readwrite.flags & + __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) + pollfd->revents |= POLLHUP; + } + } + } + } + + int retval = 0; + for (size_t i = 0; i < nfds; ++i) { + if ((fds[i].revents & POLLHUP) != 0) + fds[i].revents &= ~POLLWRNORM; + if (fds[i].revents != 0) + ++retval; + } + return retval; +} diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/pselect.c b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/pselect.c new file mode 100644 index 00000000000..606b77e5141 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/src/pselect.c @@ -0,0 +1,109 @@ +// Replacement pselect that threads errorfds through poll as POLLPRI. +// +// WASI has no out-of-band data, so POLLPRI never fires. But pselect +// should not fail when errorfds is provided alongside other fd sets. +// errorfds entries become POLLPRI poll requests; poll() strips POLLPRI +// when other events are present, returns ENOSYS when POLLPRI-only. +// +// Uses inline timeout conversion to avoid internal wasi-libc headers. +// +// Upstream fix: https://github.com/WebAssembly/wasi-libc/pull/754 + +#include +#include +#include +#include +#include + +#ifndef POLLPRI +#define POLLPRI 0x0200 +#endif + +int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, + fd_set *restrict errorfds, const struct timespec *restrict timeout, + const sigset_t *sigmask) { + if (nfds < 0) { + errno = EINVAL; + return -1; + } + + fd_set empty; + FD_ZERO(&empty); + if (readfds == NULL) + readfds = ∅ + if (writefds == NULL) + writefds = ∅ + if (errorfds == NULL) + errorfds = ∅ + + struct pollfd pfds[readfds->__nfds + writefds->__nfds + errorfds->__nfds]; + size_t npfds = 0; + + for (size_t i = 0; i < readfds->__nfds; ++i) { + int fd = readfds->__fds[i]; + if (fd < nfds) { + pfds[npfds].fd = fd; + pfds[npfds].events = POLLRDNORM; + pfds[npfds].revents = 0; + npfds++; + } + } + size_t read_count = npfds; + + for (size_t i = 0; i < writefds->__nfds; ++i) { + int fd = writefds->__fds[i]; + if (fd < nfds) { + pfds[npfds].fd = fd; + pfds[npfds].events = POLLWRNORM; + pfds[npfds].revents = 0; + npfds++; + } + } + size_t write_end = npfds; + + for (size_t i = 0; i < errorfds->__nfds; ++i) { + int fd = errorfds->__fds[i]; + if (fd < nfds) { + pfds[npfds].fd = fd; + pfds[npfds].events = POLLPRI; + pfds[npfds].revents = 0; + npfds++; + } + } + + int poll_timeout; + if (timeout) { + long long ns = + (long long)timeout->tv_sec * 1000000000LL + timeout->tv_nsec; + if (ns < 0) { + errno = EINVAL; + return -1; + } + long long ms = ns / 1000000; + poll_timeout = (ms > INT_MAX) ? INT_MAX : (int)ms; + } else { + poll_timeout = -1; + } + + if (poll(pfds, npfds, poll_timeout) < 0) + return -1; + + FD_ZERO(readfds); + FD_ZERO(writefds); + FD_ZERO(errorfds); + for (size_t i = 0; i < npfds; ++i) { + struct pollfd *pfd = pfds + i; + if (i < read_count) { + if ((pfd->revents & (POLLRDNORM | POLLIN | POLLHUP | POLLERR)) != 0) + readfds->__fds[readfds->__nfds++] = pfd->fd; + } else if (i < write_end) { + if ((pfd->revents & (POLLWRNORM | POLLOUT | POLLERR)) != 0) + writefds->__fds[writefds->__nfds++] = pfd->fd; + } else { + if ((pfd->revents & POLLPRI) != 0) + errorfds->__fds[errorfds->__nfds++] = pfd->fd; + } + } + + return readfds->__nfds + writefds->__nfds + errorfds->__nfds; +} diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.hash b/toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.hash new file mode 100644 index 00000000000..9a416fc0247 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.hash @@ -0,0 +1,3 @@ +# Locally computed +sha256 0507679dff16814b74516cd969a9b16d2ced1347388024bc7966264648c78bfb wasi-sdk-30.0-x86_64-linux.tar.gz +sha256 6f2977942308d91b0123978da3c6a0d6fce780994b3b020008c617e26764ea40 wasi-sdk-30.0-arm64-linux.tar.gz diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.mk b/toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.mk new file mode 100644 index 00000000000..3c2321142b0 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/toolchain-external-wasi-sdk.mk @@ -0,0 +1,122 @@ +################################################################################ +# +# toolchain-external-wasi-sdk +# +################################################################################ + +TOOLCHAIN_EXTERNAL_WASI_SDK_VERSION = 30.0 +TOOLCHAIN_EXTERNAL_WASI_SDK_SITE = https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-30 +TOOLCHAIN_EXTERNAL_WASI_SDK_PKGDIR = toolchain/toolchain-external/toolchain-external-wasi-sdk + +ifeq ($(HOSTARCH),aarch64) +TOOLCHAIN_EXTERNAL_WASI_SDK_SOURCE = wasi-sdk-$(TOOLCHAIN_EXTERNAL_WASI_SDK_VERSION)-arm64-linux.tar.gz +else +TOOLCHAIN_EXTERNAL_WASI_SDK_SOURCE = wasi-sdk-$(TOOLCHAIN_EXTERNAL_WASI_SDK_VERSION)-x86_64-linux.tar.gz +endif + +TOOLCHAIN_EXTERNAL_WASI_SDK_STRIP_COMPONENTS = 1 + +# Create GCC-compatible symlinks in the extract dir so they get moved +# along with everything else by TOOLCHAIN_EXTERNAL_MOVE. +define TOOLCHAIN_EXTERNAL_WASI_SDK_CREATE_SYMLINKS + cd $(@D)/bin && \ + for tool in gcc cc; do \ + ln -sf wasm32-wasi-clang wasm32-wasi-$$tool; \ + done && \ + for tool in g++ c++; do \ + ln -sf wasm32-wasi-clang++ wasm32-wasi-$$tool; \ + done && \ + for tool in ar nm objcopy objdump ranlib strip size strings readelf; do \ + [ -f llvm-$$tool ] && ln -sf llvm-$$tool wasm32-wasi-$$tool || \ + [ -f $$tool ] && ln -sf $$tool wasm32-wasi-$$tool || true; \ + done && \ + ln -sf wasm-ld wasm32-wasi-ld && \ + ln -sf clang wasm32-wasi-cpp +endef +TOOLCHAIN_EXTERNAL_WASI_SDK_POST_EXTRACT_HOOKS += TOOLCHAIN_EXTERNAL_WASI_SDK_CREATE_SYMLINKS + +$(eval $(toolchain-external-package)) + +# Override commands generated by toolchain-external-package. +# The stock commands perform GCC-specific validation (gcc --version, +# kernel headers, musl version, SSP) and install GCC sysroot layouts. +# For wasi-sdk (clang-based), we only verify the cross-compiler exists +# and copy the wasi-sysroot. + +define TOOLCHAIN_EXTERNAL_WASI_SDK_CONFIGURE_CMDS + $(Q)$(call check_cross_compiler_exists,$(TOOLCHAIN_EXTERNAL_CC)) +endef + +define TOOLCHAIN_EXTERNAL_WASI_SDK_BUILD_CMDS + $(TOOLCHAIN_WRAPPER_BUILD) +endef + +# Install wasi-sysroot into staging. The skeleton creates lib/bin/sbin +# as symlinks to usr/*, but wasi-sysroot has real lib/ and include/ +# directories. Remove conflicting symlinks before copying. Then install +# POSIX stub headers for APIs not in wasi-libc (netdb, pwd, grp, etc.) +# so packages like busybox can compile. +# +# After sysroot install, patch libc.a and libwasi-emulated-signal.a to +# remove/replace objects that conflict with the wasivm kernel host imports. +# Without these patches, wasi-libc maintains internal state (signal +# handlers, exit paths, CWD tracking) that bypasses the kernel. +define TOOLCHAIN_EXTERNAL_WASI_SDK_INSTALL_STAGING_CMDS + $(TOOLCHAIN_WRAPPER_INSTALL) + $(Q)for d in lib include share; do \ + if [ -L $(STAGING_DIR)/$$d ]; then rm -f $(STAGING_DIR)/$$d; fi; \ + done + $(Q)cp -a $(TOOLCHAIN_EXTERNAL_INSTALL_DIR)/share/wasi-sysroot/* $(STAGING_DIR)/ + $(Q)cp -a $(TOPDIR)/$(TOOLCHAIN_EXTERNAL_WASI_SDK_PKGDIR)/wasi-stubs/* \ + $(STAGING_DIR)/include/wasm32-wasi/ + $(TOOLCHAIN_EXTERNAL_INSTALL_WRAPPER) + $(call wasi_sdk_patch_libc) +endef + +define TOOLCHAIN_EXTERNAL_WASI_SDK_INSTALL_TARGET_CMDS +endef + +# Patch wasi-libc static libraries for wasivm kernel compatibility. +# Replacement C sources live in src/ next to this .mk file. +# +# libc.a replacements: +# fcntl.c - forwards to env.__posix_fcntl3 +# exit.c - fflush(NULL) + env.__posix_exit (vfork-aware) +# _Exit.c - env.__posix_exit directly +# poll.c - handle POLLPRI gracefully (strip or ENOSYS) +# pselect.c - thread errorfds through poll as POLLPRI +# fstatat.c - add 0755 permissions + st_blocks +# fstat.c - add 0755 permissions + st_blocks +# +# libc.a removals (resolved as env.* host imports): +# chdir.c.obj - env.chdir handles kernel CWD +# abort.c.obj - env.abort delivers SIGABRT cleanly +# +# libwasi-emulated-signal.a removals: +# signal.c.obj - env.signal/raise/sigaction via kernel + +WASI_SDK_PATCH_SRCDIR = $(TOPDIR)/$(TOOLCHAIN_EXTERNAL_WASI_SDK_PKGDIR)/src +WASI_SDK_PATCH_OBJS = fcntl exit _Exit poll pselect fstatat fstat + +define wasi_sdk_patch_libc + $(Q)WASI_LIBC=$(STAGING_DIR)/lib/wasm32-wasi/libc.a; \ + WASI_SIGLIB=$(STAGING_DIR)/lib/wasm32-wasi/libwasi-emulated-signal.a; \ + TMPDIR=$$(mktemp -d); \ + for src in $(WASI_SDK_PATCH_OBJS); do \ + $(TARGET_CC) -c -O2 \ + -o $$TMPDIR/$$src.c.obj \ + $(WASI_SDK_PATCH_SRCDIR)/$$src.c; \ + done; \ + if [ ! -f "$$WASI_LIBC.orig" ]; then cp "$$WASI_LIBC" "$$WASI_LIBC.orig"; fi; \ + for src in $(WASI_SDK_PATCH_OBJS); do \ + $(TARGET_AR) d "$$WASI_LIBC" $$src.c.obj 2>/dev/null || true; \ + $(TARGET_AR) r "$$WASI_LIBC" $$TMPDIR/$$src.c.obj; \ + done; \ + $(TARGET_AR) d "$$WASI_LIBC" chdir.c.obj 2>/dev/null || true; \ + $(TARGET_AR) d "$$WASI_LIBC" abort.c.obj 2>/dev/null || true; \ + if [ -f "$$WASI_SIGLIB" ]; then \ + if [ ! -f "$$WASI_SIGLIB.orig" ]; then cp "$$WASI_SIGLIB" "$$WASI_SIGLIB.orig"; fi; \ + $(TARGET_AR) d "$$WASI_SIGLIB" signal.c.obj 2>/dev/null || true; \ + fi; \ + rm -rf $$TMPDIR +endef diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/asm/types.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/asm/types.h new file mode 100644 index 00000000000..1c43b59e6c6 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/asm/types.h @@ -0,0 +1,12 @@ +#ifndef _ASM_TYPES_H +#define _ASM_TYPES_H +#include +typedef uint8_t __u8; +typedef uint16_t __u16; +typedef uint32_t __u32; +typedef uint64_t __u64; +typedef int8_t __s8; +typedef int16_t __s16; +typedef int32_t __s32; +typedef int64_t __s64; +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/grp.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/grp.h new file mode 100644 index 00000000000..7ee32bb8ff5 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/grp.h @@ -0,0 +1,11 @@ +#ifndef _GRP_H +#define _GRP_H +#include +struct group { char *gr_name; char *gr_passwd; gid_t gr_gid; char **gr_mem; }; +struct group *getgrnam(const char *); +struct group *getgrgid(gid_t); +int getgrouplist(const char *, gid_t, gid_t *, int *); +struct group *getgrent(void); +void setgrent(void); +void endgrent(void); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/capability.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/capability.h new file mode 100644 index 00000000000..21920e984ad --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/capability.h @@ -0,0 +1,37 @@ +#ifndef _LINUX_CAPABILITY_H +#define _LINUX_CAPABILITY_H +#include +#define _LINUX_CAPABILITY_VERSION_1 0x19980330 +#define _LINUX_CAPABILITY_U32S_1 1 +#define _LINUX_CAPABILITY_VERSION_2 0x20071026 +#define _LINUX_CAPABILITY_U32S_2 2 +#define _LINUX_CAPABILITY_VERSION_3 0x20080522 +#define _LINUX_CAPABILITY_U32S_3 2 +struct __user_cap_header_struct { uint32_t version; int pid; }; +typedef struct __user_cap_header_struct *cap_user_header_t; +struct __user_cap_data_struct { uint32_t effective; uint32_t permitted; uint32_t inheritable; }; +typedef struct __user_cap_data_struct *cap_user_data_t; +int capget(cap_user_header_t hdrp, cap_user_data_t datap); +int capset(cap_user_header_t hdrp, const cap_user_data_t datap); +#define CAP_CHOWN 0 +#define CAP_DAC_OVERRIDE 1 +#define CAP_DAC_READ_SEARCH 2 +#define CAP_FOWNER 3 +#define CAP_FSETID 4 +#define CAP_KILL 5 +#define CAP_SETGID 6 +#define CAP_SETUID 7 +#define CAP_SETPCAP 8 +#define CAP_NET_BIND_SERVICE 10 +#define CAP_NET_RAW 13 +#define CAP_SYS_CHROOT 18 +#define CAP_SYS_ADMIN 21 +#define CAP_SYS_RESOURCE 24 +#define CAP_LAST_CAP 40 +#define cap_valid(x) ((x) >= 0 && (x) <= CAP_LAST_CAP) +/* cap_name_count placeholder for busybox */ + +#define CAP_TO_INDEX(x) ((x) >> 5) +#define CAP_TO_MASK(x) (1 << ((x) & 31)) + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fd.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fd.h new file mode 100644 index 00000000000..cb3ba4f1d28 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fd.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_FD_H +#define _LINUX_FD_H +#define FDGETPRM 0x0204 +struct floppy_struct { + unsigned int size; + unsigned int sect; + unsigned int head; + unsigned int track; + unsigned int stretch; + unsigned char gap; + unsigned char rate; + unsigned char spec1; + unsigned char fmt_gap; + const char *name; +}; +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/filter.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/filter.h new file mode 100644 index 00000000000..d2af49e9f7c --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/filter.h @@ -0,0 +1,16 @@ +#ifndef _LINUX_FILTER_H +#define _LINUX_FILTER_H +#include +struct sock_filter { __u16 code; __u8 jt; __u8 jf; __u32 k; }; +struct sock_fprog { unsigned short len; struct sock_filter *filter; }; +#define BPF_LD 0x00 +#define BPF_JMP 0x05 +#define BPF_RET 0x06 +#define BPF_ABS 0x20 +#define BPF_K 0x00 +#define BPF_JEQ 0x10 +#define BPF_W 0x00 +#define BPF_H 0x08 +#define BPF_B 0x10 +#define SO_ATTACH_FILTER 26 +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fs.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fs.h new file mode 100644 index 00000000000..d927d814fa5 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/fs.h @@ -0,0 +1,21 @@ +#ifndef _LINUX_FS_H +#define _LINUX_FS_H +#define BLKROSET _IO(0x12, 93) +#define BLKROGET _IO(0x12, 94) +#define BLKRRPART _IO(0x12, 95) +#define BLKGETSIZE _IO(0x12, 96) +#define BLKFLSBUF _IO(0x12, 97) +#define BLKSSZGET _IO(0x12, 104) +#define BLKGETSIZE64 _IOR(0x12, 114, size_t) +#ifndef _IO +#define _IO(type, nr) (((type) << 8) | (nr)) +#define _IOR(type, nr, sz) (((type) << 8) | (nr)) +#define _IOW(type, nr, sz) (((type) << 8) | (nr)) +#define _IOWR(type, nr, sz) (((type) << 8) | (nr)) +#endif +#define MS_RDONLY 1 +#define MS_NOSUID 2 +#define MS_NODEV 4 +#define RENAME_NOREPLACE (1 << 0) +#define RENAME_EXCHANGE (1 << 1) +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/hdreg.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/hdreg.h new file mode 100644 index 00000000000..72c8482a582 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/hdreg.h @@ -0,0 +1,10 @@ +#ifndef _LINUX_HDREG_H +#define _LINUX_HDREG_H +#define HDIO_GETGEO 0x0301 +struct hd_geometry { + unsigned char heads; + unsigned char sectors; + unsigned short cylinders; + unsigned long start; +}; +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/i2c.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/i2c.h new file mode 100644 index 00000000000..20e42b5793a --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/i2c.h @@ -0,0 +1,23 @@ +#ifndef _LINUX_I2C_H +#define _LINUX_I2C_H +#include +#define I2C_SLAVE 0x0703 +#define I2C_SLAVE_FORCE 0x0706 +#define I2C_FUNCS 0x0705 +#define I2C_RDWR 0x0707 +#define I2C_SMBUS 0x0720 +#define I2C_M_RD 0x0001 +#define I2C_M_TEN 0x0010 +#define I2C_FUNC_I2C 0x00000001 +#define I2C_FUNC_10BIT_ADDR 0x00000002 +#define I2C_FUNC_SMBUS_READ_BYTE 0x00020000 +#define I2C_FUNC_SMBUS_WRITE_BYTE 0x00040000 +#define I2C_SMBUS_BYTE 1 +#define I2C_SMBUS_BYTE_DATA 2 +#define I2C_SMBUS_WORD_DATA 3 +#define I2C_SMBUS_BLOCK_DATA 5 +#define I2C_SMBUS_I2C_BLOCK_DATA 8 +#define I2C_SMBUS_READ 1 +#define I2C_SMBUS_WRITE 0 +struct i2c_msg { __u16 addr; __u16 flags; __u16 len; __u8 *buf; }; +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_addr.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_addr.h new file mode 100644 index 00000000000..8b9b8a6baf3 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_addr.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_IF_ADDR_H +#define _LINUX_IF_ADDR_H +#include + +struct rtattr; + +struct ifaddrmsg { + __u8 ifa_family; + __u8 ifa_prefixlen; + __u8 ifa_flags; + __u8 ifa_scope; + __u32 ifa_index; +}; + +#define IFA_UNSPEC 0 +#define IFA_ADDRESS 1 +#define IFA_LOCAL 2 +#define IFA_LABEL 3 +#define IFA_BROADCAST 4 +#define IFA_ANYCAST 5 +#define IFA_CACHEINFO 6 +#define IFA_MULTICAST 7 +#define IFA_FLAGS 8 +#define __IFA_MAX 9 +#define IFA_MAX (__IFA_MAX - 1) + +#define IFA_RTA(r) ((struct rtattr *)(((char *)(r)) + \ + ((sizeof(struct ifaddrmsg) + 3) & ~3))) + +#define IFA_PAYLOAD(n) ((int)((n)->nlmsg_len) - NLMSG_LENGTH(sizeof(struct ifaddrmsg))) + +#define IFA_F_SECONDARY 0x01 +#define IFA_F_NODAD 0x02 +#define IFA_F_OPTIMISTIC 0x04 +#define IFA_F_DADFAILED 0x08 +#define IFA_F_HOMEADDRESS 0x10 +#define IFA_F_DEPRECATED 0x20 +#define IFA_F_TENTATIVE 0x40 +#define IFA_F_PERMANENT 0x80 + +struct ifa_cacheinfo { + __u32 ifa_prefered; + __u32 ifa_valid; + __u32 cstamp; + __u32 tstamp; +}; + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_arp.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_arp.h new file mode 100644 index 00000000000..7ea2533eec5 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_arp.h @@ -0,0 +1,17 @@ +#ifndef _LINUX_IF_ARP_H +#define _LINUX_IF_ARP_H +#include + +#ifndef ARPHRD_IPGRE +#define ARPHRD_IPGRE 778 +#define ARPHRD_IP6GRE 823 +#define ARPHRD_SIT 776 +#define ARPHRD_TUNNEL 768 +#define ARPHRD_TUNNEL6 769 +#define ARPHRD_NONE 0xFFFE +#define ARPHRD_VOID 0xFFFF +#endif + +/* struct arphdr provided by net/if_arp.h */ + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_link.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_link.h new file mode 100644 index 00000000000..d627a154556 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_link.h @@ -0,0 +1,92 @@ +#ifndef _LINUX_IF_LINK_H +#define _LINUX_IF_LINK_H +#include + +#ifndef IFLA_UNSPEC +#define IFLA_UNSPEC 0 +#define IFLA_ADDRESS 1 +#define IFLA_BROADCAST 2 +#define IFLA_IFNAME 3 +#define IFLA_MTU 4 +#define IFLA_LINK 5 +#define IFLA_QDISC 6 +#define IFLA_STATS 7 +#define IFLA_COST 8 +#define IFLA_PRIORITY 9 +#define IFLA_MASTER 10 +#define IFLA_WIRELESS 11 +#define IFLA_PROTINFO 12 +#define IFLA_TXQLEN 13 +#define IFLA_MAP 14 +#define IFLA_WEIGHT 15 +#define IFLA_OPERSTATE 16 +#define IFLA_LINKMODE 17 +#define IFLA_LINKINFO 18 +#define IFLA_NET_NS_PID 19 +#define IFLA_IFALIAS 20 +#define __IFLA_MAX 21 +#define IFLA_MAX (__IFLA_MAX - 1) +#endif + +struct rtnl_link_stats { + __u32 rx_packets; + __u32 tx_packets; + __u32 rx_bytes; + __u32 tx_bytes; + __u32 rx_errors; + __u32 tx_errors; + __u32 rx_dropped; + __u32 tx_dropped; + __u32 multicast; + __u32 collisions; + __u32 rx_length_errors; + __u32 rx_over_errors; + __u32 rx_crc_errors; + __u32 rx_frame_errors; + __u32 rx_fifo_errors; + __u32 rx_missed_errors; + __u32 tx_aborted_errors; + __u32 tx_carrier_errors; + __u32 tx_fifo_errors; + __u32 tx_heartbeat_errors; + __u32 tx_window_errors; + __u32 rx_compressed; + __u32 tx_compressed; +}; + +struct rtnl_link_stats64 { + __u64 rx_packets; + __u64 tx_packets; + __u64 rx_bytes; + __u64 tx_bytes; + __u64 rx_errors; + __u64 tx_errors; + __u64 rx_dropped; + __u64 tx_dropped; + __u64 multicast; + __u64 collisions; + __u64 rx_length_errors; + __u64 rx_over_errors; + __u64 rx_crc_errors; + __u64 rx_frame_errors; + __u64 rx_fifo_errors; + __u64 rx_missed_errors; + __u64 tx_aborted_errors; + __u64 tx_carrier_errors; + __u64 tx_fifo_errors; + __u64 tx_heartbeat_errors; + __u64 tx_window_errors; + __u64 rx_compressed; + __u64 tx_compressed; +}; + +#endif + +/* Appended: link info attributes */ +#ifndef IFLA_INFO_KIND +#define IFLA_INFO_UNSPEC 0 +#define IFLA_INFO_KIND 1 +#define IFLA_INFO_DATA 2 +#define IFLA_INFO_XSTATS 3 + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_packet.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_packet.h new file mode 100644 index 00000000000..91dfc00001a --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_packet.h @@ -0,0 +1,9 @@ +#ifndef _LINUX_IF_PACKET_H +#define _LINUX_IF_PACKET_H +struct sockaddr_ll { unsigned short sll_family; unsigned short sll_protocol; int sll_ifindex; unsigned short sll_hatype; unsigned char sll_pkttype; unsigned char sll_halen; unsigned char sll_addr[8]; }; +#define PACKET_HOST 0 +#define PACKET_BROADCAST 1 +#define PACKET_MULTICAST 2 +#define PACKET_OTHERHOST 3 +#define PACKET_OUTGOING 4 +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_vlan.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_vlan.h new file mode 100644 index 00000000000..c4604bd781b --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/if_vlan.h @@ -0,0 +1,35 @@ +#ifndef _LINUX_IF_VLAN_H +#define _LINUX_IF_VLAN_H +enum vlan_ioctl_cmds { + ADD_VLAN_CMD, + DEL_VLAN_CMD, + SET_VLAN_INGRESS_PRIORITY_CMD, + SET_VLAN_EGRESS_PRIORITY_CMD, + GET_VLAN_INGRESS_PRIORITY_CMD, + GET_VLAN_EGRESS_PRIORITY_CMD, + SET_VLAN_NAME_TYPE_CMD, + SET_VLAN_FLAG_CMD, + GET_VLAN_REALDEV_NAME_CMD, + GET_VLAN_VID_CMD +}; +enum vlan_name_types { + VLAN_NAME_TYPE_PLUS_VID, + VLAN_NAME_TYPE_RAW_PLUS_VID, + VLAN_NAME_TYPE_PLUS_VID_NO_PAD, + VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD, + VLAN_NAME_TYPE_HIGHEST +}; +struct vlan_ioctl_args { + int cmd; + char device1[24]; + union { + char device2[24]; + int VID; + unsigned int skb_priority; + unsigned int name_type; + unsigned int bind_type; + unsigned int flag; + } u; + short vlan_qos; +}; +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/loop.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/loop.h new file mode 100644 index 00000000000..1ca67730fbf --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/loop.h @@ -0,0 +1,41 @@ +#ifndef _LINUX_LOOP_H +#define _LINUX_LOOP_H + +#include + +#define LO_NAME_SIZE 64 +#define LO_KEY_SIZE 32 +#define LO_FLAGS_READ_ONLY 1 +#define LO_FLAGS_AUTOCLEAR 4 +#define LO_FLAGS_PARTSCAN 8 +#define LO_FLAGS_DIRECT_IO 16 +#define LOOP_SET_FD 0x4C00 +#define LOOP_CLR_FD 0x4C01 +#define LOOP_SET_STATUS 0x4C02 +#define LOOP_GET_STATUS 0x4C03 +#define LOOP_SET_STATUS64 0x4C04 +#define LOOP_GET_STATUS64 0x4C05 +#define LOOP_SET_CAPACITY 0x4C07 +#define LOOP_SET_DIRECT_IO 0x4C08 +#define LOOP_SET_BLOCK_SIZE 0x4C09 +#define LOOP_CTL_ADD 0x4C80 +#define LOOP_CTL_REMOVE 0x4C81 +#define LOOP_CTL_GET_FREE 0x4C82 + +struct loop_info64 { + uint64_t lo_device; + uint64_t lo_inode; + uint64_t lo_rdevice; + uint64_t lo_offset; + uint64_t lo_sizelimit; + uint32_t lo_number; + uint32_t lo_encrypt_type; + uint32_t lo_encrypt_key_size; + uint32_t lo_flags; + uint8_t lo_file_name[LO_NAME_SIZE]; + uint8_t lo_crypt_name[LO_NAME_SIZE]; + uint8_t lo_encrypt_key[LO_KEY_SIZE]; + uint64_t lo_init[2]; +}; + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/netlink.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/netlink.h new file mode 100644 index 00000000000..8cb762295f4 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/netlink.h @@ -0,0 +1,48 @@ +#ifndef _LINUX_NETLINK_H +#define _LINUX_NETLINK_H + +#define NETLINK_ROUTE 0 +#define NETLINK_KOBJECT_UEVENT 15 + +struct sockaddr_nl { + unsigned short nl_family; + unsigned short nl_pad; + unsigned int nl_pid; + unsigned int nl_groups; +}; + +struct nlmsghdr { + unsigned int nlmsg_len; + unsigned short nlmsg_type; + unsigned short nlmsg_flags; + unsigned int nlmsg_seq; + unsigned int nlmsg_pid; +}; + +#define NLMSG_ALIGNTO 4 +#define NLMSG_ALIGN(len) (((len) + NLMSG_ALIGNTO - 1) & ~(NLMSG_ALIGNTO - 1)) +#define NLMSG_HDRLEN ((int)NLMSG_ALIGN(sizeof(struct nlmsghdr))) +#define NLMSG_LENGTH(len) ((len) + NLMSG_HDRLEN) +#define NLMSG_DATA(nlh) ((void *)(((char *)nlh) + NLMSG_HDRLEN)) +#define NLMSG_OK(nlh, len) ((len) >= (int)sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len >= sizeof(struct nlmsghdr) && \ + (nlh)->nlmsg_len <= (len)) +#define NLMSG_NEXT(nlh, len) ((len) -= NLMSG_ALIGN((nlh)->nlmsg_len), \ + (struct nlmsghdr *)(((char *)(nlh)) + NLMSG_ALIGN((nlh)->nlmsg_len))) + +#define NLMSG_DONE 3 +#define NLMSG_ERROR 2 + +#define NLM_F_REQUEST 0x01 +#define NLM_F_MULTI 0x02 +#define NLM_F_ACK 0x04 +#define NLM_F_ROOT 0x100 +#define NLM_F_MATCH 0x200 +#define NLM_F_ATOMIC 0x400 +#define NLM_F_DUMP (NLM_F_ROOT | NLM_F_MATCH) +#define NLM_F_REPLACE 0x100 +#define NLM_F_EXCL 0x200 +#define NLM_F_CREATE 0x400 +#define NLM_F_APPEND 0x800 + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/random.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/random.h new file mode 100644 index 00000000000..a3ba8cf5c91 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/random.h @@ -0,0 +1,13 @@ +#ifndef _LINUX_RANDOM_H +#define _LINUX_RANDOM_H +#include +#define GRND_NONBLOCK 0x0001 +#define GRND_RANDOM 0x0002 +#define GRND_INSECURE 0x0004 +#define RNDGETENTCNT 0x80045200 +#define RNDADDTOENTCNT 0x40045201 +#define RNDADDENTROPY 0x40085203 +#define RNDZAPENTCNT 0x5204 +#define RNDCLEARPOOL 0x5206 +#define RNDRESEEDCRNG 0x5207 +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/rtnetlink.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/rtnetlink.h new file mode 100644 index 00000000000..b86fd1afcfc --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/rtnetlink.h @@ -0,0 +1,182 @@ +#ifndef _LINUX_RTNETLINK_H +#define _LINUX_RTNETLINK_H +#include +#include +#include +#include + +/* Netlink error message */ +struct nlmsgerr { + int error; + struct nlmsghdr msg; +}; + +/* Generic netlink message */ +struct rtgenmsg { + unsigned char rtgen_family; +}; + +#define RTM_BASE 16 +#define RTM_NEWLINK 16 +#define RTM_DELLINK 17 +#define RTM_GETLINK 18 +#define RTM_SETLINK 19 +#define RTM_NEWADDR 20 +#define RTM_DELADDR 21 +#define RTM_GETADDR 22 +#define RTM_NEWROUTE 24 +#define RTM_DELROUTE 25 +#define RTM_GETROUTE 26 +#define RTM_NEWNEIGH 28 +#define RTM_DELNEIGH 29 +#define RTM_GETNEIGH 30 +#define RTM_NEWRULE 32 +#define RTM_DELRULE 33 +#define RTM_GETRULE 34 + +struct rtattr { + unsigned short rta_len; + unsigned short rta_type; +}; + +#define RTA_ALIGNTO 4 +#define RTA_ALIGN(len) (((len)+RTA_ALIGNTO-1) & ~(RTA_ALIGNTO-1)) +#define RTA_OK(rta,len) ((len) >= (int)sizeof(struct rtattr) && \ + (rta)->rta_len >= sizeof(struct rtattr) && (rta)->rta_len <= (len)) +#define RTA_NEXT(rta,attrlen) ((attrlen) -= RTA_ALIGN((rta)->rta_len), \ + (struct rtattr*)(((char*)(rta)) + RTA_ALIGN((rta)->rta_len))) +#define RTA_LENGTH(len) (RTA_ALIGN(sizeof(struct rtattr)) + (len)) +#define RTA_DATA(rta) ((void*)(((char*)(rta)) + RTA_LENGTH(0))) +#define RTA_PAYLOAD(rta) ((int)((rta)->rta_len) - RTA_LENGTH(0)) + +struct ifinfomsg { + unsigned char ifi_family; + unsigned char __ifi_pad; + unsigned short ifi_type; + int ifi_index; + unsigned ifi_flags; + unsigned ifi_change; +}; + +#define IFLA_RTA(r) ((struct rtattr *)(((char *)(r)) + \ + ((sizeof(struct ifinfomsg) + 3) & ~3))) +#define IFLA_PAYLOAD(n) ((int)((n)->nlmsg_len) - \ + NLMSG_LENGTH(sizeof(struct ifinfomsg))) + +struct rtmsg { + unsigned char rtm_family; + unsigned char rtm_dst_len; + unsigned char rtm_src_len; + unsigned char rtm_tos; + unsigned char rtm_table; + unsigned char rtm_protocol; + unsigned char rtm_scope; + unsigned char rtm_type; + unsigned rtm_flags; +}; + +#define RTM_RTA(r) ((struct rtattr *)(((char *)(r)) + \ + ((sizeof(struct rtmsg) + 3) & ~3))) + +/* Route attributes */ +#define RTA_UNSPEC 0 +#define RTA_DST 1 +#define RTA_SRC 2 +#define RTA_IIF 3 +#define RTA_OIF 4 +#define RTA_GATEWAY 5 +#define RTA_PRIORITY 6 +#define RTA_PREFSRC 7 +#define RTA_METRICS 8 +#define RTA_MULTIPATH 9 +#define RTA_FLOW 11 +#define RTA_CACHEINFO 12 +#define RTA_TABLE 15 +#define __RTA_MAX 16 +#define RTA_MAX (__RTA_MAX - 1) + +/* Route types */ +#define RTN_UNSPEC 0 +#define RTN_UNICAST 1 +#define RTN_LOCAL 2 +#define RTN_BROADCAST 3 +#define RTN_ANYCAST 4 +#define RTN_MULTICAST 5 +#define RTN_BLACKHOLE 6 +#define RTN_UNREACHABLE 7 +#define RTN_PROHIBIT 8 +#define RTN_THROW 9 +#define RTN_NAT 10 +#define RTN_XRESOLVE 11 + +/* Route flags */ +#define RTM_F_NOTIFY 0x100 +#define RTM_F_CLONED 0x200 +#define RTM_F_EQUALIZE 0x400 + +/* Route scope */ +#define RT_SCOPE_UNIVERSE 0 +#define RT_SCOPE_SITE 200 +#define RT_SCOPE_LINK 253 +#define RT_SCOPE_HOST 254 +#define RT_SCOPE_NOWHERE 255 + +/* Route table */ +#define RT_TABLE_UNSPEC 0 +#define RT_TABLE_DEFAULT 253 +#define RT_TABLE_MAIN 254 +#define RT_TABLE_LOCAL 255 + +/* Route protocol */ +#define RTPROT_UNSPEC 0 +#define RTPROT_REDIRECT 1 +#define RTPROT_KERNEL 2 +#define RTPROT_BOOT 3 +#define RTPROT_STATIC 4 + + +/* Route nexthop flags */ +#define RTNH_F_DEAD 1 +#define RTNH_F_PERVASIVE 2 +#define RTNH_F_ONLINK 4 + +struct rtnexthop { + unsigned short rtnh_len; + unsigned char rtnh_flags; + unsigned char rtnh_hops; + int rtnh_ifindex; +}; + +#define RTNH_ALIGNTO 4 +#define RTNH_ALIGN(len) (((len)+RTNH_ALIGNTO-1) & ~(RTNH_ALIGNTO-1)) +#define RTNH_DATA(rtnh) ((struct rtattr *)(((char *)(rtnh)) + RTNH_ALIGN(sizeof(struct rtnexthop)))) +#define RTNH_NEXT(rtnh) ((struct rtnexthop *)(((char *)(rtnh)) + RTNH_ALIGN((rtnh)->rtnh_len))) + +/* Route cache info */ +struct rta_cacheinfo { + unsigned int rta_clntref; + unsigned int rta_lastuse; + int rta_expires; + unsigned int rta_error; + unsigned int rta_used; + unsigned int rta_id; + unsigned int rta_ts; + unsigned int rta_tsage; +}; + +/* Route metrics attributes */ +#define RTAX_UNSPEC 0 +#define RTAX_LOCK 1 +#define RTAX_MTU 2 +#define RTAX_WINDOW 3 +#define RTAX_RTT 4 +#define RTAX_RTTVAR 5 +#define RTAX_SSTHRESH 6 +#define RTAX_CWND 7 +#define RTAX_ADVMSS 8 +#define RTAX_REORDERING 9 +#define RTAX_HOPLIMIT 10 +#define RTAX_INITCWND 11 +#define RTAX_FEATURES 12 + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/types.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/types.h new file mode 100644 index 00000000000..636b1071f84 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/types.h @@ -0,0 +1,11 @@ +#ifndef _LINUX_TYPES_H +#define _LINUX_TYPES_H +#include +#include +typedef __u16 __be16; +typedef __u32 __be32; +typedef __u64 __be64; +typedef __u16 __le16; +typedef __u32 __le32; +typedef __u64 __le64; +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/version.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/version.h new file mode 100644 index 00000000000..7089766dedf --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/linux/version.h @@ -0,0 +1,5 @@ +#ifndef _LINUX_VERSION_H +#define _LINUX_VERSION_H +#define LINUX_VERSION_CODE 394496 +#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/mntent.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/mntent.h new file mode 100644 index 00000000000..bdedc794954 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/mntent.h @@ -0,0 +1,22 @@ +#ifndef _MNTENT_H +#define _MNTENT_H + +#include + +struct mntent { + char *mnt_fsname; + char *mnt_dir; + char *mnt_type; + char *mnt_opts; + int mnt_freq; + int mnt_passno; +}; + +FILE *setmntent(const char *filename, const char *type); +struct mntent *getmntent(FILE *fp); +struct mntent *getmntent_r(FILE *fp, struct mntent *mnt, char *buf, int buflen); +int addmntent(FILE *fp, const struct mntent *mnt); +int endmntent(FILE *fp); +char *hasmntopt(const struct mntent *mnt, const char *opt); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/ethernet.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/ethernet.h new file mode 100644 index 00000000000..7982a6c4185 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/ethernet.h @@ -0,0 +1,21 @@ +#ifndef _NET_ETHERNET_H +#define _NET_ETHERNET_H + +#include + +#define ETH_ALEN 6 +#define ETHERTYPE_IP 0x0800 +#define ETHERTYPE_ARP 0x0806 +#define ETHERTYPE_IPV6 0x86dd + +struct ether_addr { + uint8_t ether_addr_octet[ETH_ALEN]; +}; + +struct ether_header { + uint8_t ether_dhost[ETH_ALEN]; + uint8_t ether_shost[ETH_ALEN]; + uint16_t ether_type; +}; + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if.h new file mode 100644 index 00000000000..7e6529127b3 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if.h @@ -0,0 +1,112 @@ +#ifndef _NET_IF_H +#define _NET_IF_H + +#include +#include + +#define IF_NAMESIZE 16 +#define IFNAMSIZ IF_NAMESIZE + +/* Interface flags */ +#define IFF_UP 0x1 +#define IFF_BROADCAST 0x2 +#define IFF_DEBUG 0x4 +#define IFF_LOOPBACK 0x8 +#define IFF_POINTOPOINT 0x10 +#define IFF_NOTRAILERS 0x20 +#define IFF_RUNNING 0x40 +#define IFF_NOARP 0x80 +#define IFF_PROMISC 0x100 +#define IFF_ALLMULTI 0x200 +#define IFF_MULTICAST 0x1000 +#define IFF_SLAVE 0x800 +#define IFF_MASTER 0x400 +#define IFF_DYNAMIC 0x8000 +#define IFF_PORTSEL 0x2000 +#define IFF_AUTOMEDIA 0x4000 + +struct ifmap { + unsigned long mem_start; + unsigned long mem_end; + unsigned short base_addr; + unsigned char irq; + unsigned char dma; + unsigned char port; +}; + +struct ifreq { + union { + char ifrn_name[IFNAMSIZ]; + } ifr_ifrn; + union { + struct sockaddr ifru_addr; + struct sockaddr ifru_dstaddr; + struct sockaddr ifru_broadaddr; + struct sockaddr ifru_netmask; + struct sockaddr ifru_hwaddr; + short ifru_flags; + int ifru_ivalue; + int ifru_mtu; + struct ifmap ifru_map; + char ifru_slave[IFNAMSIZ]; + char ifru_newname[IFNAMSIZ]; + void *ifru_data; + } ifr_ifru; +}; + +#define ifr_name ifr_ifrn.ifrn_name +#define ifr_hwaddr ifr_ifru.ifru_hwaddr +#define ifr_addr ifr_ifru.ifru_addr +#define ifr_dstaddr ifr_ifru.ifru_dstaddr +#define ifr_broadaddr ifr_ifru.ifru_broadaddr +#define ifr_netmask ifr_ifru.ifru_netmask +#define ifr_flags ifr_ifru.ifru_flags +#define ifr_metric ifr_ifru.ifru_ivalue +#define ifr_mtu ifr_ifru.ifru_mtu +#define ifr_map ifr_ifru.ifru_map +#define ifr_slave ifr_ifru.ifru_slave +#define ifr_data ifr_ifru.ifru_data +#define ifr_ifindex ifr_ifru.ifru_ivalue +#define ifr_newname ifr_ifru.ifru_newname +#define ifr_qlen ifr_ifru.ifru_ivalue + +struct ifconf { + int ifc_len; + union { + char *ifcu_buf; + struct ifreq *ifcu_req; + } ifc_ifcu; +}; + +#define ifc_buf ifc_ifcu.ifcu_buf +#define ifc_req ifc_ifcu.ifcu_req + +/* SIOC ioctl constants */ +#define SIOCGIFNAME 0x8910 +#define SIOCGIFCONF 0x8912 +#define SIOCGIFFLAGS 0x8913 +#define SIOCSIFFLAGS 0x8914 +#define SIOCGIFADDR 0x8915 +#define SIOCSIFADDR 0x8916 +#define SIOCGIFDSTADDR 0x8917 +#define SIOCSIFDSTADDR 0x8918 +#define SIOCGIFBRDADDR 0x8919 +#define SIOCSIFBRDADDR 0x891a +#define SIOCGIFNETMASK 0x891b +#define SIOCSIFNETMASK 0x891c +#define SIOCGIFMETRIC 0x891d +#define SIOCSIFMETRIC 0x891e +#define SIOCGIFMTU 0x8921 +#define SIOCSIFMTU 0x8922 +#define SIOCSIFHWADDR 0x8924 +#define SIOCGIFTXQLEN 0x8942 +#define SIOCSIFTXQLEN 0x8943 +#define SIOCSIFHWBROADCAST 0x8937 +#define SIOCGIFHWADDR 0x8927 +#define SIOCGIFINDEX 0x8933 +#define SIOCGIFCOUNT 0x8938 + +unsigned int if_nametoindex(const char *ifname); +char *if_indextoname(unsigned int ifindex, char *ifname); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if_arp.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if_arp.h new file mode 100644 index 00000000000..19922760357 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/if_arp.h @@ -0,0 +1,39 @@ +#ifndef _NET_IF_ARP_H +#define _NET_IF_ARP_H +#include +#define ARPHRD_ETHER 1 +#define ARPHRD_LOOPBACK 772 +#define ARPHRD_PPP 512 +#define ARPHRD_SIT 776 +#define ARPHRD_TUNNEL 768 +#define ARPHRD_VOID 0xFFFF +#define ARPHRD_CSLIP 257 +#define ARPHRD_SLIP 256 +#define ARPHRD_INFINIBAND 32 +#define ARPHRD_IEEE802 6 +#define ARPHRD_IEEE80211 801 +#define ARPHRD_DLCI 15 +#define ARPHRD_SLIP6 257 +#define ARPHRD_CSLIP6 258 +#define ARPHRD_ADAPT 264 +#define ARPHRD_ROSE 270 +#define ARPHRD_X25 271 +#define ARPHRD_FCPP 784 +#define ARPHRD_FCAL 785 +#define ARPHRD_FCPL 786 +#define ARPHRD_IRDA 783 +struct arphdr { uint16_t ar_hrd; uint16_t ar_pro; uint8_t ar_hln; uint8_t ar_pln; uint16_t ar_op; }; +#define ARPOP_REQUEST 1 +#define ARPOP_REPLY 2 + +#ifndef ARPHRD_IPGRE +#define ARPHRD_IPGRE 778 +#define ARPHRD_IP6GRE 823 +#define ARPHRD_SIT 776 +#define ARPHRD_TUNNEL 768 +#define ARPHRD_TUNNEL6 769 +#define ARPHRD_NONE 0xFFFE +#define ARPHRD_VOID 0xFFFF +#endif + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/route.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/route.h new file mode 100644 index 00000000000..dece0d7c913 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/net/route.h @@ -0,0 +1,41 @@ +#ifndef _NET_ROUTE_H +#define _NET_ROUTE_H +#include +#include +#include + +struct rtentry { + unsigned long rt_pad1; + struct sockaddr rt_dst; + struct sockaddr rt_gateway; + struct sockaddr rt_genmask; + unsigned short rt_flags; + short rt_pad2; + unsigned long rt_pad3; + void *rt_pad4; + short rt_metric; + char *rt_dev; + unsigned long rt_mtu; + unsigned long rt_window; + unsigned short rt_irtt; +#define rt_mss rt_mtu +}; + +#define RTF_UP 0x0001 +#define RTF_GATEWAY 0x0002 +#define RTF_HOST 0x0004 +#define RTF_REINSTATE 0x0008 +#define RTF_DYNAMIC 0x0010 +#define RTF_MODIFIED 0x0020 +#define RTF_MTU 0x0040 +#define RTF_WINDOW 0x0080 +#define RTF_IRTT 0x0100 +#define RTF_REJECT 0x0200 +#define RTF_MSS RTF_MTU +#define RTF_DEFAULT 0x00010000 + + +#define SIOCADDRT 0x890B +#define SIOCDELRT 0x890C + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netdb.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netdb.h new file mode 100644 index 00000000000..b07ae956ba3 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netdb.h @@ -0,0 +1,57 @@ +#ifndef _NETDB_H +#define _NETDB_H +#include +struct addrinfo { + int ai_flags, ai_family, ai_socktype, ai_protocol; + socklen_t ai_addrlen; + struct sockaddr *ai_addr; + char *ai_canonname; + struct addrinfo *ai_next; +}; +struct hostent { + char *h_name; char **h_aliases; int h_addrtype, h_length; char **h_addr_list; +}; +#define h_addr h_addr_list[0] +struct servent { char *s_name; char **s_aliases; int s_port; char *s_proto; }; +#define AI_PASSIVE 0x01 +#define AI_CANONNAME 0x02 +#define AI_NUMERICHOST 0x04 +#define AI_NUMERICSERV 0x400 +#define NI_NUMERICHOST 0x01 +#define NI_NUMERICSERV 0x02 +#define NI_MAXHOST 255 +#define NI_MAXSERV 32 +#define EAI_NONAME -2 +#define EAI_AGAIN -3 +#define EAI_FAIL -4 +#define EAI_FAMILY -6 +#define EAI_MEMORY -10 +#define EAI_SYSTEM -11 +int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **); +void freeaddrinfo(struct addrinfo *); +const char *gai_strerror(int); +int getnameinfo(const struct sockaddr *, socklen_t, char *, socklen_t, char *, socklen_t, int); +struct hostent *gethostbyname(const char *); +struct hostent *gethostbyaddr(const void *, socklen_t, int); +struct servent *getservbyname(const char *, const char *); +struct servent *getservbyport(int, const char *); + +/* DNS error reporting */ +extern int h_errno; +const char *hstrerror(int err); +#define HOST_NOT_FOUND 1 +#define TRY_AGAIN 2 +#define NO_RECOVERY 3 +#define NO_DATA 4 + + +/* Name info flags */ +#ifndef NI_NAMEREQD +#define NI_NUMERICHOST 1 +#define NI_NUMERICSERV 2 +#define NI_NOFQDN 4 +#define NI_NAMEREQD 8 +#define NI_DGRAM 16 +#endif + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netinet/if_ether.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netinet/if_ether.h new file mode 100644 index 00000000000..232358cf2e1 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/netinet/if_ether.h @@ -0,0 +1,60 @@ +#ifndef _NETINET_IF_ETHER_H +#define _NETINET_IF_ETHER_H + +#define ETH_ALEN 6 +#define ETH_HLEN 14 +#define ETH_ZLEN 60 +#define ETH_DATA_LEN 1500 +#define ETH_FRAME_LEN 1514 +#define ETH_FCS_LEN 4 + +/* Ethernet protocol IDs */ +#define ETH_P_LOOP 0x0060 +#define ETH_P_PUP 0x0200 +#define ETH_P_PUPAT 0x0201 +#define ETH_P_IP 0x0800 +#define ETH_P_X25 0x0805 +#define ETH_P_ARP 0x0806 +#define ETH_P_BPQ 0x08FF +#define ETH_P_DEC 0x6000 +#define ETH_P_DNA_DL 0x6001 +#define ETH_P_DNA_RC 0x6002 +#define ETH_P_DNA_RT 0x6003 +#define ETH_P_LAT 0x6004 +#define ETH_P_DIAG 0x6005 +#define ETH_P_CUST 0x6006 +#define ETH_P_SCA 0x6007 +#define ETH_P_RARP 0x8035 +#define ETH_P_ATALK 0x809B +#define ETH_P_AARP 0x80F3 +#define ETH_P_8021Q 0x8100 +#define ETH_P_IPX 0x8137 +#define ETH_P_IPV6 0x86DD +#define ETH_P_PPP_DISC 0x8863 +#define ETH_P_PPP_SES 0x8864 +#define ETH_P_MPLS_UC 0x8847 +#define ETH_P_MPLS_MC 0x8848 +#define ETH_P_802_3 0x0001 +#define ETH_P_AX25 0x0002 +#define ETH_P_ALL 0x0003 +#define ETH_P_802_2 0x0004 +#define ETH_P_SNAP 0x0005 + +#define ETH_P_DDCMP 0x0006 +#define ETH_P_WAN_PPP 0x0007 +#define ETH_P_PPP_MP 0x0008 +#define ETH_P_LOCALTALK 0x0009 +#define ETH_P_PPPTALK 0x0010 +#define ETH_P_TR_802_2 0x0011 +#define ETH_P_MOBITEX 0x0015 +#define ETH_P_CONTROL 0x0016 +#define ETH_P_IRDA 0x0017 +#define ETH_P_802_3_MIN 0x0600 + +struct ethhdr { + unsigned char h_dest[ETH_ALEN]; + unsigned char h_source[ETH_ALEN]; + unsigned short h_proto; +}; + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/paths.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/paths.h new file mode 100644 index 00000000000..95b7a11446a --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/paths.h @@ -0,0 +1,30 @@ +#ifndef _PATHS_H +#define _PATHS_H +#define _PATH_DEFPATH "/usr/bin:/bin" +#define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin" +#define _PATH_BSHELL "/bin/sh" +#define _PATH_CONSOLE "/dev/console" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_DEVZERO "/dev/zero" +#define _PATH_KMEM "/dev/kmem" +#define _PATH_MEM "/dev/mem" +#define _PATH_MNTTAB "/etc/fstab" +#define _PATH_MOUNTED "/etc/mtab" +#define _PATH_NOLOGIN "/etc/nologin" +#define _PATH_LASTLOG "/var/log/lastlog" +#define _PATH_MAILDIR "/var/mail" +#define _PATH_MAN "/usr/share/man" +#define _PATH_PRESERVE "/var/lib" +#define _PATH_RWHODIR "/var/spool/rwho" +#define _PATH_SENDMAIL "/usr/sbin/sendmail" +#define _PATH_SHADOW "/etc/shadow" +#define _PATH_SHELLS "/etc/shells" +#define _PATH_TTY "/dev/tty" +#define _PATH_UTMP "/var/run/utmp" +#define _PATH_WTMP "/var/log/wtmp" +#define _PATH_DEV "/dev/" +#define _PATH_TMP "/tmp/" +#define _PATH_VARDB "/var/db/" +#define _PATH_VARRUN "/var/run/" +#define _PATH_VARTMP "/var/tmp/" +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pty.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pty.h new file mode 100644 index 00000000000..c6f0abf36b0 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pty.h @@ -0,0 +1,7 @@ +#ifndef _PTY_H +#define _PTY_H +#include +#include +int openpty(int *master, int *slave, char *name, const struct termios *termp, const struct winsize *winp); +int forkpty(int *master, char *name, const struct termios *termp, const struct winsize *winp); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pwd.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pwd.h new file mode 100644 index 00000000000..95dd8ca3660 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/pwd.h @@ -0,0 +1,15 @@ +#ifndef _PWD_H +#define _PWD_H +#include +struct passwd { + char *pw_name, *pw_passwd; uid_t pw_uid; gid_t pw_gid; + char *pw_gecos, *pw_dir, *pw_shell; +}; +struct passwd *getpwnam(const char *); +struct passwd *getpwuid(uid_t); +struct passwd *getpwent(void); +void setpwent(void); +void endpwent(void); +int getpwnam_r(const char *, struct passwd *, char *, size_t, struct passwd **); +int getpwuid_r(uid_t, struct passwd *, char *, size_t, struct passwd **); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/shadow.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/shadow.h new file mode 100644 index 00000000000..d927927f8d4 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/shadow.h @@ -0,0 +1,26 @@ +#ifndef _SHADOW_H +#define _SHADOW_H + +#include + +struct spwd { + char *sp_namp; + char *sp_pwdp; + long sp_lstchg; + long sp_min; + long sp_max; + long sp_warn; + long sp_inact; + long sp_expire; + unsigned long sp_flag; +}; + +struct spwd *getspnam(const char *name); +struct spwd *getspent(void); +void setspent(void); +void endspent(void); +int putspent(const struct spwd *p, FILE *fp); +int lckpwdf(void); +int ulckpwdf(void); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/epoll.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/epoll.h new file mode 100644 index 00000000000..1a6319e7f53 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/epoll.h @@ -0,0 +1,27 @@ +#ifndef _SYS_EPOLL_H +#define _SYS_EPOLL_H +#include +#define EPOLLIN 0x001 +#define EPOLLPRI 0x002 +#define EPOLLOUT 0x004 +#define EPOLLERR 0x008 +#define EPOLLHUP 0x010 +#define EPOLLRDNORM 0x040 +#define EPOLLRDBAND 0x080 +#define EPOLLWRNORM 0x100 +#define EPOLLWRBAND 0x200 +#define EPOLLMSG 0x400 +#define EPOLLRDHUP 0x2000 +#define EPOLLONESHOT (1<<30) +#define EPOLLET (1<<31) +#define EPOLL_CTL_ADD 1 +#define EPOLL_CTL_DEL 2 +#define EPOLL_CTL_MOD 3 +#define EPOLL_CLOEXEC 02000000 +typedef union epoll_data { void *ptr; int fd; uint32_t u32; uint64_t u64; } epoll_data_t; +struct epoll_event { uint32_t events; epoll_data_t data; }; +int epoll_create(int size); +int epoll_create1(int flags); +int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event); +int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/inotify.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/inotify.h new file mode 100644 index 00000000000..2a62fd5fa06 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/inotify.h @@ -0,0 +1,26 @@ +#ifndef _SYS_INOTIFY_H +#define _SYS_INOTIFY_H +#include +struct inotify_event { int wd; uint32_t mask; uint32_t cookie; uint32_t len; char name[]; }; +#define IN_ACCESS 0x00000001 +#define IN_MODIFY 0x00000002 +#define IN_ATTRIB 0x00000004 +#define IN_CLOSE_WRITE 0x00000008 +#define IN_CLOSE_NOWRITE 0x00000010 +#define IN_OPEN 0x00000020 +#define IN_MOVED_FROM 0x00000040 +#define IN_MOVED_TO 0x00000080 +#define IN_CREATE 0x00000100 +#define IN_DELETE 0x00000200 +#define IN_DELETE_SELF 0x00000400 +#define IN_MOVE_SELF 0x00000800 +#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) +#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) +#define IN_ALL_EVENTS 0x00000fff +#define IN_NONBLOCK 04000 +#define IN_CLOEXEC 02000000 +int inotify_init(void); +int inotify_init1(int flags); +int inotify_add_watch(int fd, const char *path, uint32_t mask); +int inotify_rm_watch(int fd, int wd); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/klog.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/klog.h new file mode 100644 index 00000000000..69dc7d4e651 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/klog.h @@ -0,0 +1,6 @@ +#ifndef _SYS_KLOG_H +#define _SYS_KLOG_H + +int klogctl(int type, char *buf, int len); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/mount.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/mount.h new file mode 100644 index 00000000000..53a01dd3ccf --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/mount.h @@ -0,0 +1,28 @@ +#ifndef _SYS_MOUNT_H +#define _SYS_MOUNT_H + +#define MS_RDONLY 1 +#define MS_NOSUID 2 +#define MS_NODEV 4 +#define MS_NOEXEC 8 +#define MS_SYNCHRONOUS 16 +#define MS_REMOUNT 32 +#define MS_MANDLOCK 64 +#define MS_DIRSYNC 128 +#define MS_NOATIME 1024 +#define MS_NODIRATIME 2048 +#define MS_BIND 4096 +#define MS_MOVE 8192 +#define MS_REC 16384 +#define MS_SILENT 32768 +#define MS_RELATIME (1<<21) +#define MNT_FORCE 1 +#define MNT_DETACH 2 +#define MNT_EXPIRE 4 +#define UMOUNT_NOFOLLOW 8 + +int mount(const char *source, const char *target, const char *fstype, unsigned long flags, const void *data); +int umount(const char *target); +int umount2(const char *target, int flags); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/personality.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/personality.h new file mode 100644 index 00000000000..ee1fd909440 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/personality.h @@ -0,0 +1,8 @@ +#ifndef _SYS_PERSONALITY_H +#define _SYS_PERSONALITY_H +#define PER_LINUX 0x0000 +#define PER_LINUX32 0x0008 +#define PER_LINUX_32BIT 0x0800000 +#define ADDR_NO_RANDOMIZE 0x0040000 +int personality(unsigned long persona); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/prctl.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/prctl.h new file mode 100644 index 00000000000..3d6d800bd18 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/prctl.h @@ -0,0 +1,11 @@ +#ifndef _SYS_PRCTL_H +#define _SYS_PRCTL_H + +#define PR_SET_NAME 15 +#define PR_GET_NAME 16 +#define PR_SET_DUMPABLE 4 +#define PR_GET_DUMPABLE 3 + +int prctl(int option, ...); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/reboot.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/reboot.h new file mode 100644 index 00000000000..b52dc751289 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/reboot.h @@ -0,0 +1,12 @@ +#ifndef _SYS_REBOOT_H +#define _SYS_REBOOT_H + +#define RB_AUTOBOOT 0x01234567 +#define RB_HALT_SYSTEM 0xcdef0123 +#define RB_POWER_OFF 0x4321fedc +#define RB_DISABLE_CAD 0 +#define RB_ENABLE_CAD 0x89abcdef + +int reboot(int cmd); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sendfile.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sendfile.h new file mode 100644 index 00000000000..ab9ce399449 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sendfile.h @@ -0,0 +1,8 @@ +#ifndef _SYS_SENDFILE_H +#define _SYS_SENDFILE_H + +#include + +ssize_t sendfile(int out_fd, int in_fd, off_t *offset, size_t count); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/signalfd.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/signalfd.h new file mode 100644 index 00000000000..79cb31ce42d --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/signalfd.h @@ -0,0 +1,9 @@ +#ifndef _SYS_SIGNALFD_H +#define _SYS_SIGNALFD_H +#include +#include +#define SFD_CLOEXEC 02000000 +#define SFD_NONBLOCK 04000 +struct signalfd_siginfo { uint32_t ssi_signo; int32_t ssi_errno; int32_t ssi_code; uint32_t ssi_pid; uint32_t ssi_uid; int32_t ssi_fd; uint32_t ssi_tid; uint32_t ssi_band; uint32_t ssi_overrun; uint32_t ssi_trapno; int32_t ssi_status; int32_t ssi_int; uint64_t ssi_ptr; uint64_t ssi_utime; uint64_t ssi_stime; uint64_t ssi_addr; uint8_t __pad[48]; }; +int signalfd(int fd, const sigset_t *mask, int flags); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/statfs.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/statfs.h new file mode 100644 index 00000000000..78db84618cf --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/statfs.h @@ -0,0 +1,26 @@ +#ifndef _SYS_STATFS_H +#define _SYS_STATFS_H + +#include + +typedef struct { int val[2]; } fsid_t; + +struct statfs { + unsigned long f_type; + unsigned long f_bsize; + unsigned long f_blocks; + unsigned long f_bfree; + unsigned long f_bavail; + unsigned long f_files; + unsigned long f_ffree; + fsid_t f_fsid; + unsigned long f_namelen; + unsigned long f_frsize; + unsigned long f_flags; + unsigned long f_spare[4]; +}; + +int statfs(const char *path, struct statfs *buf); +int fstatfs(int fd, struct statfs *buf); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/swap.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/swap.h new file mode 100644 index 00000000000..0daf5ea6436 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/swap.h @@ -0,0 +1,10 @@ +#ifndef _SYS_SWAP_H +#define _SYS_SWAP_H + +#define SWAP_FLAG_PREFER 0x8000 +#define SWAP_FLAG_PRIO_MASK 0x7fff + +int swapon(const char *path, int flags); +int swapoff(const char *path); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sysmacros.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sysmacros.h new file mode 100644 index 00000000000..106e2aa15a0 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/sysmacros.h @@ -0,0 +1,8 @@ +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H + +#define major(dev) ((unsigned int)(((dev) >> 8) & 0xff)) +#define minor(dev) ((unsigned int)((dev) & 0xff)) +#define makedev(maj, min) ((dev_t)(((maj) << 8) | (min))) + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/timerfd.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/timerfd.h new file mode 100644 index 00000000000..2119d4e60f1 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/timerfd.h @@ -0,0 +1,10 @@ +#ifndef _SYS_TIMERFD_H +#define _SYS_TIMERFD_H +#include +#define TFD_CLOEXEC 02000000 +#define TFD_NONBLOCK 04000 +#define TFD_TIMER_ABSTIME 1 +int timerfd_create(int clockid, int flags); +int timerfd_settime(int fd, int flags, const struct itimerspec *new_value, struct itimerspec *old_value); +int timerfd_gettime(int fd, struct itimerspec *curr_value); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/vfs.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/vfs.h new file mode 100644 index 00000000000..1d6d848854e --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/vfs.h @@ -0,0 +1,4 @@ +#ifndef _SYS_VFS_H +#define _SYS_VFS_H +#include +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/wait.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/wait.h new file mode 100644 index 00000000000..18b3e8d81b0 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/wait.h @@ -0,0 +1,14 @@ +#ifndef _SYS_WAIT_H +#define _SYS_WAIT_H +#include +#define WNOHANG 1 +#define WUNTRACED 2 +#define WEXITSTATUS(s) (((s) >> 8) & 0xff) +#define WTERMSIG(s) ((s) & 0x7f) +#define WIFEXITED(s) (!WTERMSIG(s)) +#define WIFSIGNALED(s) (((signed char)(((s)&0x7f)+1)>>1) > 0) +#define WIFSTOPPED(s) ((short)((((s)&0xffff)*0x10001U)>>8) > 0x7f00) +typedef int idtype_t; +pid_t wait(int *); +pid_t waitpid(pid_t, int *, int); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/xattr.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/xattr.h new file mode 100644 index 00000000000..f7de81cd9c5 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/sys/xattr.h @@ -0,0 +1,18 @@ +#ifndef _SYS_XATTR_H +#define _SYS_XATTR_H +#include +#define XATTR_CREATE 1 +#define XATTR_REPLACE 2 +ssize_t getxattr(const char *path, const char *name, void *value, size_t size); +ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size); +ssize_t fgetxattr(int fd, const char *name, void *value, size_t size); +ssize_t listxattr(const char *path, char *list, size_t size); +ssize_t llistxattr(const char *path, char *list, size_t size); +ssize_t flistxattr(int fd, char *list, size_t size); +int setxattr(const char *path, const char *name, const void *value, size_t size, int flags); +int lsetxattr(const char *path, const char *name, const void *value, size_t size, int flags); +int fsetxattr(int fd, const char *name, const void *value, size_t size, int flags); +int removexattr(const char *path, const char *name); +int lremovexattr(const char *path, const char *name); +int fremovexattr(int fd, const char *name); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/syslog.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/syslog.h new file mode 100644 index 00000000000..b7169d9cd48 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/syslog.h @@ -0,0 +1,41 @@ +#ifndef _SYSLOG_H +#define _SYSLOG_H +#define LOG_EMERG 0 +#define LOG_ALERT 1 +#define LOG_CRIT 2 +#define LOG_ERR 3 +#define LOG_WARNING 4 +#define LOG_NOTICE 5 +#define LOG_INFO 6 +#define LOG_DEBUG 7 +#define LOG_KERN (0<<3) +#define LOG_USER (1<<3) +#define LOG_MAIL (2<<3) +#define LOG_DAEMON (3<<3) +#define LOG_AUTH (4<<3) +#define LOG_SYSLOG (5<<3) +#define LOG_LPR (6<<3) +#define LOG_NEWS (7<<3) +#define LOG_UUCP (8<<3) +#define LOG_CRON (9<<3) +#define LOG_AUTHPRIV (10<<3) +#define LOG_FTP (11<<3) +#define LOG_LOCAL0 (16<<3) +#define LOG_LOCAL1 (17<<3) +#define LOG_LOCAL2 (18<<3) +#define LOG_LOCAL3 (19<<3) +#define LOG_LOCAL4 (20<<3) +#define LOG_LOCAL5 (21<<3) +#define LOG_LOCAL6 (22<<3) +#define LOG_LOCAL7 (23<<3) +#define LOG_PID 0x01 +#define LOG_CONS 0x02 +#define LOG_ODELAY 0x04 +#define LOG_NDELAY 0x08 +#define LOG_NOWAIT 0x10 +#define LOG_PERROR 0x20 +void openlog(const char *, int, int); +void syslog(int, const char *, ...); +void closelog(void); +int setlogmask(int); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/termios.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/termios.h new file mode 100644 index 00000000000..8c5f554cb36 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/termios.h @@ -0,0 +1,161 @@ +#ifndef _TERMIOS_H +#define _TERMIOS_H + +#include + +typedef unsigned int tcflag_t; +typedef unsigned char cc_t; +typedef unsigned int speed_t; + +#define NCCS 32 + +struct termios { + tcflag_t c_iflag; + tcflag_t c_oflag; + tcflag_t c_cflag; + tcflag_t c_lflag; + cc_t c_line; + cc_t c_cc[NCCS]; + speed_t c_ispeed; + speed_t c_ospeed; +}; + +/* c_cc indexes */ +#define VINTR 0 +#define VQUIT 1 +#define VERASE 2 +#define VKILL 3 +#define VEOF 4 +#define VTIME 5 +#define VMIN 6 +#define VSWTC 7 +#define VSTART 8 +#define VSTOP 9 +#define VSUSP 10 +#define VEOL 11 +#define VREPRINT 12 +#define VDISCARD 13 +#define VWERASE 14 +#define VLNEXT 15 +#define VEOL2 16 + +/* c_iflag bits */ +#define IGNBRK 0000001 +#define BRKINT 0000002 +#define IGNPAR 0000004 +#define PARMRK 0000010 +#define INPCK 0000020 +#define ISTRIP 0000040 +#define INLCR 0000100 +#define IGNCR 0000200 +#define ICRNL 0000400 +#define IUCLC 0001000 +#define IXON 0002000 +#define IXANY 0004000 +#define IXOFF 0010000 +#define IMAXBEL 0020000 +#define IUTF8 0040000 + +/* c_oflag bits */ +#define OPOST 0000001 +#define OLCUC 0000002 +#define ONLCR 0000004 +#define OCRNL 0000010 +#define ONOCR 0000020 +#define ONLRET 0000040 +#define OFILL 0000100 +#define OFDEL 0000200 + +/* c_cflag bits */ +#define CSIZE 0000060 +#define CS5 0000000 +#define CS6 0000020 +#define CS7 0000040 +#define CS8 0000060 +#define CSTOPB 0000100 +#define CREAD 0000200 +#define PARENB 0000400 +#define PARODD 0001000 +#define HUPCL 0002000 +#define CLOCAL 0004000 + +/* c_lflag bits */ +#define ISIG 0000001 +#define ICANON 0000002 +#define XCASE 0000004 +#define ECHO 0000010 +#define ECHOE 0000020 +#define ECHOK 0000040 +#define ECHONL 0000100 +#define NOFLSH 0000200 +#define TOSTOP 0000400 +#define ECHOCTL 0001000 +#define ECHOPRT 0002000 +#define ECHOKE 0004000 +#define FLUSHO 0010000 +#define PENDIN 0040000 +#define IEXTEN 0100000 +#define EXTPROC 0200000 + +/* tcsetattr actions */ +#define TCSANOW 0 +#define TCSADRAIN 1 +#define TCSAFLUSH 2 + +/* tcflow/tcflush */ +#define TCOOFF 0 +#define TCOON 1 +#define TCIOFF 2 +#define TCION 3 +#define TCIFLUSH 0 +#define TCOFLUSH 1 +#define TCIOFLUSH 2 + +/* baud rates */ +#define B0 0000000 +#define B50 0000001 +#define B75 0000002 +#define B110 0000003 +#define B134 0000004 +#define B150 0000005 +#define B200 0000006 +#define B300 0000007 +#define B600 0000010 +#define B1200 0000011 +#define B1800 0000012 +#define B2400 0000013 +#define B4800 0000014 +#define B9600 0000015 +#define B19200 0000016 +#define B38400 0000017 +#define B57600 0010001 +#define B115200 0010002 +#define B230400 0010003 +#define B460800 0010004 +#define B500000 0010005 +#define B576000 0010006 +#define B921600 0010007 +#define B1000000 0010010 +#define B1152000 0010011 +#define B1500000 0010012 +#define B2000000 0010013 +#define B2500000 0010014 +#define B3000000 0010015 +#define B3500000 0010016 +#define B4000000 0010017 + +int tcgetattr(int fd, struct termios *t); +int tcsetattr(int fd, int actions, const struct termios *t); +speed_t cfgetispeed(const struct termios *t); +speed_t cfgetospeed(const struct termios *t); +int cfsetispeed(struct termios *t, speed_t speed); +int cfsetospeed(struct termios *t, speed_t speed); +int tcsendbreak(int fd, int duration); +int tcdrain(int fd); +int tcflush(int fd, int queue); +int tcflow(int fd, int action); +pid_t tcgetsid(int fd); +void cfmakeraw(struct termios *t); +int cfsetspeed(struct termios *t, speed_t speed); + +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmp.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmp.h new file mode 100644 index 00000000000..ba69ce82c7d --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmp.h @@ -0,0 +1,20 @@ +#ifndef _UTMP_H +#define _UTMP_H +#define UT_LINESIZE 32 +#define UT_NAMESIZE 32 +#define UT_HOSTSIZE 256 +#define EMPTY 0 +#define RUN_LVL 1 +#define BOOT_TIME 2 +#define NEW_TIME 3 +#define OLD_TIME 4 +#define INIT_PROCESS 5 +#define LOGIN_PROCESS 6 +#define USER_PROCESS 7 +#define DEAD_PROCESS 8 +struct utmp { + short ut_type; pid_t ut_pid; + char ut_line[UT_LINESIZE]; char ut_id[4]; char ut_user[UT_NAMESIZE]; + char ut_host[UT_HOSTSIZE]; +}; +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmpx.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmpx.h new file mode 100644 index 00000000000..66e26073cd7 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/utmpx.h @@ -0,0 +1,22 @@ +#ifndef _UTMPX_H +#define _UTMPX_H +#include +#include +#define EMPTY 0 +#define RUN_LVL 1 +#define BOOT_TIME 2 +#define NEW_TIME 3 +#define OLD_TIME 4 +#define INIT_PROCESS 5 +#define LOGIN_PROCESS 6 +#define USER_PROCESS 7 +#define DEAD_PROCESS 8 +struct utmpx { short ut_type; pid_t ut_pid; char ut_line[32]; char ut_id[4]; char ut_user[32]; char ut_host[256]; struct { short e_termination; short e_exit; } ut_exit; long ut_session; struct timeval ut_tv; int ut_addr_v6[4]; char __unused[20]; }; +void setutxent(void); +void endutxent(void); +struct utmpx *getutxent(void); +struct utmpx *getutxid(const struct utmpx *ut); +struct utmpx *getutxline(const struct utmpx *ut); +struct utmpx *pututxline(const struct utmpx *ut); +void updwtmpx(const char *file, const struct utmpx *ut); +#endif diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wasi-posix-fixups.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wasi-posix-fixups.h new file mode 100644 index 00000000000..87fc909ab3a --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wasi-posix-fixups.h @@ -0,0 +1,495 @@ +#ifndef __ASSEMBLER__ +/* POSIX compatibility layer for wasi-libc. + * + * Force-included via -include in the toolchain wrapper. Provides + * constants, structs, and function declarations that wasi-libc + * deliberately omits (guarded behind __wasilibc_unmodified_upstream). + * + * These are stub declarations -- the wasivm Go kernel handles the + * actual implementation at runtime via WASI host imports. + */ +#ifndef _WASI_POSIX_FIXUPS_H +#define _WASI_POSIX_FIXUPS_H + +/* Suppress setjmp.h error - we provide stub setjmp/longjmp via --import-undefined */ +#ifndef __wasm_exception_handling__ +#define __wasm_exception_handling__ 1 +#endif + +#include +#include + +/* ================================================================ + * Socket types and address families + * ================================================================ */ + +#ifndef SOCK_RAW +#define SOCK_RAW 3 +#endif +#ifndef SOCK_RDM +#define SOCK_RDM 4 +#endif +/* wasi-libc uses SOCK_DGRAM=5, so SOCK_SEQPACKET must differ. */ +#ifndef SOCK_SEQPACKET +#define SOCK_SEQPACKET 105 +#endif +#ifndef SOCK_PACKET +#define SOCK_PACKET 10 +#endif + +#ifndef SHUT_RD +#define SHUT_RD 0 +#define SHUT_WR 1 +#define SHUT_RDWR 2 +#endif + +#ifndef PF_PACKET +#define PF_PACKET 17 +#define AF_PACKET PF_PACKET +#endif +#ifndef PF_NETLINK +#define PF_NETLINK 16 +#define AF_NETLINK PF_NETLINK +#endif + +/* Override wasi-libc truncated sockaddr_un (no sun_path). */ +#define __wasilibc___struct_sockaddr_un_h +#include <__typedef_sa_family_t.h> +struct sockaddr_un { + sa_family_t sun_family; + char sun_path[108]; +}; + +#ifndef SO_DEBUG +#define SO_DEBUG 1 +#define SO_REUSEADDR 2 +#define SO_TYPE 3 +#define SO_ERROR 4 +#define SO_DONTROUTE 5 +#define SO_BROADCAST 6 +#define SO_SNDBUF 7 +#define SO_RCVBUF 8 +#define SO_KEEPALIVE 9 +#define SO_OOBINLINE 10 +#define SO_RCVBUFFORCE 33 +#define SO_SNDBUFFORCE 32 +#endif + +#ifndef SOL_PACKET +#define SOL_PACKET 263 +#endif + +#ifndef MSG_DONTWAIT +#define MSG_DONTWAIT 0x40 +#endif + +#ifndef NI_NUMERICHOST +#define NI_NUMERICHOST 1 +#define NI_NUMERICSERV 2 +#define NI_NOFQDN 4 +#define NI_NAMEREQD 8 +#define NI_DGRAM 16 +#endif + +/* ================================================================ + * Signals + * ================================================================ */ + +#include + +#ifndef SA_RESTART +#define SA_RESTART 0x10000000 +#define SA_NODEFER 0x40000000 +#define SA_RESETHAND 0x80000000 +#define SA_NOCLDSTOP 1 +#define SA_NOCLDWAIT 2 +#define SA_SIGINFO 4 +#define SA_ONSTACK 0x08000000 +#endif + +#ifndef SIG_BLOCK +#define SIG_BLOCK 0 +#define SIG_UNBLOCK 1 +#define SIG_SETMASK 2 +#endif + +#ifndef _WASI_SIGACTION_DEFINED +#define _WASI_SIGACTION_DEFINED +struct sigaction { + void (*sa_handler)(int); + unsigned long sa_flags; + void (*sa_restorer)(void); + sigset_t sa_mask; +}; +#endif + +#ifndef WCOREDUMP +#define WCOREDUMP(s) ((s) & 0x80) +#endif +int killpg(pid_t, int); +int sigaction(int, const struct sigaction *, struct sigaction *); +int sigaddset(sigset_t *, int); +int sigdelset(sigset_t *, int); +int sigfillset(sigset_t *); +int sigemptyset(sigset_t *); +int sigismember(const sigset_t *, int); +int sigisemptyset(const sigset_t *); +int sigprocmask(int, const sigset_t *, sigset_t *); +int sigtimedwait(const sigset_t *, void *, const struct timespec *); +int sigwait(const sigset_t *, int *); +int sigsuspend(const sigset_t *); + +#ifndef _WASI_SIGALTSTACK_DEFINED +#define _WASI_SIGALTSTACK_DEFINED +typedef struct sigaltstack { + void *ss_sp; + int ss_flags; + size_t ss_size; +} stack_t; +#endif +int sigaltstack(const stack_t *, stack_t *); +int sigpending(sigset_t *); + +#ifndef ITIMER_REAL +#define ITIMER_REAL 0 +#define ITIMER_VIRTUAL 1 +#define ITIMER_PROF 2 +struct itimerval { + struct timeval it_interval; + struct timeval it_value; +}; +int setitimer(int, const struct itimerval *, struct itimerval *); +int getitimer(int, struct itimerval *); +#endif + +/* ================================================================ + * Process management + * ================================================================ */ + +pid_t fork(void); +pid_t vfork(void); +pid_t setsid(void); +pid_t getsid(pid_t); +pid_t getppid(void); +pid_t getpgid(pid_t); +pid_t getpgrp(void); +int setpgid(pid_t, pid_t); +int setpgrp(void); +int kill(pid_t, int); +pid_t waitpid(pid_t, int *, int); +pid_t wait(int *); +void _exit(int) __attribute__((noreturn)); + +int execv(const char *, char *const[]); +int execve(const char *, char *const[], char *const[]); +int execvp(const char *, char *const[]); +int execl(const char *, const char *, ...); +int execle(const char *, const char *, ...); +int execlp(const char *, const char *, ...); + +/* Wait status macros */ +#ifndef WIFEXITED +#define WIFEXITED(s) (((s) & 0x7f) == 0) +#define WEXITSTATUS(s) (((s) >> 8) & 0xff) +#define WIFSIGNALED(s) (((signed char)(((s) & 0x7f) + 1) >> 1) > 0) +#define WTERMSIG(s) ((s) & 0x7f) +#define WIFSTOPPED(s) (((s) & 0xff) == 0x7f) +#define WSTOPSIG(s) WEXITSTATUS(s) +#endif + +/* ================================================================ + * User/group IDs + * ================================================================ */ + +uid_t getuid(void); +gid_t getgid(void); +uid_t geteuid(void); +gid_t getegid(void); +int setuid(uid_t); +int setgid(gid_t); +int seteuid(uid_t); +int setegid(gid_t); +int setreuid(uid_t, uid_t); +int setregid(gid_t, gid_t); +int getresuid(uid_t *, uid_t *, uid_t *); +int getresgid(gid_t *, gid_t *, gid_t *); +int setresuid(uid_t, uid_t, uid_t); +int setresgid(gid_t, gid_t, gid_t); +int getgroups(int, gid_t[]); +int setgroups(size_t, const gid_t *); +int initgroups(const char *, gid_t); + +/* ================================================================ + * File operations + * ================================================================ */ + +int chown(const char *, uid_t, gid_t); +int lchown(const char *, uid_t, gid_t); +int fchown(int, uid_t, gid_t); +mode_t umask(mode_t); +int mknod(const char *, mode_t, dev_t); +int mkfifo(const char *, mode_t); +int chroot(const char *); +void sync(void); +int link(const char *, const char *); +int symlink(const char *, const char *); +ssize_t readlink(const char *, char *, size_t); +int truncate(const char *, off_t); +int ftruncate(int, off_t); +int access(const char *, int); +int chdir(const char *); +int fchdir(int); +char *getcwd(char *, size_t); +long pathconf(const char *, int); +long fpathconf(int, int); + +/* Pipe/dup */ +int pipe(int[2]); +int pipe2(int[2], int); +int dup(int); +int dup2(int, int); +int dup3(int, int, int); + +/* Override wasi-libc fcntl (returns EINVAL for F_DUPFD) with host import. */ +int __posix_fcntl3(int, int, int); + +#ifndef O_NDELAY +#define O_NDELAY O_NONBLOCK +#endif + +/* File locking (wasi-libc omits all of these) */ +#ifndef F_RDLCK +#define F_RDLCK 0 +#define F_WRLCK 1 +#define F_UNLCK 2 +#endif +#ifndef F_DUPFD +#define F_DUPFD 0 +#define F_DUPFD_CLOEXEC 1030 +#endif +#ifndef F_GETLK +#define F_GETLK 5 +#define F_SETLK 6 +#define F_SETLKW 7 +#endif + +/* ================================================================ + * Terminal + * ================================================================ */ + +#ifndef TIOCSCTTY +#define TIOCSCTTY 0x540E +#define TIOCNOTTY 0x5422 +#define TIOCGPGRP 0x540F +#define TIOCSPGRP 0x5410 +#define TIOCGWINSZ 0x5413 +#define TIOCSWINSZ 0x5414 +#endif +#ifndef TIOCSTI +#define TIOCSTI 0x5412 +#endif +#ifndef TIOCSSERIAL +#define TIOCSSERIAL 0x541F +#define TIOCGSERIAL 0x541E +#define TIOCSERCONFIG 0x5453 +#endif + +#ifndef _WASI_WINSIZE_DEFINED +#define _WASI_WINSIZE_DEFINED +#define __NEED_struct_winsize +#include +#endif + +pid_t tcgetpgrp(int); +int tcsetpgrp(int, pid_t); +char *ttyname(int); +int ttyname_r(int, char *, size_t); +int isatty(int); + +/* PTY */ +int grantpt(int); +int unlockpt(int); +int ptsname_r(int, char *, size_t); + +/* ================================================================ + * Network + * ================================================================ */ + +struct sockaddr; +struct iovec; + +int socket(int, int, int); +int bind(int, const struct sockaddr *, unsigned int); +int connect(int, const struct sockaddr *, unsigned int); +int listen(int, int); +int accept(int, struct sockaddr *, unsigned int *); +ssize_t send(int, const void *, size_t, int); +ssize_t recv(int, void *, size_t, int); +ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, unsigned int); +ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, unsigned int *); +ssize_t sendmsg(int, const struct msghdr *, int); +ssize_t recvmsg(int, struct msghdr *, int); +int setsockopt(int, int, int, const void *, unsigned int); +int getsockopt(int, int, int, void *, unsigned int *); +int shutdown(int, int); +int getsockname(int, struct sockaddr *, unsigned int *); +int getpeername(int, struct sockaddr *, unsigned int *); +int sethostname(const char *, size_t); +int gethostname(char *, size_t); + +/* CMSG macros (struct msghdr from wasi-libc __struct_msghdr.h) */ +struct cmsghdr { + unsigned int cmsg_len; + int cmsg_level; + int cmsg_type; +}; + +#ifndef CMSG_ALIGN +#define CMSG_ALIGN(len) (((len) + sizeof(long) - 1) & ~(sizeof(long) - 1)) +#define CMSG_LEN(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + (len)) +#define CMSG_SPACE(len) (CMSG_ALIGN(sizeof(struct cmsghdr)) + CMSG_ALIGN(len)) +#define CMSG_DATA(cmsg) ((unsigned char *)((struct cmsghdr *)(cmsg) + 1)) +#define CMSG_FIRSTHDR(mhdr) \ + ((mhdr)->msg_controllen >= sizeof(struct cmsghdr) ? \ + (struct cmsghdr *)(mhdr)->msg_control : (struct cmsghdr *)0) +#define CMSG_NXTHDR(mhdr, cmsg) \ + ((cmsg)->cmsg_len < sizeof(struct cmsghdr) ? (struct cmsghdr *)0 : \ + ((unsigned char *)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len) + \ + sizeof(struct cmsghdr) > \ + (unsigned char *)(mhdr)->msg_control + (mhdr)->msg_controllen) ? \ + (struct cmsghdr *)0 : \ + (struct cmsghdr *)((unsigned char *)(cmsg) + CMSG_ALIGN((cmsg)->cmsg_len))) +#endif + +/* ================================================================ + * Resource limits and priority + * ================================================================ */ + +#ifndef RLIMIT_CORE +typedef unsigned long rlim_t; +#define RLIM_INFINITY (~(rlim_t)0) +struct rlimit { + rlim_t rlim_cur; + rlim_t rlim_max; +}; +#define RLIMIT_FSIZE 1 +#define RLIMIT_DATA 2 +#define RLIMIT_STACK 3 +#define RLIMIT_CORE 4 +#define RLIMIT_RSS 5 +#define RLIMIT_NPROC 6 +#define RLIMIT_NOFILE 7 +#define RLIMIT_AS 9 +int getrlimit(int, struct rlimit *); +int setrlimit(int, const struct rlimit *); +#endif + +#ifndef PRIO_PROCESS +#define PRIO_PROCESS 0 +#define PRIO_PGRP 1 +#define PRIO_USER 2 +#endif + +int getpriority(int, id_t); +int setpriority(int, id_t, int); +int nice(int); + +/* ================================================================ + * Clock and time + * ================================================================ */ + +#include + +#ifndef CLOCK_REALTIME +#define CLOCK_REALTIME 0 +#define CLOCK_MONOTONIC 1 +#endif +#ifndef CLOCK_BOOTTIME +#define CLOCK_BOOTTIME ((clockid_t)7) +#define CLOCK_REALTIME_COARSE ((clockid_t)5) +#define CLOCK_MONOTONIC_COARSE ((clockid_t)6) +#endif + +int clock_settime(clockid_t, const struct timespec *); +void tzset(void); + +struct timeval; +int settimeofday(const struct timeval *, const void *); +int gettimeofday(struct timeval *, void *); +unsigned int alarm(unsigned int); +int pause(void); + +/* ================================================================ + * Syslog + * ================================================================ */ + +#ifndef LOG_AUTH +#define LOG_AUTH (4<<3) +#define LOG_AUTHPRIV (10<<3) +#define LOG_CONS 0x02 +#endif + +/* ================================================================ + * CPU affinity + * ================================================================ */ + +#ifndef CPU_SETSIZE +#define CPU_SETSIZE 1024 +typedef struct { + unsigned long __bits[CPU_SETSIZE / (8 * sizeof(unsigned long))]; +} cpu_set_t; +int sched_getaffinity(pid_t, size_t, cpu_set_t *); +int sched_setaffinity(pid_t, size_t, const cpu_set_t *); +#endif + +/* ================================================================ + * Sysconf + * ================================================================ */ + +long sysconf(int); + +#ifndef _SC_CLK_TCK +#define _SC_CLK_TCK 2 +#define _SC_OPEN_MAX 4 +#define _SC_PAGESIZE 30 +#define _SC_PAGE_SIZE _SC_PAGESIZE +#define _SC_NPROCESSORS_CONF 83 +#define _SC_NPROCESSORS_ONLN 84 +#define _SC_PHYS_PAGES 85 +#endif + +/* ================================================================ + * Block device and ioctl + * ================================================================ */ + +#ifndef BLKFLSBUF +#define BLKFLSBUF 0x1261 +#define BLKGETSIZE 0x1260 +#define BLKGETSIZE64 0x80081272 +#endif + +#ifndef _IO +#define _IO(type,nr) ((type)<<8|(nr)) +#define _IOR(type,nr,size) _IO(type,nr) +#define _IOW(type,nr,size) _IO(type,nr) +#define _IOWR(type,nr,size) _IO(type,nr) +#endif + +/* ================================================================ + * Misc + * ================================================================ */ + +struct spwd; +int getspnam_r(const char *, struct spwd *, char *, size_t, struct spwd **); + +int mkstemp(char *); +int mkostemp(char *, int); +int mkstemps(char *, int); +char *mkdtemp(char *); + +#ifndef TP_STATUS_CSUMNOTREADY +#define TP_STATUS_CSUMNOTREADY (1 << 3) +#endif + +#endif /* _WASI_POSIX_FIXUPS_H */ +#endif /* \!__ASSEMBLER__ */ diff --git a/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wordexp.h b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wordexp.h new file mode 100644 index 00000000000..1fa56548675 --- /dev/null +++ b/toolchain/toolchain-external/toolchain-external-wasi-sdk/wasi-stubs/wordexp.h @@ -0,0 +1,18 @@ +#ifndef _WORDEXP_H +#define _WORDEXP_H +#include +#define WRDE_DOOFFS 1 +#define WRDE_APPEND 2 +#define WRDE_NOCMD 4 +#define WRDE_REUSE 8 +#define WRDE_SHOWERR 16 +#define WRDE_UNDEF 32 +#define WRDE_BADCHAR 1 +#define WRDE_BADVAL 2 +#define WRDE_CMDSUB 3 +#define WRDE_NOSPACE 4 +#define WRDE_SYNTAX 5 +typedef struct { size_t we_wordc; char **we_wordv; size_t we_offs; } wordexp_t; +int wordexp(const char *s, wordexp_t *p, int flags); +void wordfree(wordexp_t *p); +#endif From 98b7b2f5f4820ae2f8b34f2ef60aab25dc090558 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 28 Apr 2026 12:56:04 -0700 Subject: [PATCH 32/39] package/codex: add codex cli Signed-off-by: Christian Stewart --- package/Config.in | 1 + .../0001-code-mode-runtime-optional.patch | 323 ++++++++++++++++++ package/codex/Config.in | 11 + package/codex/codex.mk | 16 + package/pkg-cargo.mk | 11 +- 5 files changed, 361 insertions(+), 1 deletion(-) create mode 100644 package/codex/0001-code-mode-runtime-optional.patch create mode 100644 package/codex/Config.in create mode 100644 package/codex/codex.mk diff --git a/package/Config.in b/package/Config.in index a47986cc19a..fea2f34c236 100644 --- a/package/Config.in +++ b/package/Config.in @@ -170,6 +170,7 @@ menu "Development tools" source "package/bustle/Config.in" source "package/check/Config.in" source "package/cmake/Config.in" + source "package/codex/Config.in" source "package/cppunit/Config.in" source "package/cukinia/Config.in" source "package/cunit/Config.in" diff --git a/package/codex/0001-code-mode-runtime-optional.patch b/package/codex/0001-code-mode-runtime-optional.patch new file mode 100644 index 00000000000..6a45541e89e --- /dev/null +++ b/package/codex/0001-code-mode-runtime-optional.patch @@ -0,0 +1,323 @@ +diff --git i/codex-rs/Cargo.toml w/codex-rs/Cargo.toml +index d39651f..8068538 100644 +--- i/codex-rs/Cargo.toml ++++ w/codex-rs/Cargo.toml +@@ -135,7 +135,7 @@ codex-collaboration-mode-templates = { path = "collaboration-mode-templates" } + codex-cloud-requirements = { path = "cloud-requirements" } + codex-cloud-tasks-client = { path = "cloud-tasks-client" } + codex-cloud-tasks-mock-client = { path = "cloud-tasks-mock-client" } +-codex-code-mode = { path = "code-mode" } ++codex-code-mode = { path = "code-mode", default-features = false } + codex-config = { path = "config" } + codex-connectors = { path = "connectors" } + codex-core = { path = "core" } +diff --git i/codex-rs/code-mode/Cargo.toml w/codex-rs/code-mode/Cargo.toml +index 23b2ce2..12c258d 100644 +--- i/codex-rs/code-mode/Cargo.toml ++++ w/codex-rs/code-mode/Cargo.toml +@@ -12,17 +12,21 @@ path = "src/lib.rs" + [lints] + workspace = true + ++[features] ++default = ["runtime"] ++runtime = ["dep:deno_core_icudata", "dep:v8"] ++ + [dependencies] + async-channel = { workspace = true } + async-trait = { workspace = true } + codex-protocol = { workspace = true } +-deno_core_icudata = { workspace = true } ++deno_core_icudata = { workspace = true, optional = true } + serde = { workspace = true, features = ["derive"] } + serde_json = { workspace = true } + tokio = { workspace = true, features = ["macros", "rt", "sync", "time"] } + tokio-util = { workspace = true, features = ["rt"] } + tracing = { workspace = true } +-v8 = { workspace = true } ++v8 = { workspace = true, optional = true } + + [dev-dependencies] + pretty_assertions = { workspace = true } +diff --git i/codex-rs/code-mode/src/lib.rs w/codex-rs/code-mode/src/lib.rs +index bf0ce69..1b25601 100644 +--- i/codex-rs/code-mode/src/lib.rs ++++ w/codex-rs/code-mode/src/lib.rs +@@ -1,7 +1,13 @@ + mod description; + mod response; ++#[cfg(feature = "runtime")] + mod runtime; ++#[cfg(not(feature = "runtime"))] ++mod runtime_disabled; ++#[cfg(feature = "runtime")] + mod service; ++#[cfg(not(feature = "runtime"))] ++mod service_disabled; + + pub use description::CODE_MODE_PRAGMA_PREFIX; + pub use description::CodeModeToolKind; +@@ -18,17 +24,20 @@ pub use description::render_json_schema_to_typescript; + pub use response::DEFAULT_IMAGE_DETAIL; + pub use response::FunctionCallOutputContentItem; + pub use response::ImageDetail; +-pub use runtime::CodeModeNestedToolCall; +-pub use runtime::DEFAULT_EXEC_YIELD_TIME_MS; +-pub use runtime::DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL; +-pub use runtime::DEFAULT_WAIT_YIELD_TIME_MS; +-pub use runtime::ExecuteRequest; +-pub use runtime::RuntimeResponse; +-pub use runtime::WaitOutcome; +-pub use runtime::WaitRequest; +-pub use service::CodeModeService; +-pub use service::CodeModeTurnHost; +-pub use service::CodeModeTurnWorker; ++#[cfg(feature = "runtime")] ++pub use runtime::{ ++ CodeModeNestedToolCall, DEFAULT_EXEC_YIELD_TIME_MS, DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL, ++ DEFAULT_WAIT_YIELD_TIME_MS, ExecuteRequest, RuntimeResponse, WaitOutcome, WaitRequest, ++}; ++#[cfg(not(feature = "runtime"))] ++pub use runtime_disabled::{ ++ CodeModeNestedToolCall, DEFAULT_EXEC_YIELD_TIME_MS, DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL, ++ DEFAULT_WAIT_YIELD_TIME_MS, ExecuteRequest, RuntimeResponse, WaitOutcome, WaitRequest, ++}; ++#[cfg(feature = "runtime")] ++pub use service::{CodeModeService, CodeModeTurnHost, CodeModeTurnWorker}; ++#[cfg(not(feature = "runtime"))] ++pub use service_disabled::{CodeModeService, CodeModeTurnHost, CodeModeTurnWorker}; + + pub const PUBLIC_TOOL_NAME: &str = "exec"; + pub const WAIT_TOOL_NAME: &str = "wait"; +diff --git i/codex-rs/code-mode/src/runtime_disabled.rs w/codex-rs/code-mode/src/runtime_disabled.rs +new file mode 100644 +index 0000000..23d4215 +--- /dev/null ++++ w/codex-rs/code-mode/src/runtime_disabled.rs +@@ -0,0 +1,76 @@ ++use std::collections::HashMap; ++ ++use codex_protocol::ToolName; ++use serde::Serialize; ++use serde_json::Value as JsonValue; ++ ++use crate::response::FunctionCallOutputContentItem; ++use crate::ToolDefinition; ++ ++pub const DEFAULT_EXEC_YIELD_TIME_MS: u64 = 1_000; ++pub const DEFAULT_WAIT_YIELD_TIME_MS: u64 = 1_000; ++pub const DEFAULT_MAX_OUTPUT_TOKENS_PER_EXEC_CALL: usize = 8_000; ++ ++#[derive(Debug)] ++pub struct ExecuteRequest { ++ pub cell_id: String, ++ pub tool_call_id: String, ++ pub enabled_tools: Vec, ++ pub source: String, ++ pub stored_values: HashMap, ++ pub yield_time_ms: Option, ++ pub max_output_tokens: Option, ++} ++ ++#[derive(Debug, Serialize)] ++pub enum RuntimeResponse { ++ Yielded { ++ cell_id: String, ++ content_items: Vec, ++ }, ++ Terminated { ++ cell_id: String, ++ content_items: Vec, ++ }, ++ Result { ++ cell_id: String, ++ content_items: Vec, ++ stored_values: HashMap, ++ error_text: Option, ++ }, ++} ++ ++pub struct WaitRequest { ++ pub cell_id: String, ++ pub yield_time_ms: u64, ++ pub terminate: bool, ++} ++ ++pub enum WaitOutcome { ++ MissingCell, ++ LiveCell(RuntimeResponse), ++} ++ ++impl From for RuntimeResponse { ++ fn from(value: WaitOutcome) -> Self { ++ match value { ++ WaitOutcome::LiveCell(response) => response, ++ WaitOutcome::MissingCell => RuntimeResponse::Result { ++ cell_id: String::new(), ++ content_items: vec![FunctionCallOutputContentItem::InputText { ++ text: "code mode runtime is not available in this build".to_string(), ++ }], ++ stored_values: HashMap::new(), ++ error_text: Some("code mode runtime is not available in this build".to_string()), ++ }, ++ } ++ } ++} ++ ++#[derive(Debug)] ++pub struct CodeModeNestedToolCall { ++ pub cell_id: String, ++ pub runtime_tool_call_id: String, ++ pub tool_name: ToolName, ++ pub input: Option, ++} +diff --git i/codex-rs/code-mode/src/service_disabled.rs w/codex-rs/code-mode/src/service_disabled.rs +new file mode 100644 +index 0000000..099c300 +--- /dev/null ++++ w/codex-rs/code-mode/src/service_disabled.rs +@@ -0,0 +1,61 @@ ++use std::collections::HashMap; ++use std::sync::Arc; ++ ++use async_trait::async_trait; ++use serde_json::Value as JsonValue; ++use tokio_util::sync::CancellationToken; ++ ++use crate::runtime_disabled::CodeModeNestedToolCall; ++use crate::runtime_disabled::ExecuteRequest; ++use crate::runtime_disabled::RuntimeResponse; ++use crate::runtime_disabled::WaitOutcome; ++use crate::runtime_disabled::WaitRequest; ++ ++#[async_trait] ++pub trait CodeModeTurnHost: Send + Sync { ++ async fn invoke_tool( ++ &self, ++ invocation: CodeModeNestedToolCall, ++ cancellation_token: CancellationToken, ++ ) -> Result; ++ ++ async fn notify(&self, call_id: String, cell_id: String, text: String) -> Result<(), String>; ++} ++ ++pub struct CodeModeService; ++ ++impl CodeModeService { ++ pub fn new() -> Self { ++ Self ++ } ++ ++ pub async fn stored_values(&self) -> HashMap { ++ HashMap::new() ++ } ++ ++ pub async fn replace_stored_values(&self, _values: HashMap) {} ++ ++ pub fn allocate_cell_id(&self) -> String { ++ String::new() ++ } ++ ++ pub async fn execute(&self, _request: ExecuteRequest) -> Result { ++ Err("code mode runtime is not available in this build".to_string()) ++ } ++ ++ pub async fn wait(&self, _request: WaitRequest) -> Result { ++ Err("code mode runtime is not available in this build".to_string()) ++ } ++ ++ pub fn start_turn_worker(&self, _host: Arc) -> CodeModeTurnWorker { ++ CodeModeTurnWorker ++ } ++} ++ ++impl Default for CodeModeService { ++ fn default() -> Self { ++ Self::new() ++ } ++} ++ ++pub struct CodeModeTurnWorker; +diff --git i/codex-rs/linux-sandbox/src/landlock.rs w/codex-rs/linux-sandbox/src/landlock.rs +index 5794982..644cde1 100644 +--- i/codex-rs/linux-sandbox/src/landlock.rs ++++ w/codex-rs/linux-sandbox/src/landlock.rs +@@ -2,6 +2,7 @@ + //! + //! Filesystem restrictions are enforced by bubblewrap in `linux_run_main`. + //! Landlock helpers remain available here as legacy/backup utilities. ++#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] + use std::collections::BTreeMap; + use std::path::Path; + +@@ -21,15 +22,11 @@ use landlock::Compatible; + use landlock::Ruleset; + use landlock::RulesetAttr; + use landlock::RulesetCreatedAttr; +-use seccompiler::BpfProgram; +-use seccompiler::SeccompAction; +-use seccompiler::SeccompCmpArgLen; +-use seccompiler::SeccompCmpOp; +-use seccompiler::SeccompCondition; +-use seccompiler::SeccompFilter; +-use seccompiler::SeccompRule; +-use seccompiler::TargetArch; +-use seccompiler::apply_filter; ++#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] ++use seccompiler::{ ++ BpfProgram, SeccompAction, SeccompCmpArgLen, SeccompCmpOp, SeccompCondition, SeccompFilter, ++ SeccompRule, TargetArch, apply_filter, ++}; + + /// Apply sandbox policies inside this thread so only the child inherits + /// them, not the entire CLI process. +@@ -106,7 +103,9 @@ fn network_seccomp_mode( + allow_network_for_proxy: bool, + proxy_routed_network: bool, + ) -> Option { +- if !should_install_network_seccomp(network_sandbox_policy, allow_network_for_proxy) { ++ if !network_seccomp_supported() ++ || !should_install_network_seccomp(network_sandbox_policy, allow_network_for_proxy) ++ { + None + } else if proxy_routed_network { + Some(NetworkSeccompMode::ProxyRouted) +@@ -115,6 +114,16 @@ fn network_seccomp_mode( + } + } + ++#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] ++fn network_seccomp_supported() -> bool { ++ true ++} ++ ++#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] ++fn network_seccomp_supported() -> bool { ++ false ++} ++ + /// Enable `PR_SET_NO_NEW_PRIVS` so seccomp can be applied safely. + fn set_no_new_privs() -> Result<()> { + let result = unsafe { libc::prctl(libc::PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) }; +@@ -165,6 +174,7 @@ fn install_filesystem_landlock_rules_on_current_thread( + /// + /// The filter is applied to the current thread so only the sandboxed child + /// inherits it. ++#[cfg(any(target_arch = "x86_64", target_arch = "aarch64"))] + fn install_network_seccomp_filter_on_current_thread( + mode: NetworkSeccompMode, + ) -> std::result::Result<(), SandboxErr> { +@@ -263,6 +273,13 @@ fn install_network_seccomp_filter_on_current_thread( + Ok(()) + } + ++#[cfg(not(any(target_arch = "x86_64", target_arch = "aarch64")))] ++fn install_network_seccomp_filter_on_current_thread( ++ _mode: NetworkSeccompMode, ++) -> std::result::Result<(), SandboxErr> { ++ Ok(()) ++} ++ + #[cfg(test)] + mod tests { + use super::NetworkSeccompMode; diff --git a/package/codex/Config.in b/package/codex/Config.in new file mode 100644 index 00000000000..2cb5e2c44ed --- /dev/null +++ b/package/codex/Config.in @@ -0,0 +1,11 @@ +config BR2_PACKAGE_CODEX + bool "codex" + depends on BR2_PACKAGE_HOST_RUSTC_TARGET_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_RUSTC + select BR2_PACKAGE_LIBCAP + select BR2_PACKAGE_OPENSSL + select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL + help + Codex CLI is a coding agent that runs locally in a terminal. + + https://github.com/openai/codex diff --git a/package/codex/codex.mk b/package/codex/codex.mk new file mode 100644 index 00000000000..b03d2fb2208 --- /dev/null +++ b/package/codex/codex.mk @@ -0,0 +1,16 @@ +################################################################################ +# +# codex +# +################################################################################ + +CODEX_VERSION = 0670d8971a80e8890263380f4e7f04d529f55d72 +CODEX_SITE = $(call github,openai,codex,$(CODEX_VERSION)) +CODEX_LICENSE = Apache-2.0 +CODEX_LICENSE_FILES = LICENSE +CODEX_DEPENDENCIES = host-pkgconf libcap openssl +CODEX_SUBDIR = codex-rs/cli +CODEX_CARGO_BUILD_OPTS = --package codex-cli --bin codex +CODEX_CARGO_INSTALL_OPTS = --bin codex + +$(eval $(cargo-package)) diff --git a/package/pkg-cargo.mk b/package/pkg-cargo.mk index 47a6353f259..34bbaff4dd4 100644 --- a/package/pkg-cargo.mk +++ b/package/pkg-cargo.mk @@ -51,7 +51,16 @@ PKG_CARGO_ENV = \ CARGO_TARGET_APPLIES_TO_HOST="false" \ CARGO_BUILD_TARGET="$(RUSTC_TARGET_NAME)" \ CARGO_HOST_RUSTFLAGS="$(addprefix -C link-args=,$(HOST_LDFLAGS))" \ - CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc + CARGO_TARGET_$(call UPPERCASE,$(RUSTC_TARGET_NAME))_LINKER=$(notdir $(TARGET_CROSS))gcc \ + HOST_CC="$(HOSTCC_NOCCACHE)" \ + HOST_CXX="$(HOSTCXX_NOCCACHE)" \ + HOST_AR="$(HOSTAR)" \ + CC_$(subst -,_,$(RUSTC_HOST_NAME))="$(HOSTCC_NOCCACHE)" \ + CXX_$(subst -,_,$(RUSTC_HOST_NAME))="$(HOSTCXX_NOCCACHE)" \ + AR_$(subst -,_,$(RUSTC_HOST_NAME))="$(HOSTAR)" \ + CC_$(subst -,_,$(RUSTC_TARGET_NAME))="$(TARGET_CC)" \ + CXX_$(subst -,_,$(RUSTC_TARGET_NAME))="$(TARGET_CXX)" \ + AR_$(subst -,_,$(RUSTC_TARGET_NAME))="$(TARGET_AR)" # We always set both CARGO_PROFILE_DEV and CARGO_PROFILE_RELEASE # as we are unable to select a build profile using the environment. From 8a172eb62cb01984e676aa09ab988f20abed9e4a Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Sun, 31 May 2026 01:49:41 -0700 Subject: [PATCH 33/39] package/pahole: fix host build with gcc 16 Carry the upstream namespace__fprintf warning fix and compare BTF function prototype parameter types so host-pahole 1.28 builds with GCC 16 -Werror. Fix kfunc const warning with gcc 16. Fix string const warnings with gcc 16. Signed-off-by: Christian Stewart --- ...ompare-function-prototype-parameters.patch | 37 +++++++ ...le-keep-string-search-pointers-const.patch | 99 +++++++++++++++++++ 2 files changed, 136 insertions(+) create mode 100644 package/pahole/0002-btf-encoder-compare-function-prototype-parameters.patch create mode 100644 package/pahole/0004-pahole-keep-string-search-pointers-const.patch diff --git a/package/pahole/0002-btf-encoder-compare-function-prototype-parameters.patch b/package/pahole/0002-btf-encoder-compare-function-prototype-parameters.patch new file mode 100644 index 00000000000..840a5c36e58 --- /dev/null +++ b/package/pahole/0002-btf-encoder-compare-function-prototype-parameters.patch @@ -0,0 +1,37 @@ +From 52a2f866426ec86fa1919e1e01d6d5fc9b9b7f35 Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Sun, 31 May 2026 01:45:00 -0700 +Subject: [PATCH] btf_encoder: compare function prototype parameters + +GCC 16 reports the BTF_KIND_FUNC_PROTO parameter pointers as set but +unused because types__match() only increments them. The loop already +checked the function return type before iterating, but then compared the +same return type once per parameter instead of comparing each parameter +type. + +Use the current BTF parameter entries inside the loop. This removes the +warning and makes prototype matching reject mismatched parameter types. + +Upstream: not submitted +Signed-off-by: Christian Stewart +--- + btf_encoder.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/btf_encoder.c b/btf_encoder.c +index 3754884..c0a5b47 100644 +--- a/btf_encoder.c ++++ b/btf_encoder.c +@@ -1017,8 +1017,8 @@ static bool types__match(struct btf_encoder *encoder, + btf2, t2->type)) + return false; + for (i = 0; i < vlen; i++, p1++, p2++) { +- if (!types__match(encoder, btf1, t1->type, +- btf2, t2->type)) ++ if (!types__match(encoder, btf1, p1->type, ++ btf2, p2->type)) + return false; + } + return true; +-- +2.49.0 diff --git a/package/pahole/0004-pahole-keep-string-search-pointers-const.patch b/package/pahole/0004-pahole-keep-string-search-pointers-const.patch new file mode 100644 index 00000000000..0704a0b3186 --- /dev/null +++ b/package/pahole/0004-pahole-keep-string-search-pointers-const.patch @@ -0,0 +1,99 @@ +From 7af4d8f0b5b976af32401fcde4d04da577f8a28d Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Sun, 7 Jun 2026 01:02:00 -0700 +Subject: [PATCH] pahole: keep string search pointers const + +GCC 16 diagnoses strchr() results from const input strings when they are stored +in mutable char pointers. Keep the initial search results const, then use +mutable pointers only after the code has copied the strings into owned storage. + +This preserves the existing parsing behavior while fixing the host build when +warnings are treated as errors. + +Upstream: not submitted +Signed-off-by: Christian Stewart +--- + btf_encoder.c | 2 +- + pahole.c | 16 ++++++++-------- + 2 files changed, 9 insertions(+), 9 deletions(-) + +--- a/btf_encoder.c ++++ b/btf_encoder.c +@@ -1202 +1202 @@ static bool str_contains_non_fn_suffix(const char *str) { +- char *suffix = strchr(str, '.'); ++ const char *suffix = strchr(str, '.'); + +--- a/pahole.c ++++ b/pahole.c +@@ -2448,9 +2448,9 @@ + int byte_offset = 0; + + if (!member) { +- char *sep = strchr(member_name_orig, '.'); ++ const char *orig_sep = strchr(member_name_orig, '.'); + +- if (!sep) ++ if (!orig_sep) + return -1; + + char *member_name_alloc = strdup(member_name_orig); +@@ -2461,7 +2461,7 @@ + char *member_name = member_name_alloc; + struct type *type = instance->type; + +- sep = member_name_alloc + (sep - member_name_orig); ++ char *sep = member_name_alloc + (orig_sep - member_name_orig); + *sep = 0; + + while (1) { +@@ -2915,7 +2915,7 @@ + + strcpy(prototype->name, expression); + +- const char *name = prototype->name; ++ char *name = prototype->name; + + prototype->nr_args = 0; + +@@ -3079,9 +3079,9 @@ + return type__add_type_enum(type, te, cu); + + // Now look at a 'virtual enum', i.e. the concatenation of multiple enums +- char *sep = strchr(type_enum, '+'); ++ const char *orig_sep = strchr(type_enum, '+'); + +- if (!sep) ++ if (!orig_sep) + return -1; + + char *type_enums = strdup(type_enum); +@@ -3091,13 +3091,13 @@ + + int ret = -1; + +- sep = type_enums + (sep - type_enum); ++ char *sep = type_enums + (orig_sep - type_enum); + +- type_enum = type_enums; ++ char *type_enum_name = type_enums; + *sep = '\0'; + + while (1) { +- te = cu__find_enumeration_by_name(cu, type_enum, NULL); ++ te = cu__find_enumeration_by_name(cu, type_enum_name, NULL); + + if (!te) + goto out; +@@ -3108,8 +3108,8 @@ + + if (sep == NULL) + break; +- type_enum = sep + 1; +- sep = strchr(type_enum, '+'); ++ type_enum_name = sep + 1; ++ sep = strchr(type_enum_name, '+'); + } + + ret = 0; +-- +2.49.0 From 4cb1fe11434d60fee611e2c79c77e6781d7581f3 Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 22 Jun 2026 10:02:21 -0700 Subject: [PATCH 34/39] package/network-manager: remove initrd units Signed-off-by: Christian Stewart --- package/network-manager/network-manager.mk | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/package/network-manager/network-manager.mk b/package/network-manager/network-manager.mk index bf4f29c3cc7..a549bc1ce13 100644 --- a/package/network-manager/network-manager.mk +++ b/package/network-manager/network-manager.mk @@ -197,4 +197,12 @@ define NETWORK_MANAGER_INSTALL_INIT_SYSTEMD endef +define NETWORK_MANAGER_REMOVE_INITRD_UNITS + rm -f \ + $(TARGET_DIR)/usr/lib/systemd/system/NetworkManager-config-initrd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/NetworkManager-initrd.service \ + $(TARGET_DIR)/usr/lib/systemd/system/NetworkManager-wait-online-initrd.service +endef +NETWORK_MANAGER_POST_INSTALL_TARGET_HOOKS += NETWORK_MANAGER_REMOVE_INITRD_UNITS + $(eval $(meson-package)) From 466c9e06a74bb0cfb6764afa965bc7c2cb509a8a Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Tue, 23 Jun 2026 10:54:07 -0700 Subject: [PATCH 35/39] package/network-manager: set target modprobe path NetworkManager Meson searches PATH for modprobe when the option is unset. Buildroot target configure runs with HOST_DIR/bin and HOST_DIR/sbin first in BR_PATH, so it can compile the host modprobe path into the target daemon. Pass the target modprobe path explicitly, matching the existing iptables paths. Related: https://github.com/skiffos/SkiffOS/issues/357 Signed-off-by: Christian Stewart --- package/network-manager/network-manager.mk | 1 + 1 file changed, 1 insertion(+) diff --git a/package/network-manager/network-manager.mk b/package/network-manager/network-manager.mk index a549bc1ce13..cc7a1eee6ce 100644 --- a/package/network-manager/network-manager.mk +++ b/package/network-manager/network-manager.mk @@ -31,6 +31,7 @@ NETWORK_MANAGER_CONF_OPTS = \ -Dqt=false \ -Diptables=/usr/sbin/iptables \ -Dip6tables=/usr/sbin/ip6tables \ + -Dmodprobe=/sbin/modprobe \ -Difupdown=false \ -Dnm_cloud_setup=false \ -Dsession_tracking_consolekit=false From cf55524be83ac2acf96d57ab05760fbb6966815d Mon Sep 17 00:00:00 2001 From: Christian Stewart Date: Mon, 13 Jul 2026 13:23:43 -0700 Subject: [PATCH 36/39] package/go: security bump to version 1.26.5 Fixes the following security issues: CVE-2026-39822: os: root escape via symlink plus trailing slash go1.26.5 (released 2026-07-07) includes security fixes to the crypto/tls and os packages, as well as bug fixes to the compiler, the runtime, the go command, and the net, os, and syscall packages. https://go.dev/doc/devel/release#go1.26.5 Signed-off-by: Christian Stewart --- package/go/go.hash | 14 +++++++------- package/go/go.mk | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package/go/go.hash b/package/go/go.hash index 69f2a3139c8..6c9c20be69e 100644 --- a/package/go/go.hash +++ b/package/go/go.hash @@ -1,9 +1,9 @@ # sha256 checksum from https://go.dev/dl/ -sha256 1c646875d0aa8799133184ed57cf79ff24bdefe8c8820470602a9d3d6d9192b8 go1.26.3.src.tar.gz -sha256 0ef3626a149b5811c813838c62b7d6618d03ea36047b32c90b0e4851cc42b1fa go1.26.3.linux-386.tar.gz -sha256 2b2cfc7148493da5e73981bffbf3353af381d5f93e789c82c79aff64962eb556 go1.26.3.linux-amd64.tar.gz -sha256 9d89a3ea57d141c2b22d70083f2c8459ba3890f2d9e818e7e933b75614936565 go1.26.3.linux-arm64.tar.gz -sha256 d44133d4c66b1451a1e247da26db7716f76a081c0169a75e6c84e1871e394320 go1.26.3.linux-armv6l.tar.gz -sha256 dbd82b50530ead2beb1fd72215117380df3cb16332b51467116dc35b3691dd75 go1.26.3.linux-ppc64le.tar.gz -sha256 5c0605b7175449f1c8e8cb02efaba2695caab914fad4dcedc764c2f4c6dfe6ca go1.26.3.linux-s390x.tar.gz +sha256 495be4bc87176ac567392e5b4116abd98466d33d7b49d41e764ccc6976b2dc42 go1.26.5.src.tar.gz +sha256 88c162b204e6eefcc32499453b492e80209f4a4c78c33092636901c540fb0d05 go1.26.5.linux-386.tar.gz +sha256 5c2c3b16caefa1d968a94c1daca04a7ca301a496d9b086e17ad77bb81393f053 go1.26.5.linux-amd64.tar.gz +sha256 fe4789e92b1f33358680864bbe8704289e7bb5fc207d80623c308935bd696d49 go1.26.5.linux-arm64.tar.gz +sha256 6dae9edab81c13bccf962dec15f1fd2ec26c14a6821b4d2c92dab4130c289d7a go1.26.5.linux-armv6l.tar.gz +sha256 c5d60e2b303bb612f20cd82786594b64874e73b35134025e27d3390bf284ae43 go1.26.5.linux-ppc64le.tar.gz +sha256 09ce3c504c0323968b75a717244dca4f25cd4cf0443e5ff6bc0bfa74add89fa7 go1.26.5.linux-s390x.tar.gz sha256 911f8f5782931320f5b8d1160a76365b83aea6447ee6c04fa6d5591467db9dad LICENSE diff --git a/package/go/go.mk b/package/go/go.mk index ebd0d418efa..a64d7538f85 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -4,7 +4,7 @@ # ################################################################################ -GO_VERSION = 1.26.3 +GO_VERSION = 1.26.5 HOST_GO_GOPATH = $(HOST_DIR)/share/go-path HOST_GO_HOST_CACHE = $(HOST_DIR)/share/host-go-cache From e84bfc7ffcdaf9aad04c404fdaaec5bdb130ef7e Mon Sep 17 00:00:00 2001 From: Rainer Schueler Date: Mon, 3 Aug 2026 17:07:06 +0200 Subject: [PATCH 37/39] package/containerd: security bump to v2.0.11 Fixes three advisories published on 2026-07-01 and addressed by containerd on 2026-07-09 across all maintained branches: CVE-2026-53488 critical image-config LABEL flows to a host-root command (>= 2.0.0, < 2.0.10) CVE-2026-47262 medium image-triggered runtime DoS via unbounded group parsing (>= 2.0.0, < 2.0.10) CVE-2026-46680 medium user ID handling bypass allows runAsNonRoot evasion (>= 2.0.4, fixed in 2.0.9) 2.0.11 is the current release of the 2.0.x branch, so this stays within the series already packaged rather than moving to 2.3.x. Signed-off-by: Rainer Schueler --- package/containerd/containerd.hash | 2 +- package/containerd/containerd.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/containerd/containerd.hash b/package/containerd/containerd.hash index 0916c603bb7..410e5d61e13 100644 --- a/package/containerd/containerd.hash +++ b/package/containerd/containerd.hash @@ -1,3 +1,3 @@ # Computed locally -sha256 2bbf9fedcf4ab31736fcb3ce224ef22610a87da9d53bbd8f6d205710fd849831 containerd-2.0.7-go2.tar.gz +sha256 eadaa5301c0f633f6fed6a3b22f5cf4343ac522401ad2e84bb3299f811a35976 containerd-2.0.11-go2.tar.gz sha256 4bbe3b885e8cd1907ab4cf9a41e862e74e24b5422297a4f2fe524e6a30ada2b4 LICENSE diff --git a/package/containerd/containerd.mk b/package/containerd/containerd.mk index a334f0fdac0..4a3a371ee49 100644 --- a/package/containerd/containerd.mk +++ b/package/containerd/containerd.mk @@ -4,7 +4,7 @@ # ################################################################################ -CONTAINERD_VERSION = 2.0.7 +CONTAINERD_VERSION = 2.0.11 CONTAINERD_SITE = $(call github,containerd,containerd,v$(CONTAINERD_VERSION)) CONTAINERD_LICENSE = Apache-2.0 CONTAINERD_LICENSE_FILES = LICENSE From 451abe28edb2f88c88a955a2bf22c7db64ad3ef6 Mon Sep 17 00:00:00 2001 From: Rainer Schueler Date: Mon, 3 Aug 2026 22:13:35 +0200 Subject: [PATCH 38/39] package/docker-compose: security bump to v2.40.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CVE-2025-62725 (CVSS 8.9, CWE-22, EPSS 0.137 / 96th percentile) — path traversal through remote OCI compose artifacts. When a layer carries the annotations com.docker.compose.extends or com.docker.compose.envfile, Compose joins the attacker-supplied value from com.docker.compose.file / com.docker.compose.envfile with its local cache directory and writes there. The path is never constrained to that directory, so a crafted artifact can overwrite arbitrary files as the user running compose. Two things make this worse than a typical container-image issue: no container is ever started — resolving the artifact is enough, so read-only commands such as `docker compose config` or `docker compose ps` trigger it — and it applies to every workflow that resolves remote OCI compose artifacts, including CI runners. Fixed upstream in v2.40.2 (commit 69bcb96), GHSA-gv8h-7v7w-r22q. Hash regenerated from the go-vendored tarball produced by the download post-process; the LICENSE hash is unchanged. Signed-off-by: Rainer Schueler --- package/docker-compose/docker-compose.hash | 2 +- package/docker-compose/docker-compose.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package/docker-compose/docker-compose.hash b/package/docker-compose/docker-compose.hash index a2ffadd31c0..d3425213ea7 100644 --- a/package/docker-compose/docker-compose.hash +++ b/package/docker-compose/docker-compose.hash @@ -1,3 +1,3 @@ # Locally computed -sha256 0c0453729b7a37badcf530fc140b1b8b907cbdcecfdb6be6413f410c86665c70 docker-compose-2.38.2-go2.tar.gz +sha256 b802416067c94abf958544156ca30d4bc9ff99d2b5314012d6c9d6b76f3f1437 docker-compose-2.40.2-go2.tar.gz sha256 58d1e17ffe5109a7ae296caafcadfdbe6a7d176f0bc4ab01e12a689b0499d8bd LICENSE diff --git a/package/docker-compose/docker-compose.mk b/package/docker-compose/docker-compose.mk index f70cf725df9..bcc0e68e6c0 100644 --- a/package/docker-compose/docker-compose.mk +++ b/package/docker-compose/docker-compose.mk @@ -4,7 +4,7 @@ # ################################################################################ -DOCKER_COMPOSE_VERSION = 2.38.2 +DOCKER_COMPOSE_VERSION = 2.40.2 DOCKER_COMPOSE_SITE = $(call github,docker,compose,v$(DOCKER_COMPOSE_VERSION)) DOCKER_COMPOSE_LICENSE = Apache-2.0 DOCKER_COMPOSE_LICENSE_FILES = LICENSE From 2ca4a244863351818221deb5fe9c29c495402abb Mon Sep 17 00:00:00 2001 From: Rainer Schueler Date: Mon, 3 Aug 2026 22:13:35 +0200 Subject: [PATCH 39/39] package/runc: security bump to v1.3.6 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit CVE-2026-41579 (CVSS 3.3) — affects versions prior to 1.3.6, 1.4.0-rc.1, 1.4.0-rc.12, 1.5.0-rc.1 and 1.5.0-rc.1, in the container setup path. Low severity, but the bump is a patch release inside the 1.3.x series and carries no interface change, so there is little reason to carry the finding instead. Drops 0001-Replace-os.Is-error-checking-functions-with-their-er.patch. That patch backported upstream runc 536e183451b7 ("Replace os.Is error checking functions with their errors.Is counterpart"), which is contained in 1.3.6 — validator.go, criu_linux.go, device_unix.go and the rest of the files it touched already use errors.Is. Keeping it makes the build fail at the patch step, which is how this was found. The only remaining os.Is* callers in 1.3.6 are integration tests and vendored third-party code, neither of which the patch addressed. Hash regenerated from the go-vendored tarball; the LICENSE hash is unchanged. Signed-off-by: Rainer Schueler --- ...ror-checking-functions-with-their-er.patch | 400 ------------------ package/runc/runc.hash | 2 +- package/runc/runc.mk | 2 +- 3 files changed, 2 insertions(+), 402 deletions(-) delete mode 100644 package/runc/0001-Replace-os.Is-error-checking-functions-with-their-er.patch diff --git a/package/runc/0001-Replace-os.Is-error-checking-functions-with-their-er.patch b/package/runc/0001-Replace-os.Is-error-checking-functions-with-their-er.patch deleted file mode 100644 index 4e103099f9a..00000000000 --- a/package/runc/0001-Replace-os.Is-error-checking-functions-with-their-er.patch +++ /dev/null @@ -1,400 +0,0 @@ -From 87932aa3d01294886b71f9566f3bf881cf769c66 Mon Sep 17 00:00:00 2001 -From: Curd Becker -Date: Mon, 17 Nov 2025 00:28:05 +0100 -Subject: [PATCH] Replace os.Is* error checking functions with their errors.Is - counterpart - -Signed-off-by: Curd Becker -(cherry picked from commit 536e183451b7988316fdc37eecd7afd8570dc19b) -Signed-off-by: Kir Kolyshkin -(cherry picked from commit 323a54ef0d91a20f7d5be4308e5e65a98886bf4b) - -Since the runc security bump to version 1.3.5 [1], the TestOci fail due -to missing user namespace support in the kernel: - - proc/self/setgroups: no such file or directory - -The test was working well with runc 1.3.0. The regression is caused by -this commit [2] from the 1.3.3 security release. - -The regression is fixed by a refactoring from the 1.4.1 release [3]. - -Backport this commit on top of runc 1.3.5 (fixing some conflicts). - -Upstream: https://github.com/opencontainers/runc/commit/323a54ef0d91a20f7d5be4308e5e65a98886bf4b - -[1] https://gitlab.com/buildroot.org/buildroot/-/commit/e013e2df84fb36985261d7b3c6e6af06afd40f93 -[2] https://github.com/opencontainers/runc/commit/7762edc82c36ba69a4ea88b86483fcdcac93f5a2 -[3] https://github.com/opencontainers/runc/commit/323a54ef0d91a20f7d5be4308e5e65a98886bf4b -[Romain: - rebase on 1.3.5 - add comments about runc 1.3.5 regression -] -Conflicts: - libcontainer/configs/validate/validator_test.go - libcontainer/container_linux.go - libcontainer/intelrdt/intelrdt.go -Signed-off-by: Romain Naour ---- - libcontainer/configs/validate/validator.go | 6 +++--- - libcontainer/configs/validate/validator_test.go | 7 ++++--- - libcontainer/criu_linux.go | 10 +++++----- - libcontainer/devices/device_unix.go | 2 +- - libcontainer/factory_linux.go | 4 ++-- - libcontainer/init_linux.go | 4 ++-- - libcontainer/integration/exec_test.go | 6 +++--- - libcontainer/notify_linux.go | 2 +- - libcontainer/process_linux.go | 2 +- - libcontainer/rootfs_linux.go | 8 ++++---- - libcontainer/specconv/spec_linux_test.go | 5 +++-- - libcontainer/state_linux.go | 3 ++- - spec.go | 4 ++-- - 13 files changed, 33 insertions(+), 30 deletions(-) - -diff --git a/libcontainer/configs/validate/validator.go b/libcontainer/configs/validate/validator.go -index e0052900..3b77617b 100644 ---- a/libcontainer/configs/validate/validator.go -+++ b/libcontainer/configs/validate/validator.go -@@ -104,7 +104,7 @@ func security(config *configs.Config) error { - - func namespaces(config *configs.Config) error { - if config.Namespaces.Contains(configs.NEWUSER) { -- if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/user"); errors.Is(err, os.ErrNotExist) { - return errors.New("user namespaces aren't enabled in the kernel") - } - hasPath := config.Namespaces.PathOf(configs.NEWUSER) != "" -@@ -122,13 +122,13 @@ func namespaces(config *configs.Config) error { - } - - if config.Namespaces.Contains(configs.NEWCGROUP) { -- if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/cgroup"); errors.Is(err, os.ErrNotExist) { - return errors.New("cgroup namespaces aren't enabled in the kernel") - } - } - - if config.Namespaces.Contains(configs.NEWTIME) { -- if _, err := os.Stat("/proc/self/timens_offsets"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/timens_offsets"); errors.Is(err, os.ErrNotExist) { - return errors.New("time namespaces aren't enabled in the kernel") - } - hasPath := config.Namespaces.PathOf(configs.NEWTIME) != "" -diff --git a/libcontainer/configs/validate/validator_test.go b/libcontainer/configs/validate/validator_test.go -index d157feea..41412ba4 100644 ---- a/libcontainer/configs/validate/validator_test.go -+++ b/libcontainer/configs/validate/validator_test.go -@@ -1,6 +1,7 @@ - package validate - - import ( -+ "errors" - "os" - "path/filepath" - "testing" -@@ -171,7 +172,7 @@ func TestValidateSecurityWithoutNEWNS(t *testing.T) { - } - - func TestValidateUserNamespace(t *testing.T) { -- if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/user"); errors.Is(err, os.ErrNotExist) { - t.Skip("Test requires userns.") - } - config := &configs.Config{ -@@ -205,7 +206,7 @@ func TestValidateUsernsMappingWithoutNamespace(t *testing.T) { - } - - func TestValidateTimeNamespace(t *testing.T) { -- if _, err := os.Stat("/proc/self/ns/time"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/time"); errors.Is(err, os.ErrNotExist) { - t.Skip("Test requires timens.") - } - config := &configs.Config{ -@@ -224,7 +225,7 @@ func TestValidateTimeNamespace(t *testing.T) { - } - - func TestValidateTimeNamespaceWithBothPathAndTimeOffset(t *testing.T) { -- if _, err := os.Stat("/proc/self/ns/time"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/time"); errors.Is(err, os.ErrNotExist) { - t.Skip("Test requires timens.") - } - config := &configs.Config{ -diff --git a/libcontainer/criu_linux.go b/libcontainer/criu_linux.go -index 53a0202a..ddf95445 100644 ---- a/libcontainer/criu_linux.go -+++ b/libcontainer/criu_linux.go -@@ -123,7 +123,7 @@ func (c *Container) addMaskPaths(req *criurpc.CriuReq) error { - for _, path := range c.config.MaskPaths { - fi, err := os.Stat(fmt.Sprintf("/proc/%d/root/%s", c.initProcess.pid(), path)) - if err != nil { -- if os.IsNotExist(err) { -+ if errors.Is(err, os.ErrNotExist) { - continue - } - return err -@@ -304,7 +304,7 @@ func (c *Container) Checkpoint(criuOpts *CriuOpts) error { - - // Since a container can be C/R'ed multiple times, - // the checkpoint directory may already exist. -- if err := os.Mkdir(criuOpts.ImagesDirectory, 0o700); err != nil && !os.IsExist(err) { -+ if err := os.Mkdir(criuOpts.ImagesDirectory, 0o700); err != nil && !errors.Is(err, os.ErrExist) { - return err - } - -@@ -339,7 +339,7 @@ func (c *Container) Checkpoint(criuOpts *CriuOpts) error { - - // if criuOpts.WorkDirectory is not set, criu default is used. - if criuOpts.WorkDirectory != "" { -- if err := os.Mkdir(criuOpts.WorkDirectory, 0o700); err != nil && !os.IsExist(err) { -+ if err := os.Mkdir(criuOpts.WorkDirectory, 0o700); err != nil && !errors.Is(err, os.ErrExist) { - return err - } - workDir, err := os.Open(criuOpts.WorkDirectory) -@@ -698,7 +698,7 @@ func (c *Container) Restore(process *Process, criuOpts *CriuOpts) error { - if criuOpts.WorkDirectory != "" { - // Since a container can be C/R'ed multiple times, - // the work directory may already exist. -- if err := os.Mkdir(criuOpts.WorkDirectory, 0o700); err != nil && !os.IsExist(err) { -+ if err := os.Mkdir(criuOpts.WorkDirectory, 0o700); err != nil && !errors.Is(err, os.ErrExist) { - return err - } - workDir, err := os.Open(criuOpts.WorkDirectory) -@@ -1149,7 +1149,7 @@ func (c *Container) criuNotifications(resp *criurpc.CriuResp, process *Process, - return err - } - if err := os.Remove(filepath.Join(c.stateDir, "checkpoint")); err != nil { -- if !os.IsNotExist(err) { -+ if !errors.Is(err, os.ErrNotExist) { - logrus.Error(err) - } - } -diff --git a/libcontainer/devices/device_unix.go b/libcontainer/devices/device_unix.go -index c533eb1c..409e58e9 100644 ---- a/libcontainer/devices/device_unix.go -+++ b/libcontainer/devices/device_unix.go -@@ -98,7 +98,7 @@ func GetDevices(path string) ([]*Device, error) { - if errors.Is(err, ErrNotADevice) { - continue - } -- if os.IsNotExist(err) { -+ if errors.Is(err, os.ErrNotExist) { - continue - } - return nil, err -diff --git a/libcontainer/factory_linux.go b/libcontainer/factory_linux.go -index 94b55eaa..d8a2d8e3 100644 ---- a/libcontainer/factory_linux.go -+++ b/libcontainer/factory_linux.go -@@ -51,7 +51,7 @@ func Create(root, id string, config *configs.Config) (*Container, error) { - } - if _, err := os.Stat(stateDir); err == nil { - return nil, ErrExist -- } else if !os.IsNotExist(err) { -+ } else if !errors.Is(err, os.ErrNotExist) { - return nil, err - } - -@@ -154,7 +154,7 @@ func loadState(root string) (*State, error) { - } - f, err := os.Open(stateFilePath) - if err != nil { -- if os.IsNotExist(err) { -+ if errors.Is(err, os.ErrNotExist) { - return nil, ErrNotExist - } - return nil, err -diff --git a/libcontainer/init_linux.go b/libcontainer/init_linux.go -index 40529200..25c135f3 100644 ---- a/libcontainer/init_linux.go -+++ b/libcontainer/init_linux.go -@@ -311,7 +311,7 @@ func finalizeNamespace(config *initConfig) error { - switch { - case err == nil: - doChdir = false -- case os.IsPermission(err): -+ case errors.Is(err, os.ErrPermission): - // If we hit an EPERM, we should attempt again after setting up user. - // This will allow us to successfully chdir if the container user has access - // to the directory, but the user running runc does not. -@@ -477,7 +477,7 @@ func setupUser(config *initConfig) error { - setgroups, err = io.ReadAll(setgroupsFile) - _ = setgroupsFile.Close() - } -- if err != nil && !os.IsNotExist(err) { -+ if err != nil && !errors.Is(err, os.ErrNotExist) { - return err - } - -diff --git a/libcontainer/integration/exec_test.go b/libcontainer/integration/exec_test.go -index df99da26..14006922 100644 ---- a/libcontainer/integration/exec_test.go -+++ b/libcontainer/integration/exec_test.go -@@ -1097,7 +1097,7 @@ func TestHook(t *testing.T) { - - for _, hook := range []string{"prestart", "createRuntime", "poststart"} { - fi, err := os.Stat(filepath.Join(config.Rootfs, hook)) -- if err == nil || !os.IsNotExist(err) { -+ if err == nil || !errors.Is(err, os.ErrNotExist) { - t.Fatalf("expected file '%s to not exists, but it does", fi.Name()) - } - } -@@ -1645,7 +1645,7 @@ func TestTmpfsCopyUp(t *testing.T) { - } - - func TestCGROUPPrivate(t *testing.T) { -- if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/cgroup"); errors.Is(err, os.ErrNotExist) { - t.Skip("Test requires cgroupns.") - } - if testing.Short() { -@@ -1665,7 +1665,7 @@ func TestCGROUPPrivate(t *testing.T) { - } - - func TestCGROUPHost(t *testing.T) { -- if _, err := os.Stat("/proc/self/ns/cgroup"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/cgroup"); errors.Is(err, os.ErrNotExist) { - t.Skip("Test requires cgroupns.") - } - if testing.Short() { -diff --git a/libcontainer/notify_linux.go b/libcontainer/notify_linux.go -index a8762842..77e23157 100644 ---- a/libcontainer/notify_linux.go -+++ b/libcontainer/notify_linux.go -@@ -51,7 +51,7 @@ func registerMemoryEvent(cgDir string, evName string, arg string) (<-chan struct - } - // When a cgroup is destroyed, an event is sent to eventfd. - // So if the control path is gone, return instead of notifying. -- if _, err := os.Lstat(eventControlPath); os.IsNotExist(err) { -+ if _, err := os.Lstat(eventControlPath); errors.Is(err, os.ErrNotExist) { - return - } - ch <- struct{}{} -diff --git a/libcontainer/process_linux.go b/libcontainer/process_linux.go -index baf3706c..6f10a6c2 100644 ---- a/libcontainer/process_linux.go -+++ b/libcontainer/process_linux.go -@@ -940,7 +940,7 @@ func getPipeFds(pid int) ([]string, error) { - // Ignore permission errors, for rootless containers and other - // non-dumpable processes. if we can't get the fd for a particular - // file, there's not much we can do. -- if os.IsPermission(err) { -+ if errors.Is(err, os.ErrPermission) { - continue - } - return fds, err -diff --git a/libcontainer/rootfs_linux.go b/libcontainer/rootfs_linux.go -index 31d05174..abc372f3 100644 ---- a/libcontainer/rootfs_linux.go -+++ b/libcontainer/rootfs_linux.go -@@ -361,7 +361,7 @@ func mountCgroupV1(m mountEntry, c *mountConfig) error { - // symlink(2) is very dumb, it will just shove the path into - // the link and doesn't do any checks or relative path - // conversion. Also, don't error out if the cgroup already exists. -- if err := os.Symlink(mc, filepath.Join(c.root, m.Destination, ss)); err != nil && !os.IsExist(err) { -+ if err := os.Symlink(mc, filepath.Join(c.root, m.Destination, ss)); err != nil && !errors.Is(err, os.ErrExist) { - return err - } - } -@@ -613,7 +613,7 @@ func mountToRootfs(c *mountConfig, m mountEntry) error { - return err - } - if fi, err := os.Lstat(dest); err != nil { -- if !os.IsNotExist(err) { -+ if !errors.Is(err, os.ErrNotExist) { - return err - } - } else if !fi.IsDir() { -@@ -910,7 +910,7 @@ func setupDevSymlinks(rootfs string) error { - src = link[0] - dst = filepath.Join(rootfs, link[1]) - ) -- if err := os.Symlink(src, dst); err != nil && !os.IsExist(err) { -+ if err := os.Symlink(src, dst); err != nil && !errors.Is(err, os.ErrExist) { - return err - } - } -@@ -1132,7 +1132,7 @@ func setReadonly() error { - - func setupPtmx(config *configs.Config) error { - ptmx := filepath.Join(config.Rootfs, "dev/ptmx") -- if err := os.Remove(ptmx); err != nil && !os.IsNotExist(err) { -+ if err := os.Remove(ptmx); err != nil && !errors.Is(err, os.ErrNotExist) { - return err - } - if err := os.Symlink("pts/ptmx", ptmx); err != nil { -diff --git a/libcontainer/specconv/spec_linux_test.go b/libcontainer/specconv/spec_linux_test.go -index 66359f79..88156516 100644 ---- a/libcontainer/specconv/spec_linux_test.go -+++ b/libcontainer/specconv/spec_linux_test.go -@@ -1,6 +1,7 @@ - package specconv - - import ( -+ "errors" - "os" - "strings" - "testing" -@@ -609,7 +610,7 @@ func TestDupNamespaces(t *testing.T) { - } - - func TestUserNamespaceMappingAndPath(t *testing.T) { -- if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/user"); errors.Is(err, os.ErrNotExist) { - t.Skip("Test requires userns.") - } - -@@ -643,7 +644,7 @@ func TestUserNamespaceMappingAndPath(t *testing.T) { - } - - func TestNonZeroEUIDCompatibleSpecconvValidate(t *testing.T) { -- if _, err := os.Stat("/proc/self/ns/user"); os.IsNotExist(err) { -+ if _, err := os.Stat("/proc/self/ns/user"); errors.Is(err, os.ErrNotExist) { - t.Skip("Test requires userns.") - } - -diff --git a/libcontainer/state_linux.go b/libcontainer/state_linux.go -index 2b7b8b5b..1f758e2a 100644 ---- a/libcontainer/state_linux.go -+++ b/libcontainer/state_linux.go -@@ -1,6 +1,7 @@ - package libcontainer - - import ( -+ "errors" - "fmt" - "os" - "path/filepath" -@@ -213,7 +214,7 @@ func (r *restoredState) transition(s containerState) error { - - func (r *restoredState) destroy() error { - if _, err := os.Stat(filepath.Join(r.c.stateDir, "checkpoint")); err != nil { -- if !os.IsNotExist(err) { -+ if !errors.Is(err, os.ErrNotExist) { - return err - } - } -diff --git a/spec.go b/spec.go -index d03d644e..15e933eb 100644 ---- a/spec.go -+++ b/spec.go -@@ -91,7 +91,7 @@ created by an unprivileged user. - if err == nil { - return fmt.Errorf("File %s exists. Remove it first", name) - } -- if !os.IsNotExist(err) { -+ if !errors.Is(err, os.ErrNotExist) { - return err - } - return nil -@@ -117,7 +117,7 @@ created by an unprivileged user. - func loadSpec(cPath string) (spec *specs.Spec, err error) { - cf, err := os.Open(cPath) - if err != nil { -- if os.IsNotExist(err) { -+ if errors.Is(err, os.ErrNotExist) { - return nil, fmt.Errorf("JSON specification file %s not found", cPath) - } - return nil, err --- -2.54.0 - diff --git a/package/runc/runc.hash b/package/runc/runc.hash index d3132b10085..67511d29398 100644 --- a/package/runc/runc.hash +++ b/package/runc/runc.hash @@ -1,3 +1,3 @@ # Locally computed -sha256 72620f9b0e62d8da80c0c08a6265ab10d24330c544115c30713ba1429bde706d runc-1.3.5-go2.tar.gz +sha256 8816e8d4181d13012d16733e837425f5f67df57dfac28bc58a68f7dfcd54291b runc-1.3.6-go2.tar.gz sha256 552a739c3b25792263f731542238b92f6f8d07e9a488eae27e6c4690038a8243 LICENSE diff --git a/package/runc/runc.mk b/package/runc/runc.mk index 10ff98c9d73..e0c93baeb97 100644 --- a/package/runc/runc.mk +++ b/package/runc/runc.mk @@ -4,7 +4,7 @@ # ################################################################################ -RUNC_VERSION = 1.3.5 +RUNC_VERSION = 1.3.6 RUNC_SITE = $(call github,opencontainers,runc,v$(RUNC_VERSION)) RUNC_LICENSE = Apache-2.0, LGPL-2.1 (libseccomp) RUNC_LICENSE_FILES = LICENSE