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 os
import sys import sys
import subprocess import subprocess
import re
LLVM_CONFIG = "/bin/llvm-config" LLVM_CONFIG = "/bin/llvm-config"
@ -50,6 +51,8 @@ def main():
target_arch = target_triple.split('-')[0] if target_triple else "" target_arch = target_triple.split('-')[0] if target_triple else ""
mapped_archs = ARCH_MAP.get(target_arch) mapped_archs = ARCH_MAP.get(target_arch)
target_built_name, comp_prefix, lib_prefix = mapped_archs 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:] cmd = [toolchain_path + LLVM_CONFIG] + sys.argv[1:]
@ -57,7 +60,7 @@ def main():
result = subprocess.run( result = subprocess.run(
cmd, cmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=sys.stderr, stderr=subprocess.PIPE,
check=False, check=False,
text=True text=True
) )
@ -65,13 +68,27 @@ def main():
print(f"Error: Could not find executable '{LLVM_CONFIG}'", file=sys.stderr) print(f"Error: Could not find executable '{LLVM_CONFIG}'", file=sys.stderr)
sys.exit(1) sys.exit(1)
if result.returncode != 0:
sys.exit(result.returncode)
output = result.stdout.strip()
args_set = set(sys.argv[1:]) 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: if "--bindir" in args_set:
output = toolchain_path + "/usr/bin" output = toolchain_path + "/usr/bin"
@ -89,13 +106,9 @@ def main():
output = " ".join(filtered) output = " ".join(filtered)
# if "--ldflags" in args_set: # if "--ldflags" in args_set:
src = toolchain_path.rstrip(os.sep) output = output.replace(toolchain_path, sysroot_path)
dst = sysroot_path.rstrip(os.sep)
output = output.replace(src, dst)
else: else:
src = toolchain_path.rstrip(os.sep) output = output.replace(toolchain_path, sysroot_path)
dst = sysroot_path.rstrip(os.sep)
output = output.replace(src, dst)
print(output + '\n', end='') print(output + '\n', end='')

View File

@ -10,5 +10,10 @@ DYNAMIC_STATIC_INIT
# required by llvm21 as zstd statically linked there # required by llvm21 as zstd statically linked there
export CPPFLAGS="$CPPFLAGS -fPIC" export CPPFLAGS="$CPPFLAGS -fPIC"
COOKBOOK_SOURCE="$COOKBOOK_SOURCE/build/cmake" COOKBOOK_SOURCE="$COOKBOOK_SOURCE/build/cmake"
if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then
COOKBOOK_CMAKE_FLAGS+=(
-DZSTD_BUILD_SHARED=OFF
)
fi
cookbook_cmake 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 # 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 # 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+=( COOKBOOK_CMAKE_FLAGS+=(
-DLLVM_BUILD_LLVM_DYLIB=On
-DLLVM_LINK_LLVM_DYLIB=On
-DLLVM_INCLUDE_UTILS=On -DLLVM_INCLUDE_UTILS=On
-DLLVM_INSTALL_UTILS=On -DLLVM_INSTALL_UTILS=On
-DLLVM_TOOL_LLVM_COV_BUILD=On -DLLVM_TOOL_LLVM_COV_BUILD=On

View File

@ -19,9 +19,17 @@ script = """
DYNAMIC_INIT DYNAMIC_INIT
export CFLAGS="$CFLAGS -I$COOKBOOK_SYSROOT/include/inotify" export CFLAGS="$CFLAGS -I$COOKBOOK_SYSROOT/include/inotify"
export LDFLAGS="$LDFLAGS -linotify" export LDFLAGS="$LDFLAGS -linotify"
LIBRARY=shared
if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then
LIBRARY=static
fi
cookbook_meson \ cookbook_meson \
-Ddefault_library=shared \ -Ddefault_library=$LIBRARY \
-Dxattr=false \ -Dxattr=false \
-Dtests=false \ -Dtests=false \
-Dfile_monitor_backend=inotify -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] [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] [build]
template = "custom" template = "custom"
script = """ script = """
DYNAMIC_INIT 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 = """ script = """
autotools_recursive_regenerate autotools_recursive_regenerate
""" """
patches = [
"redox.patch"
]
[build] [build]
template = "custom" 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 LLVM_CONFIG="${TARGET}-llvm-config"
export LDFLAGS+=" -lorbital" export LDFLAGS+=" -lorbital"
if [ "${COOKBOOK_DYNAMIC}" == "1" ]; then if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then
COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=enabled) # TODO: Fix wayland-scanner and enable wayland platform
COOKBOOK_MESON_FLAGS+=(-Dshared-llvm=enabled -Degl=enabled -Dplatforms=redox -Dvulkan-drivers=swrast)
else 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 fi
cookbook_meson \ cookbook_meson \
-Ddri-drivers-path=/usr/lib/dri \ -Ddri-drivers-path=/usr/lib/dri \
-Degl=enabled \
-Dglx=disabled \ -Dglx=disabled \
-Dllvm=enabled \ -Dllvm=enabled \
-Dosmesa=true \ -Dosmesa=true \
-Dplatforms=redox \
-Dshader-cache=disabled \ -Dshader-cache=disabled \
-Dvulkan-drivers=swrast \
-Dgallium-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) # 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 = """ script = """
DYNAMIC_INIT DYNAMIC_INIT
CFLAGS="${CFLAGS} -DM_SQRT2=1.41421356237309504880" CFLAGS="${CFLAGS} -DM_SQRT2=1.41421356237309504880"
if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then
COOKBOOK_MESON_FLAGS+=(-Dwayland_backend=false)
fi
cookbook_meson \ cookbook_meson \
-Dexamples=false \ -Dexamples=false \
-Dintrospection=false \ -Dintrospection=false \

View File

@ -4,14 +4,21 @@ blake3 = "0ccee9635115fe417cfc4bc33ffd160bf1e2852bd6c03816b4af771d59462f53"
patches = ["redox.patch"] patches = ["redox.patch"]
[build] [build]
template = "meson" template = "custom"
dev-dependencies = [ dev-dependencies = [
"libx11", "libx11",
"mesa", "mesa",
] ]
mesonflags = [ script = """
"-Degl=yes", DYNAMIC_INIT
# we're forcing x11 backend via EGL if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then
"-Dx11=true", # Forcing x11 via EGL
"-Dtests=false", 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] [source]
tar = "https://download.gnome.org/sources/libnotify/0.8/libnotify-0.8.4.tar.xz" tar = "https://download.gnome.org/sources/libnotify/0.8/libnotify-0.8.4.tar.xz"
blake3 = "1c749e4f1cc85f88348bb363b6d78c8373baa19a6db4d2b3a4cf537c1af6b929" blake3 = "1c749e4f1cc85f88348bb363b6d78c8373baa19a6db4d2b3a4cf537c1af6b929"
patches = [
"redox.patch"
]
[build] [build]
dependencies = [ dependencies = [
@ -15,4 +18,3 @@ mesonflags = [
"-Dtests=false", "-Dtests=false",
"-Dintrospection=disabled", "-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 \ -Dsysprof=disabled \
-Dtests=false \ -Dtests=false \
-Dtls_check=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" 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 = """ script = """
DYNAMIC_INIT DYNAMIC_INIT
if [ "${COOKBOOK_DYNAMIC}" = "1" ]; then
COOKBOOK_MESON_FLAGS+=(-Dglx=dri)
else
COOKBOOK_MESON_FLAGS+=(-Dglx=xlib -Dshared-glapi=disabled)
fi
cookbook_meson \ cookbook_meson \
-Ddri-drivers-path=/usr/lib/dri \ -Ddri-drivers-path=/usr/lib/dri \
-Degl=disabled \ -Degl=disabled \
-Dglx=dri \
-Dllvm=enabled \ -Dllvm=enabled \
-Dgles1=disabled \ -Dgles1=disabled \
-Dgles2=disabled \ -Dgles2=disabled \

View File

@ -24,6 +24,7 @@ dependencies = [
"mesa-x11", "mesa-x11",
"openssl3", "openssl3",
"pixman", "pixman",
"xkbcomp",
"x11proto", "x11proto",
"xtrans", "xtrans",
"zlib", "zlib",
@ -31,6 +32,11 @@ dependencies = [
template = "custom" template = "custom"
script = """ script = """
DYNAMIC_INIT DYNAMIC_INIT
if [ "${COOKBOOK_DYNAMIC}" != "1" ]; then
COOKBOOK_MESON_FLAGS+=(-Dglx=false -Dxnest=false)
fi
cookbook_meson \ cookbook_meson \
-Ddri1=false \ -Ddri1=false \
-Dglamor=false \ -Dglamor=false \