From 1d055aaa300bbf3bb50ca115649389664c55a952 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= Date: Tue, 17 Mar 2026 23:01:15 +0100 Subject: =?UTF-8?q?gnu:=20commencement:=20Build=20=E2=80=9Cmesboot?= =?UTF-8?q?=E2=80=9D=20toolchain=20with=20=E2=80=98=5FFILE=5FOFFSET=5FBITS?= =?UTF-8?q?=3D64=E2=80=99.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes a bug whereby, for example, ‘gcc-mesboot0’ would fail to read its own spec file because the ‘stat’ function would return EOVERFLOW when encountering an inode number or timestamps that does not fit in 32 bits (on Btrfs inode numbers greater than 2^32 are not uncommon), a UID/GID that does not fit in 16 bits, etc. Internally, when ‘_FILE_OFFSET_BITS’ is unset, the ‘stat’ function in glibc invokes the ‘stat64’ syscall and then converts the result to a 32-bit ‘struct stat’, failing with EOVERFLOW if one of the field from ‘struct stat64’ doesn’t fit in the corresponding field of ‘struct stat’. In Mes-Libc, the choice between ‘stat’ and ‘stat64’ (and the corresponding struct layout), ‘getdents’ and ‘getdents64’, etc. is dictated by the value of ‘__SIZEOF_LONG_LONG__’, which ‘mescc’ sets to 8 but ‘tcc’ leaves unset (equivalent to 0). This change forces use of ‘stat64’ & co. for Mes-Libc users, including when using ‘tcc’. * gnu/packages/commencement.scm (mes-boot)[arguments]: Add ‘use-64-bit-file-offsets’ phase. (binutils-mesboot0)[arguments]: Add ‘-D_FILE_OFFSET_BITS=64’ to ‘cppflags’. (gcc-core-mesboot0)[arguments]: Likewise. (gcc-mesboot0)[arguments]: Likewise. Fixes: guix/guix#7194 Change-Id: I05d5b8f5aee78ca0e95d7c89ba93b2729791a66a Signed-off-by: Ludovic Courtès --- gnu/packages/commencement.scm | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index d87c225c721..d4c381168a7 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -503,7 +503,19 @@ MesCC-Tools), and finally M2-Planet.") (for-each (lambda (x) (install-file x cache)) (append (objects-in-dir "m2") (objects-in-dir ".") - (objects-in-dir "mescc-lib"))))))))) + (objects-in-dir "mescc-lib")))))) + (add-after 'install 'use-64-bit-file-offsets + (lambda _ + ;; In Mes-Libc headers such as 'kernel-stat.h', + ;; __SIZEOF_LONG_LONG__ determines the layout of structures like + ;; 'struct stat' in the same way _FILE_OFFSET_BITS normally + ;; does. While 'mescc' defines this macro, 'tcc' does not, + ;; which leads to discrepancies. Thus hardcode it. + (substitute* (find-files (string-append #$output "/include") + (lambda (file stat) + (string-suffix? ".h" file))) + (("__SIZEOF_LONG_LONG__ == 8") "1") + (("__SIZEOF_LONG_LONG__ != 8") "0"))))))) (native-search-paths (list (search-path-specification (variable "C_INCLUDE_PATH") @@ -926,8 +938,9 @@ MesCC-Tools), and finally M2-Planet.") #:strip-binaries? #f ; no strip yet #:configure-flags #~(let ((cppflags (string-append - " -D __GLIBC_MINOR__=6" - " -D MES_BOOTSTRAP=1")) + " -D__GLIBC_MINOR__=6" + " -DMES_BOOTSTRAP=1" + " -D_FILE_OFFSET_BITS=64")) (bash (search-input-file %build-inputs "/bin/sh"))) (list (string-append "CONFIG_SHELL=" bash) (string-append "CPPFLAGS=" cppflags) @@ -1006,7 +1019,8 @@ MesCC-Tools), and finally M2-Planet.") (add-before 'configure 'setenv (lambda _ (let ((shell (search-input-file %build-inputs "/bin/bash")) - (cppflags " -D __GLIBC_MINOR__=6")) + (cppflags (string-append " -D __GLIBC_MINOR__=6" + " -D_FILE_OFFSET_BITS=64"))) (setenv "CONFIG_SHELL" shell) (setenv "CPPFLAGS" cppflags) (setenv "CC" (string-append "tcc" cppflags)) @@ -1198,6 +1212,7 @@ ac_cv_c_float_format='IEEE (little-endian)' (replace 'setenv (lambda _ (setenv "CONFIG_SHELL" (which "sh")) + (setenv "CPPFLAGS" "-D_FILE_OFFSET_BITS=64") (with-output-to-file "config.cache" (lambda _ (display " -- cgit v1.2.3