Support compiling more i586 programs

This commit is contained in:
Wildan M 2026-06-21 20:51:08 +02:00
parent affe2ef023
commit 2ba2fd843e
16 changed files with 161 additions and 32 deletions

View File

@ -0,0 +1 @@
x86_64-unknown-redox-llvm-config

View File

@ -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='')

View File

@ -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
"""

View File

@ -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

View File

@ -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
"""

View File

@ -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"
"""

View File

@ -4,6 +4,9 @@ blake3 = "e4bfbda32f4fdf5ed96c152efe3a3867193b690faa5378d02a2a6fd052ee3393"
script = """
autotools_recursive_regenerate
"""
patches = [
"redox.patch"
]
[build]
template = "custom"

View File

@ -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 <features.h>, but

View File

@ -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)

View File

@ -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 \

View File

@ -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
"""

View File

@ -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",
]

View File

@ -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 <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <strings.h>
#include <glib.h>
#include <glib-unix.h>
#include <glib/gprintf.h>

View File

@ -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
"""

View File

@ -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 \

View File

@ -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 \