3c6f2bf301
After cooking relibc, copy the freshly built libc.a and libc.so to both the prefix toolchain and the redoxer toolchain (the latter is what 'make live' actually consumes for cross-recipe builds). Without this, recipes that link against the dynamic libc.so see a stale copy (no eventfd, no __fseterr, ...) and fail with 'undefined reference' at link time. 'make prefix' does this sync via its sysroot rule, but 'make r.relibc' alone does not — covering both paths prevents the first recipe that needs a new symbol from breaking the build.
63 lines
2.7 KiB
TOML
63 lines
2.7 KiB
TOML
[source]
|
|
path = "../../../local/sources/relibc"
|
|
|
|
[build]
|
|
template = "custom"
|
|
script = """
|
|
# rustup workaround https://github.com/rust-lang/rustup/issues/988
|
|
if [ "${COOKBOOK_HOST_SYSROOT}" = "/usr" ] && command -v rustup >/dev/null 2>&1; then
|
|
pushd ${COOKBOOK_SOURCE}
|
|
${RUSTUP:-rustup} install
|
|
popd
|
|
fi
|
|
|
|
# relibc HEAD uses VaList::next_arg() and VaList<'a> (1 lifetime) from
|
|
# Rust 1.98-dev. The PREFIX toolchain (nightly-2025-11-15) is older and
|
|
# has VaList<'a, 'f: 'a> (2 lifetimes) with no next_arg() method.
|
|
# When building via make live, REDOXER_TOOLCHAIN=PREFIX forces the older
|
|
# Rust. Override to the redoxer default toolchain (Rust 1.98-dev) which
|
|
# has the required API. Skip during PREFIX bootstrap (*.partial dirs).
|
|
REDOXER_TC="${REDOXER_TOOLCHAIN:-}"
|
|
if [ -n "${REDOXER_TC}" ] && [[ "${REDOXER_TC}" != *".partial"* ]]; then
|
|
REDOXER_DEFAULT="${HOME}/.redoxer/${TARGET}/toolchain"
|
|
if [ -d "${REDOXER_DEFAULT}/lib/rustlib/src/rust/library/core" ]; then
|
|
export RUSTUP_TOOLCHAIN="${REDOXER_DEFAULT}"
|
|
export PATH="${REDOXER_DEFAULT}/bin:${PATH}"
|
|
fi
|
|
fi
|
|
|
|
export CARGO=${CARGO:-env -u CARGO cargo}
|
|
"${COOKBOOK_MAKE}" \
|
|
-C "${COOKBOOK_SOURCE}" \
|
|
-j"${COOKBOOK_MAKE_JOBS}" \
|
|
DESTDIR="${COOKBOOK_STAGE}/usr" \
|
|
install
|
|
|
|
# Fix cbindgen generating ... instead of va_list for v*printf functions
|
|
sed -i '/^int vfprintf(/s/\\.\\.\\./va_list ap/' "${COOKBOOK_STAGE}/usr/include/stdio.h"
|
|
sed -i '/^int vsnprintf(/s/\\.\\.\\./va_list ap/' "${COOKBOOK_STAGE}/usr/include/stdio.h"
|
|
sed -i '/^int vsprintf(/s/\\.\\.\\./va_list ap/' "${COOKBOOK_STAGE}/usr/include/stdio.h"
|
|
|
|
# Mirror the freshly built libc into the prefix toolchain. `make prefix`
|
|
# does this via mk/prefix.mk, but `make r.relibc` alone does not, and
|
|
# recipes that link against the dynamic libc.so would otherwise see a
|
|
# stale libc.so (no eventfd, no __fseterr, ...) and fail with
|
|
# "undefined reference" at link time. The redoxer toolchain is what
|
|
# `make live` actually consumes for cross-recipe builds, so it must
|
|
# stay in sync too.
|
|
PREFIX_LIB_DIR="${COOKBOOK_HOST_SYSROOT%/}/${TARGET}/lib"
|
|
if [ -d "${PREFIX_LIB_DIR}" ]; then
|
|
cp -f "${COOKBOOK_STAGE}/usr/lib/libc.a" "${PREFIX_LIB_DIR}/" 2>/dev/null || true
|
|
if [ -f "${COOKBOOK_STAGE}/usr/lib/libc.so" ]; then
|
|
cp -f "${COOKBOOK_STAGE}/usr/lib/libc.so" "${PREFIX_LIB_DIR}/" 2>/dev/null || true
|
|
fi
|
|
fi
|
|
REDOXER_TC_LIB="${HOME}/.redoxer/${TARGET}/toolchain/${TARGET}/lib"
|
|
if [ -d "${REDOXER_TC_LIB}" ]; then
|
|
cp -f "${COOKBOOK_STAGE}/usr/lib/libc.a" "${REDOXER_TC_LIB}/" 2>/dev/null || true
|
|
if [ -f "${COOKBOOK_STAGE}/usr/lib/libc.so" ]; then
|
|
cp -f "${COOKBOOK_STAGE}/usr/lib/libc.so" "${REDOXER_TC_LIB}/" 2>/dev/null || true
|
|
fi
|
|
fi
|
|
"""
|