From 2ba2fd843e7b0c7b827ee6fe9449b2e9b9566cf4 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Sun, 21 Jun 2026 20:51:08 +0200 Subject: [PATCH] Support compiling more i586 programs --- bin/i586-unknown-redox-llvm-config | 1 + bin/x86_64-unknown-redox-llvm-config | 37 +++++++++++------ recipes/archives/zstd/recipe.toml | 5 +++ recipes/dev/llvm21/recipe.toml | 17 +++++++- recipes/libs/glib/recipe.toml | 10 ++++- recipes/libs/libinotify-stub/recipe.toml | 8 +++- recipes/libs/libnettle/recipe.toml | 3 ++ recipes/libs/libnettle/redox.patch | 43 ++++++++++++++++++++ recipes/libs/mesa/recipe.toml | 11 +++-- recipes/wip/libs/gnome/gtk3/recipe.toml | 5 +++ recipes/wip/libs/gnome/libepoxy/recipe.toml | 21 ++++++---- recipes/wip/libs/gnome/libnotify/recipe.toml | 4 +- recipes/wip/libs/gnome/libnotify/redox.patch | 11 +++++ recipes/wip/libs/gnome/libsoup/recipe.toml | 3 ++ recipes/wip/x11/mesa-x11/recipe.toml | 8 +++- recipes/wip/x11/xserver-xorg/recipe.toml | 6 +++ 16 files changed, 161 insertions(+), 32 deletions(-) create mode 120000 bin/i586-unknown-redox-llvm-config create mode 100644 recipes/libs/libnettle/redox.patch create mode 100644 recipes/wip/libs/gnome/libnotify/redox.patch diff --git a/bin/i586-unknown-redox-llvm-config b/bin/i586-unknown-redox-llvm-config new file mode 120000 index 000000000..a118f6a90 --- /dev/null +++ b/bin/i586-unknown-redox-llvm-config @@ -0,0 +1 @@ +x86_64-unknown-redox-llvm-config \ No newline at end of file diff --git a/bin/x86_64-unknown-redox-llvm-config b/bin/x86_64-unknown-redox-llvm-config index db740d80e..edf868688 100755 --- a/bin/x86_64-unknown-redox-llvm-config +++ b/bin/x86_64-unknown-redox-llvm-config @@ -7,6 +7,7 @@ import os import sys import subprocess +import re LLVM_CONFIG = "/bin/llvm-config" @@ -50,6 +51,8 @@ def main(): target_arch = target_triple.split('-')[0] if target_triple else "" mapped_archs = ARCH_MAP.get(target_arch) target_built_name, comp_prefix, lib_prefix = mapped_archs + toolchain_path = toolchain_path.rstrip(os.sep) + sysroot_path = sysroot_path.rstrip(os.sep) cmd = [toolchain_path + LLVM_CONFIG] + sys.argv[1:] @@ -57,7 +60,7 @@ def main(): result = subprocess.run( cmd, stdout=subprocess.PIPE, - stderr=sys.stderr, + stderr=subprocess.PIPE, check=False, text=True ) @@ -65,13 +68,27 @@ def main(): print(f"Error: Could not find executable '{LLVM_CONFIG}'", file=sys.stderr) sys.exit(1) - if result.returncode != 0: - sys.exit(result.returncode) - - output = result.stdout.strip() - args_set = set(sys.argv[1:]) + if result.returncode != 0: + # static libs is not part of the toolchain, but they do + # exist for platforms without dynamic library support + if "--link-static" in args_set and "--libfiles" in args_set: + output = result.stderr.strip() + output = output.replace("llvm-config: error: missing: ", "") + elif "--link-static" in args_set and "--libs" in args_set: + output = result.stderr.strip() + libpath = toolchain_path + "/lib" + output = output.replace(f"llvm-config: error: missing: {libpath}/lib", "-l") + output = output.replace(f".a", "") + output = re.sub('-lLLVMX86\w+ ?', '', output, count=0, flags=0) # TODO: why? + output = f"-L{libpath} {output}" + else: + print(result.stderr) + sys.exit(result.returncode) + else: + output = result.stdout.strip() + if "--bindir" in args_set: output = toolchain_path + "/usr/bin" @@ -89,13 +106,9 @@ def main(): output = " ".join(filtered) # if "--ldflags" in args_set: - src = toolchain_path.rstrip(os.sep) - dst = sysroot_path.rstrip(os.sep) - output = output.replace(src, dst) + output = output.replace(toolchain_path, sysroot_path) else: - src = toolchain_path.rstrip(os.sep) - dst = sysroot_path.rstrip(os.sep) - output = output.replace(src, dst) + output = output.replace(toolchain_path, sysroot_path) print(output + '\n', end='') diff --git a/recipes/archives/zstd/recipe.toml b/recipes/archives/zstd/recipe.toml index a79907bb5..a3a0f56e8 100644 --- a/recipes/archives/zstd/recipe.toml +++ b/recipes/archives/zstd/recipe.toml @@ -10,5 +10,10 @@ DYNAMIC_STATIC_INIT # required by llvm21 as zstd statically linked there export CPPFLAGS="$CPPFLAGS -fPIC" COOKBOOK_SOURCE="$COOKBOOK_SOURCE/build/cmake" +if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then + COOKBOOK_CMAKE_FLAGS+=( + -DZSTD_BUILD_SHARED=OFF + ) +fi cookbook_cmake """ diff --git a/recipes/dev/llvm21/recipe.toml b/recipes/dev/llvm21/recipe.toml index d3237826e..423eb102f 100644 --- a/recipes/dev/llvm21/recipe.toml +++ b/recipes/dev/llvm21/recipe.toml @@ -28,9 +28,22 @@ fi # This just build the LLVM library and tools just enough for Rust, to build the rest of LLVM see # https://github.com/llvm/llvm-zorg/blob/main/zorg/buildbot/builders/annotated/standalone-build.sh + +if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then + COOKBOOK_CMAKE_FLAGS+=( + -DLLVM_BUILD_LLVM_DYLIB=On + -DLLVM_LINK_LLVM_DYLIB=On + ) +else + COOKBOOK_CMAKE_FLAGS+=( + -DLLVM_BUILD_LLVM_DYLIB=OFF + -DLLVM_LINK_LLVM_DYLIB=OFF + -DLLVM_BUILD_STATIC=True + -DLLVM_ENABLE_PIC=False + ) +fi + COOKBOOK_CMAKE_FLAGS+=( - -DLLVM_BUILD_LLVM_DYLIB=On - -DLLVM_LINK_LLVM_DYLIB=On -DLLVM_INCLUDE_UTILS=On -DLLVM_INSTALL_UTILS=On -DLLVM_TOOL_LLVM_COV_BUILD=On diff --git a/recipes/libs/glib/recipe.toml b/recipes/libs/glib/recipe.toml index d004afd09..12ed8d26c 100644 --- a/recipes/libs/glib/recipe.toml +++ b/recipes/libs/glib/recipe.toml @@ -19,9 +19,17 @@ script = """ DYNAMIC_INIT export CFLAGS="$CFLAGS -I$COOKBOOK_SYSROOT/include/inotify" export LDFLAGS="$LDFLAGS -linotify" +LIBRARY=shared +if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then + LIBRARY=static +fi cookbook_meson \ - -Ddefault_library=shared \ + -Ddefault_library=$LIBRARY \ -Dxattr=false \ -Dtests=false \ -Dfile_monitor_backend=inotify + +if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then + sed -i 's/^Libs:.*$/& -linotify/' "${COOKBOOK_STAGE}/usr/lib/pkgconfig/gio-2.0.pc" +fi """ diff --git a/recipes/libs/libinotify-stub/recipe.toml b/recipes/libs/libinotify-stub/recipe.toml index 8b77e15d3..6f9362b6e 100644 --- a/recipes/libs/libinotify-stub/recipe.toml +++ b/recipes/libs/libinotify-stub/recipe.toml @@ -1,9 +1,13 @@ [source] -tar = "https://github.com/willnode/inotify-stub/archive/refs/tags/v0.1.tar.gz" +tar = "https://github.com/willnode/inotify-stub/archive/refs/tags/v0.2.tar.gz" +blake3 = "f76d204b0453e56688a4d8609d0b5680163eb9d2984cbd9e897f514becaf8e31" [build] template = "custom" script = """ DYNAMIC_INIT -make -C "$COOKBOOK_SOURCE" install BUILD="$(pwd)" DESTDIR="$COOKBOOK_STAGE/usr" +COOKBOOK_DYNAMIC=${COOKBOOK_DYNAMIC:-0} +make -C "$COOKBOOK_SOURCE" install \ + SHARED="${COOKBOOK_DYNAMIC}" BUILD="$(pwd)" \ + DESTDIR="$COOKBOOK_STAGE/usr" """ diff --git a/recipes/libs/libnettle/recipe.toml b/recipes/libs/libnettle/recipe.toml index 29d81817e..a1ff983ea 100644 --- a/recipes/libs/libnettle/recipe.toml +++ b/recipes/libs/libnettle/recipe.toml @@ -4,6 +4,9 @@ blake3 = "e4bfbda32f4fdf5ed96c152efe3a3867193b690faa5378d02a2a6fd052ee3393" script = """ autotools_recursive_regenerate """ +patches = [ + "redox.patch" +] [build] template = "custom" diff --git a/recipes/libs/libnettle/redox.patch b/recipes/libs/libnettle/redox.patch new file mode 100644 index 000000000..4c038f168 --- /dev/null +++ b/recipes/libs/libnettle/redox.patch @@ -0,0 +1,43 @@ +diff --color -ruwN source/getopt1.c source-new/getopt1.c +--- source/getopt1.c 2023-06-01 20:40:35.000000000 +0200 ++++ source-new/getopt1.c 2026-06-21 12:59:43.982043176 +0200 +@@ -45,6 +45,10 @@ + #endif + #endif + ++#ifdef __RELIBC__ ++#define ELIDE_CODE ++#endif ++ + #ifndef ELIDE_CODE + + +diff --color -ruwN source/getopt.c source-new/getopt.c +--- source/getopt.c 2023-06-01 20:40:35.000000000 +0200 ++++ source-new/getopt.c 2026-06-21 12:59:43.982043176 +0200 +@@ -51,6 +51,10 @@ + # endif + #endif + ++#ifdef __RELIBC__ ++#define ELIDE_CODE ++#endif ++ + #ifndef ELIDE_CODE + + +diff --color -ruwN source/getopt.h source-new/getopt.h +--- source/getopt.h 2023-06-01 20:40:35.000000000 +0200 ++++ source-new/getopt.h 2026-06-21 12:59:44.908095155 +0200 +@@ -22,6 +22,11 @@ + # define _GETOPT_H 1 + #endif + ++#ifdef __RELIBC__ ++#define __GNU_LIBRARY__ ++#endif ++ ++ + /* If __GNU_LIBRARY__ is not already defined, either we are being used + standalone, or this is the first header included in the source file. + If we are being used with glibc, we need to include , but diff --git a/recipes/libs/mesa/recipe.toml b/recipes/libs/mesa/recipe.toml index 13768b8b8..f88db5dec 100644 --- a/recipes/libs/mesa/recipe.toml +++ b/recipes/libs/mesa/recipe.toml @@ -23,21 +23,20 @@ export CFLAGS+=" -DHAVE_PTHREAD=1 -I${COOKBOOK_SYSROOT}/include/libdrm" export LLVM_CONFIG="${TARGET}-llvm-config" export LDFLAGS+=" -lorbital" -if [ "${COOKBOOK_DYNAMIC}" == "1" ]; then - COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=enabled) +if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then + # TODO: Fix wayland-scanner and enable wayland platform + COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=enabled -Degl=enabled -Dplatforms=redox -Dvulkan-drivers=swrast) else - COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=disabled) + # No vulkan, lavapipe or EGL which is strictly requires shared library support + COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=disabled -Dshared-glapi=disabled -Dgbm=disabled -Dplatforms=) fi cookbook_meson \ -Ddri-drivers-path=/usr/lib/dri \ - -Degl=enabled \ -Dglx=disabled \ -Dllvm=enabled \ -Dosmesa=true \ - -Dplatforms=redox \ -Dshader-cache=disabled \ - -Dvulkan-drivers=swrast \ -Dgallium-drivers=swrast # Hack to add LLVM libs, the list can be seen from meson log and check for matches $("${LLVM_CONFIG}" --libs) diff --git a/recipes/wip/libs/gnome/gtk3/recipe.toml b/recipes/wip/libs/gnome/gtk3/recipe.toml index 02631e99d..da80247fd 100644 --- a/recipes/wip/libs/gnome/gtk3/recipe.toml +++ b/recipes/wip/libs/gnome/gtk3/recipe.toml @@ -40,6 +40,11 @@ template = "custom" script = """ DYNAMIC_INIT CFLAGS="${CFLAGS} -DM_SQRT2=1.41421356237309504880" + +if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then + COOKBOOK_MESON_FLAGS+=(-Dwayland_backend=false) +fi + cookbook_meson \ -Dexamples=false \ -Dintrospection=false \ diff --git a/recipes/wip/libs/gnome/libepoxy/recipe.toml b/recipes/wip/libs/gnome/libepoxy/recipe.toml index 7544bdc5d..292032f23 100644 --- a/recipes/wip/libs/gnome/libepoxy/recipe.toml +++ b/recipes/wip/libs/gnome/libepoxy/recipe.toml @@ -4,14 +4,21 @@ blake3 = "0ccee9635115fe417cfc4bc33ffd160bf1e2852bd6c03816b4af771d59462f53" patches = ["redox.patch"] [build] -template = "meson" +template = "custom" dev-dependencies = [ "libx11", "mesa", ] -mesonflags = [ - "-Degl=yes", -# we're forcing x11 backend via EGL - "-Dx11=true", - "-Dtests=false", -] +script = """ +DYNAMIC_INIT +if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then + # Forcing x11 via EGL + COOKBOOK_MESON_FLAGS+=(-Degl=yes) +else + # No EGL, No wayland + COOKBOOK_MESON_FLAGS+=(-Degl=no) +fi + +COOKBOOK_MESON_FLAGS+=(-Dx11=true -Dtests=false) +cookbook_meson +""" diff --git a/recipes/wip/libs/gnome/libnotify/recipe.toml b/recipes/wip/libs/gnome/libnotify/recipe.toml index a451e3451..649881839 100644 --- a/recipes/wip/libs/gnome/libnotify/recipe.toml +++ b/recipes/wip/libs/gnome/libnotify/recipe.toml @@ -2,6 +2,9 @@ [source] tar = "https://download.gnome.org/sources/libnotify/0.8/libnotify-0.8.4.tar.xz" blake3 = "1c749e4f1cc85f88348bb363b6d78c8373baa19a6db4d2b3a4cf537c1af6b929" +patches = [ + "redox.patch" +] [build] dependencies = [ @@ -15,4 +18,3 @@ mesonflags = [ "-Dtests=false", "-Dintrospection=disabled", ] - diff --git a/recipes/wip/libs/gnome/libnotify/redox.patch b/recipes/wip/libs/gnome/libnotify/redox.patch new file mode 100644 index 000000000..530bcad46 --- /dev/null +++ b/recipes/wip/libs/gnome/libnotify/redox.patch @@ -0,0 +1,11 @@ +diff -ruwN source/tools/notify-send.c source-new/tools/notify-send.c +--- source/tools/notify-send.c 2025-02-20 03:59:41.000000000 +0100 ++++ source-new/tools/notify-send.c 2026-06-21 12:16:03.152538528 +0200 +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + #include + #include + #include diff --git a/recipes/wip/libs/gnome/libsoup/recipe.toml b/recipes/wip/libs/gnome/libsoup/recipe.toml index 6a8c44f16..a2086227b 100644 --- a/recipes/wip/libs/gnome/libsoup/recipe.toml +++ b/recipes/wip/libs/gnome/libsoup/recipe.toml @@ -23,5 +23,8 @@ cookbook_meson \ -Dsysprof=disabled \ -Dtests=false \ -Dtls_check=false + +if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then patchelf --replace-needed "${COOKBOOK_SYSROOT}/usr/lib/libsqlite3.so" "libsqlite3.so" "${COOKBOOK_STAGE}/usr/lib/libsoup-3.0.so" +fi """ diff --git a/recipes/wip/x11/mesa-x11/recipe.toml b/recipes/wip/x11/mesa-x11/recipe.toml index 2bcc4a38c..61595b3da 100644 --- a/recipes/wip/x11/mesa-x11/recipe.toml +++ b/recipes/wip/x11/mesa-x11/recipe.toml @@ -22,10 +22,16 @@ dev-dependencies = [ script = """ DYNAMIC_INIT + +if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then + COOKBOOK_MESON_FLAGS+=(-Dglx=dri) +else + COOKBOOK_MESON_FLAGS+=(-Dglx=xlib -Dshared-glapi=disabled) +fi + cookbook_meson \ -Ddri-drivers-path=/usr/lib/dri \ -Degl=disabled \ - -Dglx=dri \ -Dllvm=enabled \ -Dgles1=disabled \ -Dgles2=disabled \ diff --git a/recipes/wip/x11/xserver-xorg/recipe.toml b/recipes/wip/x11/xserver-xorg/recipe.toml index 86849c243..8e6ae30af 100644 --- a/recipes/wip/x11/xserver-xorg/recipe.toml +++ b/recipes/wip/x11/xserver-xorg/recipe.toml @@ -24,6 +24,7 @@ dependencies = [ "mesa-x11", "openssl3", "pixman", + "xkbcomp", "x11proto", "xtrans", "zlib", @@ -31,6 +32,11 @@ dependencies = [ template = "custom" script = """ DYNAMIC_INIT + +if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then + COOKBOOK_MESON_FLAGS+=(-Dglx=false -Dxnest=false) +fi + cookbook_meson \ -Ddri1=false \ -Dglamor=false \