diff --git a/mk/prefix.mk b/mk/prefix.mk index 37c211eb05..3efcb091c0 100644 --- a/mk/prefix.mk +++ b/mk/prefix.mk @@ -103,6 +103,22 @@ ifeq ($(PODMAN_BUILD),1) else rm -rf "$@" cp -r "$(PREFIX)/relibc-install/" "$@" +# Patch relibc sysroot and redoxer toolchain GCC for strtold. +# relibc declares strtold in stdlib.h (cbindgen trailer) but GCC's +# cstdlib does 'using ::strtold' before the trailer is processed. +# Add explicit #include after #include_next +# so ::strtold is visible when the C++ wrapper runs its using. + for _cstdlib in "$(COOKBOOK_ROOT)/prefix/${TARGET}/sysroot/${GNU_TARGET}/include/c++"/*/cstdlib; do \ + [ -f "$$_cstdlib" ] || continue; \ + sed -i '/^#include_next $$/a\\n// Red Bear: relibc declares strtold via cbindgen trailer.\n// The explicit include ensures ::strtold is visible when the\n// C++ wrapper processes its using-directives below.\n#include ' "$$_cstdlib"; \ + done + @REDOXER_TC=$(HOME)/.redoxer/$(TARGET)/toolchain/$(GNU_TARGET); \ + if [ -d "$$REDOXER_TC/include/c++" ]; then \ + for _cstdlib in "$$REDOXER_TC/include/c++"/*/cstdlib; do \ + [ -f "$$_cstdlib" ] || continue; \ + sed -i '/^#include_next $$/a\\n// Red Bear: relibc declares strtold via cbindgen trailer.\n// The explicit include ensures ::strtold is visible when the\n// C++ wrapper processes its using-directives below.\n#include ' "$$_cstdlib"; \ + done; \ + fi # Propagate fresh relibc artifacts (libc.a, crt*.o, headers) from the # rebuilt sysroot back into gcc-install. The GCC driver's built-in # library search path always looks inside gcc-install/ first; if that