unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH
@ 2016-03-04 13:13 Jan Nieuwenhuizen
  2016-03-11 18:14 ` [PATCH] Skip invalid compiled file found, continue searching path Jan Nieuwenhuizen
  2016-03-16 14:19 ` [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH Mikael Djurfeldt
  0 siblings, 2 replies; 12+ messages in thread
From: Jan Nieuwenhuizen @ 2016-03-04 13:13 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 3117 bytes --]

Hi,

I am running guile-2.0 and guile-2.2 alongside each other which is
causing me some pain*).

This is what bits of my GUILE_LOAD_COMPILED_PATH look like

    /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/lib/guile/2.2/ccache
    --> /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/lib/guile/2.2/ccache/ice-9/and-let-star.go

    /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.2/
    --> /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.2/os/process.go

If `/<effective-version>' is always used as the suffix of each path
element, and we/guix/packagers do not include that suffix in GUILE_*PATH
elements, then Guile can append effective-prefix and different major
Guile-versions can happily share the same GUILE_LOAD[_COMPILED]_PATH,
e.g., having

    GUILE_LOAD_COMPILED_PATH=/gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site

then guile-2.0 would get (os process) from

    /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site + /2.0
    --> /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.0/os/process.go

and guile-2.2 would read

    /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site + /2.2
    --> /gnu/store/7ml4psifv46pzxjxw56xfl7mwd47k277-profile/share/guile/site/2.2/os/process.go
    
What do you think?  No more pain!  Find patch attached.

Greetings,
Jan


*) Some of my pain

My Debian host system has guile-2.0, guix depends on guile-2.0, guix's
LD script depends on guile-2.0, the guile bits of my project depend on
guile-2.2.

I have some scripts to make this situation almost bearable, but still I
regularly

cannot find a basic library

    [1]13:53:25 janneke@janneke-ijzer:~
    $ guile --no-auto-compile
    GNU Guile 2.0.11
    Copyright (C) 1995-2014 Free Software Foundation, Inc.

    Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
    This program is free software, and you are welcome to redistribute it
    under certain conditions; type `,show c' for details.

    Enter `,help' for help.
    scheme@(guile-user)> (use-modules (os proccess))
    While compiling expression:
    ERROR: no code for module (os proccess)

or some guile script (guix) aborts

    guix environment --ad-hoc ccache coreutils git guix emacs guile-next guile-next-lib
    Throw without catch before boot:
    Throw to key misc-error with args ("make_objcode_from_file" "bad header on object file: ~s" ("\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00") #f)Aborting.
    Aborted

or linking breaks

    g++ -Wall -std=c++11  -g -I. -I out/alarm.project/c++ -I check/alarm.project/   out/alarm.project/c++/main.o out/alarm.project/c++/Alarm.o out/alarm.project/c++/AlarmSystem.o out/alarm.project/c++/pump.o out/alarm.project/c++/runtime.o    -lboost_system -lboost_coroutine -lboost_thread -lboost_context -pthread -o out/alarm.project/c++/test
    collect2: error: ld terminated with signal 6 [Afgebroken]
    Throw without catch before boot:
    Aborting.

and then I juggle installed guile versions and/or manually modify
GUILE_LOAD_COMPILED_PATH.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Append-effective-version-to-GUILE_LOAD-_COMPILED-_PA.patch --]
[-- Type: text/x-diff, Size: 3192 bytes --]

From 81c8b35752235aeb26058c0baadd0ea58046f640 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Thu, 3 Mar 2016 18:18:55 +0100
Subject: [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH
 elements.

* libguile/load.c (scm_path_append_effective_version): New function
  (scm_init_load_path): Use it.

* am/guilec (moddir,ccachedir): Use GUILE_EFFECTIVE_VERSION as prefix.
---
 am/guilec       |  4 ++--
 libguile/load.c | 27 ++++++++++++++++++++++++++-
 2 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/am/guilec b/am/guilec
index 5ef07fa..fa2b5ba 100644
--- a/am/guilec
+++ b/am/guilec
@@ -3,9 +3,9 @@ GOBJECTS = $(SOURCES:%.scm=%.go) $(ELISP_SOURCES:%.el=%.go)
 
 GUILE_WARNINGS = -Wunbound-variable -Warity-mismatch -Wformat
 
-moddir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)/$(modpath)
+moddir = $(pkgdatadir)/$(modpath)/$(GUILE_EFFECTIVE_VERSION)
 nobase_mod_DATA = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
-ccachedir = $(pkglibdir)/$(GUILE_EFFECTIVE_VERSION)/ccache/$(modpath)
+ccachedir = $(pkglibdir)/ccache/$(GUILE_EFFECTIVE_VERSION)/$(modpath)
 nobase_ccache_DATA = $(GOBJECTS)
 EXTRA_DIST = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
 ETAGS_ARGS = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
diff --git a/libguile/load.c b/libguile/load.c
index d26f9fc..055f3c4 100644
--- a/libguile/load.c
+++ b/libguile/load.c
@@ -1,5 +1,6 @@
 /* Copyright (C) 1995, 1996, 1998, 1999, 2000, 2001, 2004, 2006, 2008,
- *   2009, 2010, 2011, 2012, 2013, 2014 Free Software Foundation, Inc.
+ *   2009, 2010, 2011, 2012, 2013, 2014, 2016 Free Software Foundation,
+ *   Inc.
  * 
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public License
@@ -312,6 +313,28 @@ scm_i_mirror_backslashes (char *path)
   return path;
 }
 
+/* Append effective_version to each element in PATH.  This allows using
+   one single heterogeneous path for different effective versions of
+   Guile, i.e., running different versions of guile alongside each other
+   from one shell, without juggling GUILE_LOAD_COMPILED_PATH.  */
+static SCM
+scm_path_append_effective_version (SCM path)
+{
+  SCM vpath = SCM_EOL;
+  SCM version = scm_effective_version ();
+  SCM slash = scm_from_utf8_string ("/");
+  for (path = scm_reverse (path); scm_is_pair (path);
+       path = SCM_CDR (path))
+    {
+      SCM dir = SCM_CAR (path);
+      SCM vdir = scm_string_append (scm_list_3 (dir, slash, version));
+      /* keep non-M.M suffixed dir as fallback for compatibility.  */
+      vpath = scm_cons (dir, vpath);
+      vpath = scm_cons (vdir, vpath);
+    }
+  return vpath;
+}
+
 /* Initialize the global variable %load-path, given the value of the
    SCM_SITE_DIR and SCM_LIBRARY_DIR preprocessor symbols and the
    GUILE_LOAD_PATH environment variable.  */
@@ -393,7 +416,9 @@ scm_init_load_path ()
   if (env)
     cpath = scm_parse_path_with_ellipsis (scm_from_locale_string (env), cpath);
 
+  path = scm_path_append_effective_version (path);
   *scm_loc_load_path = path;
+  cpath = scm_path_append_effective_version (cpath);
   *scm_loc_load_compiled_path = cpath;
 }
 
-- 
2.6.3


[-- Attachment #3: Type: text/plain, Size: 154 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2016-03-19 21:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-03-04 13:13 [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH Jan Nieuwenhuizen
2016-03-11 18:14 ` [PATCH] Skip invalid compiled file found, continue searching path Jan Nieuwenhuizen
2016-03-11 22:02   ` David Kastrup
2016-03-13 10:15     ` Jan Nieuwenhuizen
2016-03-13 11:05       ` David Kastrup
2016-03-13 11:10         ` David Kastrup
2016-03-13 10:03   ` [PATCH v3] " Jan Nieuwenhuizen
2016-03-13 10:19     ` Jan Nieuwenhuizen
2016-03-14 16:10       ` [PATCH v4] " Jan Nieuwenhuizen
2016-03-16 14:19 ` [PATCH] Append effective version to GUILE_LOAD[_COMPILED]_PATH Mikael Djurfeldt
2016-03-19  9:26   ` Jan Nieuwenhuizen
2016-03-19 21:09     ` Ludovic Courtès

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).