From 3b4d7cdccce97dbffee538812c86bc03a6ae35d9 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 2 Apr 2020 14:17:36 +0200 Subject: bournish: Prevent inlining of run-time support procedures. On Guile 3, those procedures could be inlined, leading to unbound-variable errors: scheme@(guile-user)> ,bournish Welcome to Bournish, a minimal Bourne-like shell! To switch back, type `,L scheme'. bournish@(guile-user)> ls ice-9/boot-9.scm:1669:16: In procedure raise-exception: Unbound variable: ls-command-implementation Reported by Ricardo Wurmus. * guix/build/bournish.scm (define-command-runtime): New macro. (ls-command-implementation, wc-command-implementation) (wc-l-command-implementation, wc-c-command-implementation): Use it instead of 'define'. --- guix/build/bournish.scm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'guix/build') diff --git a/guix/build/bournish.scm b/guix/build/bournish.scm index 247a687d80..31fc493b09 100644 --- a/guix/build/bournish.scm +++ b/guix/build/bournish.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2016, 2017 Ludovic Courtès +;;; Copyright © 2016, 2017, 2020 Ludovic Courtès ;;; Copyright © 2016 Efraim Flashner ;;; Copyright © 2017 Ricardo Wurmus ;;; @@ -83,7 +83,21 @@ TERMINAL-WIDTH. Use COLUMN-GAP spaces between two subsequent columns." (newline) (loop (map 1+ indexes))))) -(define ls-command-implementation +(define-syntax define-command-runtime + (syntax-rules () + "Define run-time support of a Bournish command. This macro ensures that +the implementation is not subject to inlining, which would prevent compiled +code from referring to it via '@@'." + ((_ (command . args) body ...) + (define-command-runtime command (lambda args body ...))) + ((_ command exp) + (begin + (define command exp) + + ;; Prevent inlining of COMMAND. + (set! command command))))) + +(define-command-runtime ls-command-implementation ;; Run-time support procedure. (case-lambda (() @@ -173,13 +187,13 @@ TERMINAL-WIDTH. Use COLUMN-GAP spaces between two subsequent columns." (call-with-input-file file lines+chars))) (format #t "~a ~a~%" chars file))) -(define (wc-command-implementation . files) +(define-command-runtime (wc-command-implementation . files) (for-each wc-print (filter file-exists?* files))) -(define (wc-l-command-implementation . files) +(define-command-runtime (wc-l-command-implementation . files) (for-each wc-l-print (filter file-exists?* files))) -(define (wc-c-command-implementation . files) +(define-command-runtime (wc-c-command-implementation . files) (for-each wc-c-print (filter file-exists?* files))) (define (wc-command . args) -- cgit v1.2.3 From 041c3c22dc14d485ca58b3ae1436b62d4a39d0aa Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 7 Apr 2020 23:48:54 +0200 Subject: compile: Run the load phase within 'with-target'. * guix/build/compile.scm (compile-files)[build]: Remove 'with-target'. Wrap body in 'with-target'. --- guix/build/compile.scm | 51 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) (limited to 'guix/build') diff --git a/guix/build/compile.scm b/guix/build/compile.scm index 4b6472784c..3ce0ecede5 100644 --- a/guix/build/compile.scm +++ b/guix/build/compile.scm @@ -184,36 +184,35 @@ files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"." ;; Exit as soon as something goes wrong. (exit-on-exception file - (with-target host - (lambda () - (let ((relative (relative-file source-directory file))) - (compile-file file - #:output-file (string-append build-directory "/" - (scm->go relative)) - #:opts (append warning-options - (optimization-options relative)))))))) + (let ((relative (relative-file source-directory file))) + (compile-file file + #:output-file (string-append build-directory "/" + (scm->go relative)) + #:opts (append warning-options + (optimization-options relative)))))) (with-augmented-search-path %load-path source-directory (with-augmented-search-path %load-compiled-path build-directory (with-fluids ((*current-warning-prefix* "")) - - ;; FIXME: To work around , we first load all - ;; of FILES. - (load-files source-directory files - #:report-load report-load - #:debug-port debug-port) - - ;; Make sure compilation related modules are loaded before starting to - ;; compile files in parallel. - (compile #f) - - ;; XXX: Don't use too many workers to work around the insane memory - ;; requirements of the compiler in Guile 2.2.2: - ;; . - (n-par-for-each (min workers 8) build files) - - (unless (zero? total) - (report-compilation #f total total)))))) + (with-target host + (lambda () + ;; FIXME: To work around , we first + ;; load all of FILES. + (load-files source-directory files + #:report-load report-load + #:debug-port debug-port) + + ;; Make sure compilation related modules are loaded before + ;; starting to compile files in parallel. + (compile #f) + + ;; XXX: Don't use too many workers to work around the insane + ;; memory requirements of the compiler in Guile 2.2.2: + ;; . + (n-par-for-each (min workers 8) build files) + + (unless (zero? total) + (report-compilation #f total total)))))))) (eval-when (eval load) (when (and (string=? "2" (major-version)) -- cgit v1.2.3 From 93d5cea57e6cbbbf99066aef65da65795cf51fd6 Mon Sep 17 00:00:00 2001 From: nixo Date: Fri, 17 Jan 2020 19:40:55 +0100 Subject: build: julia-build-system: Update for new Julia version. * guix/build/julia-build-system.scm (generate-load-path): Delete function. (install): Don't set JULIA_LOAD_PATH. (precompile): Set SOURCE_DATE_EPOCH. Update calculating the JULIA_LOAD_PATH. Adjust the 'invoke-julia' command. (check): Set SOURCE_DATE_EPOCH. Adjust JULIA_LOAD_PATH. Signed-off-by: Efraim Flashner --- guix/build/julia-build-system.scm | 51 +++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'guix/build') diff --git a/guix/build/julia-build-system.scm b/guix/build/julia-build-system.scm index ff6fcf5fe3..e8ebcf8ba0 100644 --- a/guix/build/julia-build-system.scm +++ b/guix/build/julia-build-system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2019 Nicolò Balzarotti +;;; Copyright © 2019, 2020 Nicolò Balzarotti ;;; ;;; This file is part of GNU Guix. ;;; @@ -37,53 +37,46 @@ ;; subpath where we store the package content (define %package-path "/share/julia/packages/") -(define (generate-load-path inputs outputs) - (string-append - (string-join (map (match-lambda - ((_ . path) - (string-append path %package-path))) - ;; Restrict to inputs beginning with "julia-". - (filter (match-lambda - ((name . _) - (string-prefix? "julia-" name))) - inputs)) - ":") - (string-append ":" (assoc-ref outputs "out") %package-path) - ;; stdlib is always required to find Julia's standard libraries. - ;; usually there are other two paths in this variable: - ;; "@" and "@v#.#" - ":@stdlib")) - (define* (install #:key source inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (package-dir (string-append out %package-path - (string-append - (strip-store-file-name source))))) - (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs)) + (strip-store-file-name source)))) (mkdir-p package-dir) - (copy-recursively source package-dir)) + (copy-recursively (getcwd) package-dir)) #t) -;; TODO: Precompilation is working, but I don't know how to tell -;; julia to use use it. If (on rantime) we set HOME to -;; store path, julia tries to write files there (failing) (define* (precompile #:key source inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (builddir (string-append out "/share/julia/")) (package (strip-store-file-name source))) (mkdir-p builddir) + ;; With a patch, SOURCE_DATE_EPOCH is honored + (setenv "SOURCE_DATE_EPOCH" "1") (setenv "JULIA_DEPOT_PATH" builddir) - (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs)) - ;; Actual precompilation - (invoke-julia (string-append "using " package))) + ;; Add new package dir to the load path. + (setenv "JULIA_LOAD_PATH" + (string-append builddir "packages/" ":" + (or (getenv "JULIA_LOAD_PATH") + ""))) + ;; Actual precompilation: + (invoke-julia + ;; When using Julia as a user, Julia writes precompile cache to the first + ;; entry of the DEPOT_PATH list (by default, the home dir). We want to + ;; write it to the store, so let's push the store path as the first + ;; element of DEPOT_PATH. Once the cache file exists, this hack is not + ;; needed anymore (like in the check phase). If the user install new + ;; packages, those will be installed and precompiled in the home dir. + (string-append "pushfirst!(DEPOT_PATH, pop!(DEPOT_PATH)); using " package))) #t) (define* (check #:key source inputs outputs #:allow-other-keys) (let* ((out (assoc-ref outputs "out")) (package (strip-store-file-name source)) (builddir (string-append out "/share/julia/"))) + ;; With a patch, SOURCE_DATE_EPOCH is honored + (setenv "SOURCE_DATE_EPOCH" "1") (setenv "JULIA_DEPOT_PATH" builddir) - (setenv "JULIA_LOAD_PATH" (generate-load-path inputs outputs)) + (setenv "JULIA_LOAD_PATH" (string-append builddir "packages/")) (invoke-julia (string-append "using Pkg;Pkg.test(\"" package "\")"))) #t) -- cgit v1.2.3 From 82d8959e5d137b2061a68878d78a8f74a238ac44 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 16 Apr 2020 17:34:38 +0200 Subject: syscalls: 'readdir*' chooses between the Linux and Hurd code at run time. Partly fixes . Reported by Jan Nieuwenhuizen . Previously, we'd choose at expansion time whether to use the Hurd or the Linux variant, taking the cross-compilation target into account. This would lead to the wrong decision when (guix build syscalls) is evaluated while we're cross-compiling to GNU/Hurd. This is a followup to 1ab9e483391f8b62b873833ea71cb0074efa03e7. * guix/build/syscalls.scm (define-generic-identifier) (read-dirent-header, %struct-dirent-header, sizeof-dirent-header): Remove. (readdir*): Rename to... (readdir-procedure): ... this, and add parameters. (readdir*): Define as a call to 'readdir-procedure' as a function of %HOST-TYPE. --- guix/build/syscalls.scm | 50 +++++++++++++++---------------------------------- 1 file changed, 15 insertions(+), 35 deletions(-) (limited to 'guix/build') diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 0938ec0ff1..7ef03417c1 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -22,7 +22,6 @@ (define-module (guix build syscalls) #:use-module (system foreign) - #:use-module (system base target) ;for cross-compilation support #:use-module (rnrs bytevectors) #:autoload (ice-9 binary-ports) (get-bytevector-n) #:use-module (srfi srfi-1) @@ -892,36 +891,6 @@ system to PUT-OLD." (namelen uint8) (name uint8)) -(define-syntax define-generic-identifier - (syntax-rules (gnu/linux gnu/hurd =>) - "Define a generic identifier that adjust to the current GNU variant." - ((_ id (gnu/linux => linux) (gnu/hurd => hurd)) - (define-syntax id - (lambda (s) - (syntax-case s () - ((_ args (... ...)) - (if (string-contains (or (target-type) %host-type) - "linux") - #'(linux args (... ...)) - #'(hurd args (... ...)))) - (_ - (if (string-contains (or (target-type) %host-type) - "linux") - #'linux - #'hurd)))))))) - -(define-generic-identifier read-dirent-header - (gnu/linux => read-dirent-header/linux) - (gnu/hurd => read-dirent-header/hurd)) - -(define-generic-identifier %struct-dirent-header - (gnu/linux => %struct-dirent-header/linux) - (gnu/hurd => %struct-dirent-header/hurd)) - -(define-generic-identifier sizeof-dirent-header - (gnu/linux => sizeof-dirent-header/linux) - (gnu/hurd => sizeof-dirent-header/hurd)) - ;; Constants for the 'type' field, from . (define DT_UNKNOWN 0) (define DT_FIFO 1) @@ -960,19 +929,30 @@ system to PUT-OLD." "closedir: ~A" (list (strerror err)) (list err))))))) -(define readdir* +(define (readdir-procedure name-field-offset sizeof-dirent-header + read-dirent-header) (let ((proc (syscall->procedure '* "readdir64" '(*)))) (lambda* (directory #:optional (pointer->string pointer->string/utf-8)) (let ((ptr (proc directory))) (and (not (null-pointer? ptr)) (cons (pointer->string - (make-pointer (+ (pointer-address ptr) - (c-struct-field-offset - %struct-dirent-header name))) + (make-pointer (+ (pointer-address ptr) name-field-offset)) -1) (read-dirent-header (pointer->bytevector ptr sizeof-dirent-header)))))))) +(define readdir* + ;; Decide at run time which one must be used. + (if (string-suffix? "linux-gnu" %host-type) + (readdir-procedure (c-struct-field-offset %struct-dirent-header/linux + name) + sizeof-dirent-header/linux + read-dirent-header/linux) + (readdir-procedure (c-struct-field-offset %struct-dirent-header/hurd + name) + sizeof-dirent-header/hurd + read-dirent-header/hurd))) + (define* (scandir* name #:optional (select? (const #t)) (entry Date: Mon, 20 Apr 2020 16:21:17 +0200 Subject: syscalls: Fix Linux detection in 'readdir*'. * guix/build/syscalls.scm (readdir*): Fix Linux detection for `arm-unknown-linux-gnueabihf'. --- guix/build/syscalls.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix/build') diff --git a/guix/build/syscalls.scm b/guix/build/syscalls.scm index 7ef03417c1..73b439fb7d 100644 --- a/guix/build/syscalls.scm +++ b/guix/build/syscalls.scm @@ -4,6 +4,7 @@ ;;; Copyright © 2015 Mark H Weaver ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2019 Guillaume Le Vaillant +;;; Copyright © 2020 Julien Lepiller ;;; ;;; This file is part of GNU Guix. ;;; @@ -943,7 +944,7 @@ system to PUT-OLD." (define readdir* ;; Decide at run time which one must be used. - (if (string-suffix? "linux-gnu" %host-type) + (if (string-contains %host-type "linux-gnu") (readdir-procedure (c-struct-field-offset %struct-dirent-header/linux name) sizeof-dirent-header/linux -- cgit v1.2.3 From 12da5162e49ea3b0f2e5e46f7aa5e410ebf30845 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Thu, 23 Apr 2020 23:10:19 +0200 Subject: compile: Pre-load the compiler outside 'with-target'. * guix/build/compile.scm (compile-files): Move call to 'compile' before 'with-target'. Failing to do that, if the target has a different word size than the host, the first call to 'compile-file' fails with: ice-9/eval.scm:293:34: In procedure load-thunk-from-memory: ELF file does not have native word size while attempting loading 'language/spec.go'. --- guix/build/compile.scm | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'guix/build') diff --git a/guix/build/compile.scm b/guix/build/compile.scm index 3ce0ecede5..c4dbb6e34c 100644 --- a/guix/build/compile.scm +++ b/guix/build/compile.scm @@ -194,6 +194,11 @@ files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"." (with-augmented-search-path %load-path source-directory (with-augmented-search-path %load-compiled-path build-directory (with-fluids ((*current-warning-prefix* "")) + ;; Make sure the compiler's modules are loaded before 'with-target' + ;; (since 'with-target' influences the .go loader), and before + ;; starting to compile files in parallel. + (compile #f) + (with-target host (lambda () ;; FIXME: To work around , we first @@ -202,10 +207,6 @@ files are for HOST, a GNU triplet such as \"x86_64-linux-gnu\"." #:report-load report-load #:debug-port debug-port) - ;; Make sure compilation related modules are loaded before - ;; starting to compile files in parallel. - (compile #f) - ;; XXX: Don't use too many workers to work around the insane ;; memory requirements of the compiler in Guile 2.2.2: ;; . -- cgit v1.2.3