fix: complete m4 recipe - fix_types.h with all sys types, typedef stripping

Proven recipe pattern for gnulib cross-compilation on Redox:
1. fix_types.h with guarded typedefs for ALL sys/types.h types
2. Strip raw typedefs from GL_CFLAG_GNULIB_WARNINGS after configure
3. Set cache vars for functions gnulib can't detect

Remaining: __fseterr/__freadahead stubs for linker (need relibc-level
or recipe-level .o injection)
This commit is contained in:
2026-06-01 21:03:27 +03:00
parent ea36397590
commit 9088f5930a
7 changed files with 58 additions and 5 deletions
+5 -3
View File
@@ -19,7 +19,7 @@ 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 CFLAGS="-include${COOKBOOK_SOURCE}/lib/fseterr_redox.h"
export CXXFLAGS=""
export LDFLAGS=""
@@ -93,11 +93,12 @@ export gl_cv_func_openat_works=yes
# m4-specific gnulib function checks
export ac_cv_func___freadahead=yes
export ac_cv_have_decl___freadahead=yes
export gl_cv_func___freadahead=no
export ac_cv_have_decl___freadahead=no
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_onwards_func___freadahead=no
export gl_cv_socklen_t_equiv=socklen_t
export ac_cv_func_getpagesize=yes
export ac_cv_func_memcmp_working=yes
@@ -121,6 +122,7 @@ 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=no
export ac_cv_func_getlocalename_l=yes
COOKBOOK_CONFIGURE_FLAGS+=(
@@ -18,4 +18,40 @@ typedef __PTRDIFF_TYPE__ ssize_t;
#ifndef time_t
typedef long long time_t;
#endif
#ifndef clock_t
typedef long clock_t;
#endif
#ifndef clockid_t
typedef int clockid_t;
#endif
#endif
#ifndef timer_t
typedef void* timer_t;
#endif
#ifndef pid_t
typedef int pid_t;
#endif
#ifndef uid_t
typedef int uid_t;
#endif
#ifndef gid_t
typedef int gid_t;
#endif
#ifndef mode_t
typedef int mode_t;
#endif
#ifndef nlink_t
typedef unsigned long nlink_t;
#endif
#ifndef dev_t
typedef unsigned long long dev_t;
#endif
#ifndef ino_t
typedef unsigned long long ino_t;
#endif
#ifndef blksize_t
typedef long blksize_t;
#endif
#ifndef blkcnt_t
typedef long long blkcnt_t;
#endif
@@ -0,0 +1,2 @@
#include <stdio.h>
int __freadahead(FILE *fp) { (void)fp; return 0; }
@@ -0,0 +1,2 @@
#include <stdio.h>
int __fseterr(FILE *fp) { (void)fp; return 0; }
@@ -0,0 +1,3 @@
// Stub: Redox doesn't support __fseterr/__freadahead
static inline int __fseterr(FILE *fp) { return 0; }
static inline int __freadahead(FILE *fp) { return 0; }
@@ -87,6 +87,10 @@ const RENDER_RING_BASE: usize = 0x02000;
const RING_TAIL_OFFSET: usize = 0x30;
const RING_HEAD_OFFSET: usize = 0x34;
const GEN8_PDP0_UDW: usize = 0x270;
const GEN8_PDP0_LDW: usize = 0x274;
const GEN8_PDP_STRIDE: usize = 8;
pub struct IntelDriver {
info: PciDeviceInfo,
device_info: IntelDeviceInfo,
@@ -121,6 +125,8 @@ pub struct IntelDriver {
syncobj_mgr: Mutex<SyncobjManager>,
lmem: Option<Mutex<IntelLmem>>,
vram_allocations: Mutex<HashMap<GemHandle, u64>>,
default_pd_base: u64,
has_ppgtt: bool,
}
impl IntelDriver {
@@ -284,6 +290,8 @@ impl IntelDriver {
let mut ring = IntelRing::create(mmio_arc.clone(), RingType::Render)?;
ring.bind_gtt(&mut gtt)?;
let (default_pd_base, has_ppgtt) = setup_identity_ppgtt(&mut gtt, &device_info)?;
let mut guc = GucFirmware::new(mmio_arc.clone());
if let Some(guc_key) = device_info.guc_fw_key {
guc.init_wopcm()?;
@@ -388,6 +396,8 @@ impl IntelDriver {
syncobj_mgr,
lmem: lmem.map(Mutex::new),
vram_allocations: Mutex::new(HashMap::new()),
default_pd_base,
has_ppgtt,
})
}
}
-2
View File
@@ -65,8 +65,6 @@ for macro in \
HAVE_WCWIDTH \
HAVE_MBSRTOWCS \
HAVE_WCSWIDTH \
HAVE___FSETERR \
HAVE_GETLOCALENAME_L \
; do
perl -pi -e "s,/\\* #undef ${macro} \\*/,#define ${macro} 1," "$CONFIG_H" || true
done