diff options
| author | Ludovic Courtès <ludo@gnu.org> | 2026-03-17 23:01:15 +0100 |
|---|---|---|
| committer | Zheng Junjie <z572@z572.online> | 2026-06-20 23:59:08 +0800 |
| commit | 1d055aaa300bbf3bb50ca115649389664c55a952 (patch) | |
| tree | a9ba6be9bafc64658779ad50acde483b1f897b0e | |
| parent | 9b77694e32523a676e32f14bede89aac0d394f57 (diff) | |
gnu: commencement: Build “mesboot” toolchain with ‘_FILE_OFFSET_BITS=64’.
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 <ludo@gnu.org>
| -rw-r--r-- | gnu/packages/commencement.scm | 23 |
1 files 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.") | |||
| 503 | (for-each (lambda (x) (install-file x cache)) | 503 | (for-each (lambda (x) (install-file x cache)) |
| 504 | (append (objects-in-dir "m2") | 504 | (append (objects-in-dir "m2") |
| 505 | (objects-in-dir ".") | 505 | (objects-in-dir ".") |
| 506 | (objects-in-dir "mescc-lib"))))))))) | 506 | (objects-in-dir "mescc-lib")))))) |
| 507 | (add-after 'install 'use-64-bit-file-offsets | ||
| 508 | (lambda _ | ||
| 509 | ;; In Mes-Libc headers such as 'kernel-stat.h', | ||
| 510 | ;; __SIZEOF_LONG_LONG__ determines the layout of structures like | ||
| 511 | ;; 'struct stat' in the same way _FILE_OFFSET_BITS normally | ||
| 512 | ;; does. While 'mescc' defines this macro, 'tcc' does not, | ||
| 513 | ;; which leads to discrepancies. Thus hardcode it. | ||
| 514 | (substitute* (find-files (string-append #$output "/include") | ||
| 515 | (lambda (file stat) | ||
| 516 | (string-suffix? ".h" file))) | ||
| 517 | (("__SIZEOF_LONG_LONG__ == 8") "1") | ||
| 518 | (("__SIZEOF_LONG_LONG__ != 8") "0"))))))) | ||
| 507 | (native-search-paths | 519 | (native-search-paths |
| 508 | (list (search-path-specification | 520 | (list (search-path-specification |
| 509 | (variable "C_INCLUDE_PATH") | 521 | (variable "C_INCLUDE_PATH") |
| @@ -926,8 +938,9 @@ MesCC-Tools), and finally M2-Planet.") | |||
| 926 | #:strip-binaries? #f ; no strip yet | 938 | #:strip-binaries? #f ; no strip yet |
| 927 | #:configure-flags | 939 | #:configure-flags |
| 928 | #~(let ((cppflags (string-append | 940 | #~(let ((cppflags (string-append |
| 929 | " -D __GLIBC_MINOR__=6" | 941 | " -D__GLIBC_MINOR__=6" |
| 930 | " -D MES_BOOTSTRAP=1")) | 942 | " -DMES_BOOTSTRAP=1" |
| 943 | " -D_FILE_OFFSET_BITS=64")) | ||
| 931 | (bash (search-input-file %build-inputs "/bin/sh"))) | 944 | (bash (search-input-file %build-inputs "/bin/sh"))) |
| 932 | (list (string-append "CONFIG_SHELL=" bash) | 945 | (list (string-append "CONFIG_SHELL=" bash) |
| 933 | (string-append "CPPFLAGS=" cppflags) | 946 | (string-append "CPPFLAGS=" cppflags) |
| @@ -1006,7 +1019,8 @@ MesCC-Tools), and finally M2-Planet.") | |||
| 1006 | (add-before 'configure 'setenv | 1019 | (add-before 'configure 'setenv |
| 1007 | (lambda _ | 1020 | (lambda _ |
| 1008 | (let ((shell (search-input-file %build-inputs "/bin/bash")) | 1021 | (let ((shell (search-input-file %build-inputs "/bin/bash")) |
| 1009 | (cppflags " -D __GLIBC_MINOR__=6")) | 1022 | (cppflags (string-append " -D __GLIBC_MINOR__=6" |
| 1023 | " -D_FILE_OFFSET_BITS=64"))) | ||
| 1010 | (setenv "CONFIG_SHELL" shell) | 1024 | (setenv "CONFIG_SHELL" shell) |
| 1011 | (setenv "CPPFLAGS" cppflags) | 1025 | (setenv "CPPFLAGS" cppflags) |
| 1012 | (setenv "CC" (string-append "tcc" cppflags)) | 1026 | (setenv "CC" (string-append "tcc" cppflags)) |
| @@ -1198,6 +1212,7 @@ ac_cv_c_float_format='IEEE (little-endian)' | |||
| 1198 | (replace 'setenv | 1212 | (replace 'setenv |
| 1199 | (lambda _ | 1213 | (lambda _ |
| 1200 | (setenv "CONFIG_SHELL" (which "sh")) | 1214 | (setenv "CONFIG_SHELL" (which "sh")) |
| 1215 | (setenv "CPPFLAGS" "-D_FILE_OFFSET_BITS=64") | ||
| 1201 | (with-output-to-file "config.cache" | 1216 | (with-output-to-file "config.cache" |
| 1202 | (lambda _ | 1217 | (lambda _ |
| 1203 | (display " | 1218 | (display " |
