From e1f761e9969a39190177fda48d60f42d63423ab7 Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Thu, 13 Feb 2020 08:30:13 +0100 Subject: [PATCH] gnu: Use guile-2.0 for make-bootstrap. * gnu/packages/make-bootstrap.scm (%guile-static): Inherit from guile-2.0. [source]: Update patch set. (%guile-static-stripped): Adjust for guile-2.0. * gnu/packages/patches/guile-2.0-relocatable.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. --- gnu/local.mk | 1 + gnu/packages/make-bootstrap.scm | 30 ++++---- .../patches/guile-2.0-relocatable.patch | 68 +++++++++++++++++++ 3 files changed, 84 insertions(+), 15 deletions(-) create mode 100644 gnu/packages/patches/guile-2.0-relocatable.patch diff --git a/gnu/local.mk b/gnu/local.mk index 3f8fa2ed7b..2cd799dca4 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -980,6 +980,7 @@ dist_patch_DATA = \ %D%/packages/patches/guile-finalization-crash.patch \ %D%/packages/patches/guile-linux-syscalls.patch \ %D%/packages/patches/guile-present-coding.patch \ + %D%/packages/patches/guile-2.0-relocatable.patch \ %D%/packages/patches/guile-relocatable.patch \ %D%/packages/patches/guile-rsvg-pkgconfig.patch \ %D%/packages/patches/guile-emacs-fix-configure.patch \ diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm index b8d1b2af3e..2c08e31a97 100644 --- a/gnu/packages/make-bootstrap.scm +++ b/gnu/packages/make-bootstrap.scm @@ -699,14 +699,14 @@ for `sh' in $PATH, and without nscd, and with static NSS modules." ;; A statically-linked Guile that is relocatable--i.e., it can search ;; .scm and .go files relative to its installation directory, rather ;; than in hard-coded configure-time paths. - (let* ((patches (cons* (search-patch "guile-relocatable.patch") - (search-patch "guile-2.2-default-utf8.patch") + (let* ((patches (cons* (search-patch "guile-2.0-relocatable.patch") + (search-patch "guile-default-utf8.patch") (search-patch "guile-linux-syscalls.patch") - (origin-patches (package-source guile-2.2)))) - (source (origin (inherit (package-source guile-2.2)) + (origin-patches (package-source guile-2.0)))) + (source (origin (inherit (package-source guile-2.0)) (patches patches))) - (guile (package (inherit guile-2.2) - (name (string-append (package-name guile-2.2) "-static")) + (guile (package (inherit guile-2.0) + (name (string-append (package-name guile-2.0) "-static")) (source source) (synopsis "Statically-linked and relocatable Guile") @@ -715,14 +715,14 @@ for `sh' in $PATH, and without nscd, and with static NSS modules." (inputs `(("libunistring:static" ,libunistring "static") - ,@(package-inputs guile-2.2))) + ,@(package-inputs guile-2.0))) (propagated-inputs `(("bdw-gc" ,libgc) ,@(alist-delete "bdw-gc" - (package-propagated-inputs guile-2.2)))) + (package-propagated-inputs guile-2.0)))) (arguments - (substitute-keyword-arguments (package-arguments guile-2.2) + (substitute-keyword-arguments (package-arguments guile-2.0) ((#:configure-flags flags '()) ;; When `configure' checks for ltdl availability, it ;; doesn't try to link using libtool, and thus fails @@ -777,13 +777,13 @@ for `sh' in $PATH, and without nscd, and with static NSS modules." (out (assoc-ref %outputs "out")) (guile1 (string-append in "/bin/guile")) (guile2 (string-append out "/bin/guile"))) - (mkdir-p (string-append out "/share/guile/2.2")) - (copy-recursively (string-append in "/share/guile/2.2") - (string-append out "/share/guile/2.2")) + (mkdir-p (string-append out "/share/guile/2.0")) + (copy-recursively (string-append in "/share/guile/2.0") + (string-append out "/share/guile/2.0")) - (mkdir-p (string-append out "/lib/guile/2.2/ccache")) - (copy-recursively (string-append in "/lib/guile/2.2/ccache") - (string-append out "/lib/guile/2.2/ccache")) + (mkdir-p (string-append out "/lib/guile/2.0/ccache")) + (copy-recursively (string-append in "/lib/guile/2.0/ccache") + (string-append out "/lib/guile/2.0/ccache")) (mkdir (string-append out "/bin")) (copy-file guile1 guile2) diff --git a/gnu/packages/patches/guile-2.0-relocatable.patch b/gnu/packages/patches/guile-2.0-relocatable.patch new file mode 100644 index 0000000000..95bddcce88 --- /dev/null +++ b/gnu/packages/patches/guile-2.0-relocatable.patch @@ -0,0 +1,68 @@ +This patch changes Guile to use a default search path relative to the +location of the `guile' binary, allowing it to be relocated. + +--- a/libguile/load.c ++++ b/libguile/load.c +@@ -26,6 +26,7 @@ + + #include + #include ++#include + + #include "libguile/_scm.h" + #include "libguile/alist.h" +@@ -325,6 +326,32 @@ + SCM cpath = SCM_EOL; + + #ifdef SCM_LIBRARY_DIR ++ char *program, *bin_dir, *prefix, *module_dir, *ccache_dir; ++ ++ /* Determine the source and compiled module directories at run-time, ++ relative to the executable's location. ++ ++ Note: Use /proc/self/exe instead of argv[0] because the latter is ++ not necessarily an absolute, nor a valid file name. */ ++ ++ program = scm_gc_malloc_pointerless (256, "string"); ++ readlink ("/proc/self/exe", program, 256); ++ ++ bin_dir = dirname (strdupa (program)); ++ ++ prefix = scm_gc_malloc_pointerless (strlen (bin_dir) + 4, "string"); ++ strcpy (prefix, bin_dir); ++ strcat (prefix, "/.."); ++ prefix = canonicalize_file_name (prefix); ++ ++ module_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string"); ++ strcpy (module_dir, prefix); ++ strcat (module_dir, "/share/guile/" SCM_EFFECTIVE_VERSION); ++ ++ ccache_dir = scm_gc_malloc_pointerless (strlen (prefix) + 50, "string"); ++ strcpy (ccache_dir, prefix); ++ strcat (ccache_dir, "/lib/guile/" SCM_EFFECTIVE_VERSION "/ccache"); ++ + env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_PATH")); + if (env && strcmp (env, "") == 0) + /* special-case interpret system-path=="" as meaning no system path instead +@@ -333,10 +360,7 @@ + else if (env) + path = scm_parse_path (scm_from_locale_string (env), path); + else +- path = scm_list_4 (scm_from_locale_string (SCM_LIBRARY_DIR), +- scm_from_locale_string (SCM_SITE_DIR), +- scm_from_locale_string (SCM_GLOBAL_SITE_DIR), +- scm_from_locale_string (SCM_PKGDATA_DIR)); ++ path = scm_list_1 (scm_from_locale_string (module_dir)); + + env = scm_i_mirror_backslashes (getenv ("GUILE_SYSTEM_COMPILED_PATH")); + if (env && strcmp (env, "") == 0) +@@ -346,8 +370,7 @@ + cpath = scm_parse_path (scm_from_locale_string (env), cpath); + else + { +- cpath = scm_list_2 (scm_from_locale_string (SCM_CCACHE_DIR), +- scm_from_locale_string (SCM_SITE_CCACHE_DIR)); ++ cpath = scm_list_1 (scm_from_locale_string (ccache_dir)); + } + + #endif /* SCM_LIBRARY_DIR */ -- 2.25.0