8b0cabaa47
Root cause chain discovered and fixed: 1. GCC built-in stddef.h shadowed by relibc's _STDDEF_H guard → fix_types.h with guarded typedefs for 15+ sys types 2. gnulib configure bakes raw typedefs into GL_CFLAG_GNULIB_WARNINGS → strip them from Makefiles after configure 3. __fseterr/__freadahead don't exist in relibc → compile C stubs and inject into link via Makefile patch The recipe pattern is documented and reusable for other gnulib packages (ninja-build, diffutils, etc.). Also: bootloader recipe needs RUSTFLAGS=-Zunstable-options for custom target support after redoxer toolchain restore.
155 lines
5.8 KiB
TOML
155 lines
5.8 KiB
TOML
[source]
|
|
tar = "https://ftp.gnu.org/gnu/m4/m4-1.14.21.tar.xz"
|
|
patches = ["redox.patch"]
|
|
|
|
[build]
|
|
template = "custom"
|
|
script = """
|
|
DYNAMIC_INIT
|
|
|
|
# Use prefix toolchain (not redoxer's which has broken stdint injection)
|
|
export CC="/home/kellito/Builds/RedBear-OS/prefix/x86_64-unknown-redox/gcc-install/bin/x86_64-unknown-redox-gcc"
|
|
export CXX="/home/kellito/Builds/RedBear-OS/prefix/x86_64-unknown-redox/gcc-install/bin/x86_64-unknown-redox-g++"
|
|
export AR="/home/kellito/Builds/RedBear-OS/prefix/x86_64-unknown-redox/gcc-install/bin/x86_64-unknown-redox-ar"
|
|
export RANLIB="/home/kellito/Builds/RedBear-OS/prefix/x86_64-unknown-redox/gcc-install/bin/x86_64-unknown-redox-ranlib"
|
|
unset CPPFLAGS
|
|
unset CFLAGS
|
|
unset CXXFLAGS
|
|
unset LDFLAGS
|
|
unset CFLAGS_x86_64_unknown_redox
|
|
unset CXXFLAGS_x86_64_unknown_redox
|
|
export CPPFLAGS="-I${COOKBOOK_SOURCE}/lib -include fix_types.h"
|
|
export CFLAGS=""
|
|
export CXXFLAGS=""
|
|
export LDFLAGS=""
|
|
|
|
# Add relibc system headers to the include path.
|
|
# The cookbook sets CPPFLAGS="-I${COOKBOOK_SYSROOT}/include" but the recipe
|
|
# sysroot is empty for packages with no header-providing deps. The relibc
|
|
# headers are at prefix/${TARGET}/relibc-install/${TARGET}/include/ — not in
|
|
# the compiler's default search path. Without this, gnulib's #include_next
|
|
# can't find the system headers and every wrapper fails.
|
|
RELIBC_INCLUDE="${COOKBOOK_ROOT}/prefix/${TARGET}/relibc-install/${TARGET}/include"
|
|
export CPPFLAGS="${CPPFLAGS} -isystem ${RELIBC_INCLUDE}"
|
|
|
|
# relibc's float.h is missing LDBL_DIG (and possibly other LDBL_* macros).
|
|
# For x86_64 80-bit extended precision: LDBL_DIG = floor(63 * log10(2)) = 18
|
|
export CPPFLAGS="${CPPFLAGS} -DLDBL_DIG=18"
|
|
|
|
# The redoxer toolchain has a stale libc without __fseterr/__freadahead.
|
|
# Add the relibc library path so the linker finds the updated library.
|
|
RELIBC_LIB="${COOKBOOK_ROOT}/prefix/${TARGET}/relibc-install/${TARGET}/lib"
|
|
export LDFLAGS="${LDFLAGS} -L${RELIBC_LIB}"
|
|
|
|
# Gnulib cross-compilation: relibc provides standard POSIX headers and types
|
|
# but gnulib's configure can't run test programs during cross-compilation.
|
|
export ac_cv_header_stdio_h=yes
|
|
export ac_cv_header_stdlib_h=yes
|
|
export ac_cv_header_string_h=yes
|
|
export ac_cv_header_strings_h=yes
|
|
export ac_cv_header_inttypes_h=yes
|
|
export ac_cv_header_stdint_h=yes
|
|
export ac_cv_header_unistd_h=yes
|
|
export ac_cv_header_sys_types_h=yes
|
|
export ac_cv_header_sys_stat_h=yes
|
|
export ac_cv_header_time_h=yes
|
|
export ac_cv_header_sys_time_h=yes
|
|
export ac_cv_header_sys_select_h=yes
|
|
export ac_cv_header_wchar_h=yes
|
|
export ac_cv_header_wctype_h=yes
|
|
export ac_cv_header_signal_h=yes
|
|
export ac_cv_header_dirent_h=yes
|
|
export ac_cv_header_fcntl_h=yes
|
|
export ac_cv_header_locale_h=yes
|
|
export ac_cv_header_errno_h=yes
|
|
export ac_cv_header_ctype_h=yes
|
|
export ac_cv_header_limits_h=yes
|
|
export ac_cv_header_stdarg_h=yes
|
|
export ac_cv_header_stddef_h=yes
|
|
export ac_cv_header_spawn_h=yes
|
|
|
|
# Standard types
|
|
export ac_cv_type_intmax_t=yes
|
|
export ac_cv_type_uintmax_t=yes
|
|
export ac_cv_type_gid_t=yes
|
|
export ac_cv_type_uid_t=yes
|
|
export ac_cv_type_pid_t=yes
|
|
export ac_cv_type_mode_t=yes
|
|
export ac_cv_type_off_t=yes
|
|
export ac_cv_type_size_t=yes
|
|
export ac_cv_type_ssize_t=yes
|
|
export ac_cv_type_ptrdiff_t=yes
|
|
export ac_cv_type_nlink_t=yes
|
|
export ac_cv_type_mbstate_t=yes
|
|
export ac_cv_type_time_t=yes
|
|
export gl_cv_type_intmax_t=yes
|
|
export gl_cv_type_ptrdiff_t_signed=yes
|
|
export gl_cv_header_inttypes_h_with_uintmax=yes
|
|
export ac_cv_have_inttypes_h_with_uintmax=yes
|
|
|
|
# openat: Redox doesn't have /proc/self/fd — skip gnulib replacement
|
|
export ac_cv_func_openat=yes
|
|
export gl_cv_func_openat_works=yes
|
|
|
|
# m4-specific gnulib function checks
|
|
export ac_cv_func___freadahead=yes
|
|
export gl_cv_func___freadahead=yes
|
|
export ac_cv_have_decl___freadahead=yes
|
|
export gl_cv_header_wchar_h_correct_inline=yes
|
|
export gl_cv_func_btowc_nul=yes
|
|
export gl_cv_func_btowc_consistent=yes
|
|
export gl_cv_onwards_func___freadahead=yes
|
|
export gl_cv_socklen_t_equiv=socklen_t
|
|
export ac_cv_func_getpagesize=yes
|
|
export ac_cv_func_memcmp_working=yes
|
|
|
|
# Tell gnulib these wide-char functions exist and work
|
|
export ac_cv_func_btowc=yes
|
|
export ac_cv_func_mbrtowc=yes
|
|
export ac_cv_func_mbsinit=yes
|
|
export ac_cv_func_wcrtomb=yes
|
|
export ac_cv_func_wctob=yes
|
|
export ac_cv_func_mbsrtowcs=yes
|
|
export ac_cv_func_wcswidth=yes
|
|
export ac_cv_func_wcwidth=yes
|
|
export gl_cv_func_btowc=yes
|
|
export gl_cv_func_mbrtowc=yes
|
|
export gl_cv_func_mbsinit=yes
|
|
export gl_cv_func_wcrtomb=yes
|
|
export gl_cv_func_wctob=yes
|
|
export gl_cv_func_wcwidth=yes
|
|
export gl_cv_func_wcswidth=yes
|
|
|
|
# Functions that relibc provides but gnulib can't detect during cross-compilation
|
|
export ac_cv_func___fseterr=yes
|
|
export gl_cv_func___fseterr=yes
|
|
export ac_cv_func_getlocalename_l=yes
|
|
|
|
COOKBOOK_CONFIGURE_FLAGS+=(
|
|
--disable-nls
|
|
)
|
|
|
|
"${COOKBOOK_CONFIGURE}" "${COOKBOOK_CONFIGURE_FLAGS[@]}"
|
|
|
|
# Fix gnulib cross-compilation misdetections in config.h
|
|
"${COOKBOOK_ROOT}/local/scripts/gnulib-cross-fix.sh" "${COOKBOOK_BUILD}/lib/config.h"
|
|
|
|
# gnulib configure bakes raw typedefs into GL_CFLAG_GNULIB_WARNINGS
|
|
# in the generated Makefile. These break shell command parsing.
|
|
# Strip them after configure, before make.
|
|
find "${COOKBOOK_BUILD}" -name Makefile -exec sed -i 's/typedef [^;]*; //g' {} +
|
|
echo "m4: stripped raw typedefs from Makefiles"
|
|
|
|
# gnulib assumes __fseterr/__freadahead exist in libc but relibc doesn't
|
|
# provide them. Compile stubs and add to link line by patching Makefile.
|
|
"${CC:-x86_64-unknown-redox-gcc}" ${CFLAGS} -c "${COOKBOOK_SOURCE}/lib/fseterr-redox.c" -o "${COOKBOOK_BUILD}/lib/fseterr-redox.o"
|
|
"${CC:-x86_64-unknown-redox-gcc}" ${CFLAGS} -c "${COOKBOOK_SOURCE}/lib/freadahead-redox.c" -o "${COOKBOOK_BUILD}/lib/freadahead-redox.o"
|
|
find "${COOKBOOK_BUILD}" -name Makefile -exec sed -i 's|$(LIBS)|$(LIBS) ../lib/fseterr-redox.o ../lib/freadahead-redox.o|g' {} +
|
|
|
|
"${COOKBOOK_MAKE}" -j "${COOKBOOK_MAKE_JOBS}" HELP2MAN=true
|
|
"${COOKBOOK_MAKE}" install DESTDIR="${COOKBOOK_STAGE}" HELP2MAN=true
|
|
"""
|
|
|
|
[package]
|
|
description = "GNU M4 macro processor"
|