Subject: bug#13848: Statically linking guile-2.0.

From: Jan Schukat <[email-masked]>
Date: Tue, 05 Mar 2013 01:54:12 +0100

Ok, I did some more work on the linux and mingw side. My little test 
project now compiles and works under linux, provided in gc.c I remove 
the static qualifiers from GC_set_finalize_on_demand, 
GC_get_heap_usage_safe, GC_get_free_space_divisor and 
GC_set_finalizer_notifier. That still gave a warning at linking time, 
but any combination of preprocessor guards caused either compile errors 
or link errors.

Also, when building guile-2.9 with --disable-posix, there comes a 
lisp-compile error when the standard modules are made:

   GUILEC ice-9/popen.go
Backtrace:
In ice-9/eval.scm:
  376: 19 [eval # #]
In srfi/srfi-1.scm:
  619: 18 [for-each #<procedure a389618 at ice-9/eval.scm:405:20 (a)> #]
In ice-9/eval.scm:
  376: 17 [eval # #]
  470: 16 [lp (#<fluid 23>) ("")]
In system/base/target.scm:
   59: 15 [with-target "i686-pc-linux-gnu" ...]
In system/base/compile.scm:
  147: 14 [compile-file "ice-9/popen.scm" #:output-file ...]
   43: 13 [call-once #<procedure a434b40 at system/base/compile.scm:56:5 
()>]
In ice-9/boot-9.scm:
  171: 12 [with-throw-handler #t ...]
In system/base/compile.scm:
   59: 11 [#<procedure a434b20 at system/base/compile.scm:58:9 ()>]
  150: 10 [#<procedure a434b60 at system/base/compile.scm:148:8 (port)> 
#<input-output: ice-9/popen.go.HBtyxJ 6>]
  199: 9 [read-and-compile #<input: ice-9/popen.scm 5> #:from ...]
  211: 8 [lp (#<tree-il (let # # ...)>) #<directory (ice-9 popen) 
a4f2a68> ...]
  177: 7 [lp (#<procedure compile-tree-il (x e opts)>) (eval-when # #) ...]
In ice-9/boot-9.scm:
2131: 6 [save-module-excursion #<procedure a50b9f0 at 
language/scheme/compile-tree-il.scm:29:3 ()>]
In language/scheme/compile-tree-il.scm:
   31: 5 [#<procedure a50b9f0 at 
language/scheme/compile-tree-il.scm:29:3 ()>]
In ice-9/psyntax.scm:
1091: 4 [expand-top-sequence ((eval-when # #)) () ((top)) ...]
  976: 3 [scan ((eval-when # #)) () ((top)) ...]
  270: 2 [scan ((load-extension # "scm_init_popen")) () ((top)) ...]
In unknown file:
    ?: 1 [load-extension "libguile-2.0" "scm_init_popen"]
In ice-9/boot-9.scm:
  106: 0 [#<procedure a434b00 at ice-9/boot-9.scm:97:6 (thrown-k . 
args)> misc-error ...]

ice-9/boot-9.scm:106:20: In procedure #<procedure a434b00 at 
ice-9/boot-9.scm:97:6 (thrown-k . args)>:
ice-9/boot-9.scm:106:20: In procedure dynamic-pointer: Symbol not found: 
scm_init_popen
make[3]: *** [ice-9/popen.go] Error 1
make[3]: Leaving directory `/home/shookie/guiletest/lib/guile-2.0/module'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/home/shookie/guiletest/lib/guile-2.0'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/home/shookie/guiletest/lib/guile-2.0'
make: *** [lib/lib/libguile-2.0.a] Error 2

When I leave out that option it (the test project) builds and runs fine 
on linux now though.

On mingw, I still have to define the struct timespec:

diff --recursive guile-2.0/lib/stat-time.h guile-2.0.7/lib/stat-time.h
26,32d25
< #ifndef _TIMESPEC_DEFINED
< struct timespec {
<         time_t tv_sec;
<         long tv_nsec;
< };
< #endif
<
diff --recursive guile-2.0/libguile/random.c guile-2.0.7/libguile/random.c
668c668
<      scm_from_ulong(getpid()),         /* process ID */
---
 >      scm_getpid (),         /* process ID */
diff --recursive guile-2.0/libguile/threads.c guile-2.0.7/libguile/threads.c
70,75d69
< #ifndef _TIMESPEC_DEFINED
< struct timespec {
<         time_t tv_sec;
<         long tv_nsec;
< };
< #endif

With that it builds.

When I run it with --program-suffix=.exe it also copies guild.exe 
(without it fails while trying), but then fails when it tries to run it 
without the suffix.

So I run it again without the --program-suffix, and since the files are 
copied in the previous build it starts them, but then they fail like this:

  but then fails installing the lisp modules:

   GEN      guile-procedures.texi
Throw without catch before boot:
Throw to key system-error with args ("canonicalize-path" "~A" ("No such 
file or directory") (2))Aborting.

This application has requested the Runtime to terminate it in an unusual 
way.
Please contact the application's support team for more information.
make[4]: *** [guile-procedures.texi] Error 1
make[4]: Leaving directory 
`/c/Users/shookie/guiletest/lib/guile-2.0/libguile'
make[3]: *** [install] Error 2
make[3]: Leaving directory 
`/c/Users/shookie/guiletest/lib/guile-2.0/libguile'
make[2]: *** [install-recursive] Error 1
make[2]: Leaving directory `/c/Users/shookie/guiletest/lib/guile-2.0'
make[1]: *** [install] Error 2
make[1]: Leaving directory `/c/Users/shookie/guiletest/lib/guile-2.0'
make: *** [lib/lib/libguile-2.0.a] Error 2

I attached the new updated test-project tgz.

In summary, I still think on mingw the configure script gets very 
confused about paths and file names.

Regards

Jan Schukat

On 03/02/2013 04:28 PM, Ludovic Courtès wrote:
> Hello,
>
> Thanks for the report.
>
> Jan Schukat<[email-masked]>  skribis:
>
>> But then on install (processing .texi files) guile.exe fails with this
>> message:
>>
>> "Throw without catch before boot:
>> Throw to key system-error with args ("canonicalize-path" "~A" ("No
>> such file or directory") (2))Aborting.
> [...]
>
>> Calling guile.exe directly gives this message:
>>
>> "Throw without catch before boot:
>> Throw to key misc-error with args ("primitive-load-path" "Unable to
>> find file ~S in load path" ("ice-9/boot-9") #f)Aborting.
> Does it happen when running the installed Guile?  That is, you
> successfully run ‘make’ and ‘make install’ (and ideally ‘make check’),
> and it’s the installed ‘guile’ binary that produces this message?
>
> As most Unix and GNU packages, Guile expects to be installed in the
> place specified by --prefix.  If you install it elsewhere, it will fail
> to find its companion files, such as ice-9/boot-9.scm.  So you really
> must install it in --prefix, and leave it there.  Is it what you did?
>
> (Note that this restriction can be worked around by techniques such as
> found in
> <http://git.savannah.gnu.org/cgit/guix.git/tree/gnu/packages/patches/guile-relocatable.patch>.)
>
> Thanks,
> Ludo’.