1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

linker: Create sparse files for padding.

Since ‘*lcm-page-size*’ is 64 KiB, this saves disk space for small ‘.go’
files.

* module/system/vm/linker.scm (link-elf)[write-padding]: Rewrite in
terms of ‘seek’.
This commit is contained in:
Ludovic Courtès 2024-04-15 15:58:30 +02:00
parent 6495b4d578
commit 4a0c2433d9
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -769,16 +769,10 @@ Returns a bytevector."
objects) objects)
bv) bv)
(lambda (port) (lambda (port)
(define write-padding (define (write-padding port size)
(let ((blank (make-bytevector 4096 0))) ;; Write SIZE bytes of padding to PORT. Use 'seek' to
(lambda (port size) ;; create a sparse file.
;; Write SIZE bytes of padding to PORT. (seek port size SEEK_CUR))
(let loop ((size size))
(unless (zero? size)
(let ((count (min size
(bytevector-length blank))))
(put-bytevector port blank 0 count)
(loop (- size count))))))))
(define (compute-padding objects) (define (compute-padding objects)
;; Return the list of padding in between OBJECTS--the list ;; Return the list of padding in between OBJECTS--the list