gcc13, rust: fix C++20 char8_t and the nix/libc type mismatch

gcc13
  The host compiler is now GCC 16, which defaults to C++20
  (__cplusplus 202002L). C++20 changed u8"" literals from const char[] to
  const char8_t[], and GCC 13's libcody -- its module mapper -- uses them
  throughout, so the build collapsed with ~100 diagnostics like
      error: invalid conversion from 'const char8_t*' to 'const char*'
  in libcody/{buffer,client,server}.cc. GCC 13's sources are C++17; build
  them at that standard. Not a workaround -- it is the dialect this
  release was written against.

rust / rust-native
  nix 0.30.1 is incompatible with the resolved libc 0.2.178: it declares
  type SaFlags_t = libc::c_ulong while libc now has sigaction.sa_flags and
  the SA_* constants as c_int, so rustc's bootstrap tooling failed with
      error[E0308]: expected `u64`, found `i32`  nix/src/macros.rs:72
      error[E0308]: expected `i32`, found `u64`  nix/src/sys/signal.rs:808
  nix 0.31 fixed it by flipping the default to c_int. ctrlc moves itself
  (3.5 requires nix "0.31"), but in-tree miri pinned 0.30.1 and kept the
  broken version in the graph, so both are moved forward -- update and
  adapt rather than pinning libc back, per the
  Most-recent-upstream-when-building rule. Both crates were already in the
  offline registry cache.

These surfaced only because gcc-native/rust-native were restored to the
config; neither had been building.
This commit is contained in:
2026-08-03 17:12:16 +03:00
parent 46abc404a2
commit c7bca65088
4 changed files with 144 additions and 80 deletions
+28
View File
@@ -0,0 +1,28 @@
miri: move to nix 0.31 so the bootstrap tooling compiles.
nix 0.30.1 is incompatible with the libc this tree resolves (0.2.178): it
declares
type SaFlags_t = libc::c_ulong;
while libc now has sigaction.sa_flags and the SA_* constants as c_int, so
rustc's bootstrap fails to build its tools:
error[E0308]: expected `u64`, found `i32` nix/src/macros.rs:72
error[E0308]: expected `i32`, found `u64` nix/src/sys/signal.rs:808
nix 0.31 fixed this by flipping the default to c_int. ctrlc moves itself
(3.5 requires nix "0.31"), but in-tree miri pinned 0.30.1 and held the old
version in the graph. Move it forward too, per local/AGENTS.md
"Most-recent-upstream-when-building rule" -- update and adapt rather than
--- a/src/tools/miri/Cargo.toml
+++ b/src/tools/miri/Cargo.toml
@@ -44,7 +44,7 @@
serde = { version = "1.0.219", features = ["derive"], optional = true }
[target.'cfg(target_os = "linux")'.dependencies]
-nix = { version = "0.30.1", features = ["mman", "ptrace", "signal"], optional = true }
+nix = { version = "0.31.3", features = ["mman", "ptrace", "signal"], optional = true }
ipc-channel = { version = "0.20.0", optional = true }
capstone = { version = "0.13", optional = true }
+17
View File
@@ -31,6 +31,23 @@ CROSS_GNU_TARGET=${COOKBOOK_CROSS_GNU_TARGET:-$GNU_TARGET}
# HAVE_SYS_SDT_H and then failing to include a non-existent target header.
export gcc_cv_sys_sdt_h=no
# GCC 13's own sources are C++17. Build them that way.
#
# The host compiler is now GCC 16, which defaults to C++20
# (__cplusplus 202002L), and C++20 changed u8"" literals from const char[]
# to const char8_t[]. libcody -- GCC's module mapper -- uses them freely, so
# the build collapses with ~100 diagnostics of the form
# error: invalid conversion from 'const char8_t*' to 'const char*'
# error: no matching function for call to 'Cody::...'
# in libcody/{buffer,client,server}.cc.
#
# This is not a workaround: C++17 is the dialect this release was written
# against, and GCC's own build documentation expects the host compiler to be
# driven at the standard the sources use. Applies to both the cross-toolchain
# and the gcc-native target build below, which share this script.
export CXXFLAGS="${CXXFLAGS:+$CXXFLAGS }-std=gnu++17"
export CXXFLAGS_FOR_BUILD="${CXXFLAGS_FOR_BUILD:+$CXXFLAGS_FOR_BUILD }-std=gnu++17"
if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then
# not specifying --enable-shared as it will link shared deps
COOKBOOK_STAGE+="/usr"
+1
View File
@@ -0,0 +1 @@
../../../local/patches/rust/01-miri-nix-0.31.patch
+98 -80
View File
@@ -2,83 +2,101 @@
name = "rust"
version = "0.1.0"
[source]
git = "https://gitlab.redox-os.org/redox-os/rust.git"
branch = "redox-2025-10-03"
shallow_clone = true
[build]
template = "custom"
dependencies = [
"llvm21",
"zlib",
"curl",
"openssl3",
]
dev-dependencies = [
"llvm21.dev",
"llvm21.runtime",
"lld21",
]
script = """
if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then
cat ${COOKBOOK_RECIPE}/config-bootstrap.toml > config.toml
sed -i "s|TARGET|${TARGET}|g" config.toml
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_TOOLCHAIN}|g" config.toml
else
DYNAMIC_INIT
# Linker flags for stage2 compiler (host -> target)
ARCH="${TARGET%%-*}"
export CARGO_TARGET_${ARCH^^}_UNKNOWN_REDOX_RUSTFLAGS="${RUSTFLAGS}" # Rust
# Hack for Rust errorneusly running `llvm-config --version` on cross compiled llvm-config
cat "${COOKBOOK_ROOT}/bin/${TARGET}-llvm-config" > "${COOKBOOK_SYSROOT}/bin/llvm-config"
# Hack for Rust stage1 being dynamically linked with LLVM in prefix toolchain
export LD_LIBRARY_PATH="${COOKBOOK_HOST_SYSROOT}/lib:${LD_LIBRARY_PATH}"
# Linker flags for stage1 compiler (host -> host)
export RUSTFLAGS_BOOTSTRAP="\
-Clink-args=-L${COOKBOOK_HOST_SYSROOT}/lib \
-Clink-args=-Wl,-rpath-link,${COOKBOOK_HOST_SYSROOT}/lib"
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
cat ${COOKBOOK_RECIPE}/config.toml > config.toml
sed -i "s|COOKBOOK_SYSROOT|${COOKBOOK_SYSROOT}|g" config.toml
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_HOST_SYSROOT}|g" config.toml
sed -i "s|COOKBOOK_TARGET|${TARGET}|g" config.toml
sed -i "s|COOKBOOK_GNU_TARGET|${GNU_TARGET}|g" config.toml
fi
# Don't poison the stage1 compiler (host -> host)
unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS CARGO_ENCODED_RUSTFLAGS STRIP
python3 "${COOKBOOK_SOURCE}/x.py" install \
--config config.toml \
--jobs ${COOKBOOK_MAKE_JOBS}
mkdir -p "${COOKBOOK_STAGE}"/usr
rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}"/usr/
rm -rf "${COOKBOOK_STAGE}"/usr/lib/rustlib/*.log
# workaround for rust.lld, needed by e.g. compiling bootloader
# https://github.com/rust-lang/rust/issues/143076#issuecomment-3011710678
LLD_DIR="${COOKBOOK_STAGE}/usr/lib/rustlib/$TARGET/bin"
mkdir -p $LLD_DIR/gcc-ld
cp ${COOKBOOK_SYSROOT}/usr/bin/lld $LLD_DIR/rust-lld
ln -s rust-lld $LLD_DIR/wasm-component-ld
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld.lld
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld64.lld
ln -s ../rust-lld $LLD_DIR/gcc-ld/lld-link
ln -s ../rust-lld $LLD_DIR/gcc-ld/wasm-ld
ln -s ../../../libLLVM.so.21.1 $LLD_DIR/../lib/libLLVM.so.21.1
"""
[[optional-packages]]
name = "doc"
files = [
"usr/share/doc/**",
]
[source]
git = "https://gitlab.redox-os.org/redox-os/rust.git"
branch = "redox-2025-10-03"
shallow_clone = true
patches = [
"01-miri-nix-0.31.patch"
]
script = """
# ctrlc 3.4.7 pins nix "0.30", and nix 0.30.1 is incompatible with the
# libc 0.2.178 this tree resolves: it declares
# type SaFlags_t = libc::c_ulong;
# while libc now has sigaction.sa_flags and the SA_* constants as c_int,
# so rustc's bootstrap tooling fails to compile with
# error[E0308]: expected `u64`, found `i32` (nix/src/macros.rs:72)
# error[E0308]: expected `i32`, found `u64` (nix/src/sys/signal.rs:808)
# nix 0.31 fixed this by flipping the default to c_int, and ctrlc 3.5
# requires nix "0.31". Move forward to the fixed pair rather than pinning
# libc back, per local/AGENTS.md "Most-recent-upstream-when-building rule".
# Both crates are already in the offline registry cache.
cargo update -p ctrlc --precise 3.5.2 --offline 2>/dev/null || \
cargo update -p ctrlc --precise 3.5.2 || true
"""
[build]
template = "custom"
dependencies = [
"llvm21",
"zlib",
"curl",
"openssl3",
]
dev-dependencies = [
"llvm21.dev",
"llvm21.runtime",
"lld21",
]
script = """
if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ]; then
cat ${COOKBOOK_RECIPE}/config-bootstrap.toml > config.toml
sed -i "s|TARGET|${TARGET}|g" config.toml
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_TOOLCHAIN}|g" config.toml
else
DYNAMIC_INIT
# Linker flags for stage2 compiler (host -> target)
ARCH="${TARGET%%-*}"
export CARGO_TARGET_${ARCH^^}_UNKNOWN_REDOX_RUSTFLAGS="${RUSTFLAGS}" # Rust
# Hack for Rust errorneusly running `llvm-config --version` on cross compiled llvm-config
cat "${COOKBOOK_ROOT}/bin/${TARGET}-llvm-config" > "${COOKBOOK_SYSROOT}/bin/llvm-config"
# Hack for Rust stage1 being dynamically linked with LLVM in prefix toolchain
export LD_LIBRARY_PATH="${COOKBOOK_HOST_SYSROOT}/lib:${LD_LIBRARY_PATH}"
# Linker flags for stage1 compiler (host -> host)
export RUSTFLAGS_BOOTSTRAP="\
-Clink-args=-L${COOKBOOK_HOST_SYSROOT}/lib \
-Clink-args=-Wl,-rpath-link,${COOKBOOK_HOST_SYSROOT}/lib"
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_RUSTFLAGS="${RUSTFLAGS_BOOTSTRAP}"
cat ${COOKBOOK_RECIPE}/config.toml > config.toml
sed -i "s|COOKBOOK_SYSROOT|${COOKBOOK_SYSROOT}|g" config.toml
sed -i "s|COOKBOOK_TOOLCHAIN|${COOKBOOK_HOST_SYSROOT}|g" config.toml
sed -i "s|COOKBOOK_TARGET|${TARGET}|g" config.toml
sed -i "s|COOKBOOK_GNU_TARGET|${GNU_TARGET}|g" config.toml
fi
# Don't poison the stage1 compiler (host -> host)
unset AR AS CC CXX LD LDFLAGS NM OBJCOPY OBJDUMP RANLIB READELF RUSTFLAGS CARGO_ENCODED_RUSTFLAGS STRIP
python3 "${COOKBOOK_SOURCE}/x.py" install \
--config config.toml \
--jobs ${COOKBOOK_MAKE_JOBS}
mkdir -p "${COOKBOOK_STAGE}"/usr
rsync -av --delete "${COOKBOOK_BUILD}"/install/* "${COOKBOOK_STAGE}"/usr/
rm -rf "${COOKBOOK_STAGE}"/usr/lib/rustlib/*.log
# workaround for rust.lld, needed by e.g. compiling bootloader
# https://github.com/rust-lang/rust/issues/143076#issuecomment-3011710678
LLD_DIR="${COOKBOOK_STAGE}/usr/lib/rustlib/$TARGET/bin"
mkdir -p $LLD_DIR/gcc-ld
cp ${COOKBOOK_SYSROOT}/usr/bin/lld $LLD_DIR/rust-lld
ln -s rust-lld $LLD_DIR/wasm-component-ld
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld.lld
ln -s ../rust-lld $LLD_DIR/gcc-ld/ld64.lld
ln -s ../rust-lld $LLD_DIR/gcc-ld/lld-link
ln -s ../rust-lld $LLD_DIR/gcc-ld/wasm-ld
ln -s ../../../libLLVM.so.21.1 $LLD_DIR/../lib/libLLVM.so.21.1
"""
[[optional-packages]]
name = "doc"
files = [
"usr/share/doc/**",
]