relibc: mirror fresh libc to prefix and redoxer toolchain

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.
This commit is contained in:
2026-06-28 16:12:48 +03:00
parent 7ac4349fd0
commit 3c6f2bf301
+22
View File
@@ -37,4 +37,26 @@ export CARGO=${CARGO:-env -u CARGO cargo}
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
"""