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

From: [email-masked]
Date: Sun, 10 Mar 2013 19:54:22 +0100

On 10.03.2013, at 18:32, Andy Wingo <[email-masked]> wrote:

> Hi :)
> 
> On Sun 10 Mar 2013 05:09, [email-masked] writes:
> 
>> The struct timespec is still an issue in a mingw build on windows, but
>> I know how to handle it.
> 
> How do you handle it, for the record?

by adding 

#ifndef _TIMESPEC_DEFINED
struct timespec {
        time_t tv_sec;
        long tv_nsec;
};
#endif

to lib/stat-time.h and libguile/threads.c.  Don't particularly like it, but that's what works. If you don't wanna make that part of the main source tree, I got no problem making a patch part of my build process. I gotta do some patching anyway to be able to have relative/runtime initialized load paths on windows.

> 
> I assume you are using pthreads-w32?

/* This is an implementation of the threads API of POSIX 1003.1-2001.
 *
 * --------------------------------------------------------------------------
 *
 *      Pthreads-win32 - POSIX Threads Library for Win32
 *      Copyright(C) 1998 John E. Bossom
 *      Copyright(C) 1999,2005 Pthreads-win32 contributors
 *
 *      Contact Email: [email-masked]

That's what the pthread.h says.

> 
>> As I said, I build everything on windows.
>> 
>> I have to build bdw-gc with --enable-threads=posix. If I don't, I get errors along this line:
>> 
>> ./.libs/libguile-2.0.a(libguile_2.0_la-threads.o):threads.c:(.text+0xfb8): undefined reference to `GC_pthread_detach'
>> ./.libs/libguile-2.0.a(libguile_2.0_la-threads.o):threads.c:(.text+0x10de): undefined reference to `GC_pthread_create'
>> ./.libs/libguile-2.0.a(libguile_2.0_la-threads.o):threads.c:(.text+0x1221): undefined reference to `GC_pthread_detach'
>> ./.libs/libguile-2.0.a(libguile_2.0_la-threads.o):threads.c:(.text+0x12d1): undefined reference to `GC_pthread_create'
> 
> You can build bdw-gc without threads, and then build Guile without
> threads.  In my builds I was doing --enable-threads=posix.
> 
>> The problem is, when I do build bdw-gc with posix threads, the guile
>> module compiling is all broken, it periodically drops messages like
>> this:
>> 
>>  GUILEC ice-9/eval.go
>> Backtrace:
>> In unknown file:
>>   ?: 3 [apply-smob/1 #<boot-closure 192c100 (_ _ _)> #t ...]
>>   ?: 2 [apply-smob/1 #<catch-closure 1ccee70>]
>>   ?: 1 [primitive-eval ((@ # %) (begin # # #))]
>>   ?: 0 [chmod #<closed: file 0> 438]
> 
> You passed the `GEN guile-procedures.texi' phase?  If so, things are
> already going well.  That's the first time the newly built Guile is
> used, and if it went through it means at least you have a functional
> Guile.
> 
> This problem sounds similar to something Eli Zaretskii reported:
> http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10474#14:
> 
>   The next problem is here:
> 
>          GUILEC ice-9/eval.go
>        Backtrace:
>        In unknown file:
>   	?: 5 [boot-closure #t #<catch-closure 231fd40> ...]
>   	?: 4 [catch-closure]
>   	?: 3 [primitive-eval ((@ # %) (begin # # #))]
>   	?: 2 [chmod #<input-output: ice-9/eval.go.9IiPxC 6> 438]
>   	?: 1 [boot-closure system-error "chmod" ...]
>   	?: 0 [delete-file "ice-9/eval.go.9IiPxC"]
> 
>        ERROR: In procedure delete-file:
>        ERROR: In procedure delete-file: Permission denied
> 
>   This happens because Guile calls fchmod, which is #define'd to -1 on
>   MinGW.
> 
> However the code is different now, than it was when Eli made his report;
> now if you don't have fchmod (as mingw does not), chmod only accepts
> strings -- and here it seems that we are trying to chmod a port.  I will
> see what I can do here.

Sounds promising!

Regards

Jan Schukat

P.S. I guess I append some more info, namely my configure command line, and the most interesting build output section (after that its mostly backtraces from guile compiling):

./configure --prefix=/c/Users/shookie/guiletest/lib --disable-shared --disable-fast-install --with-gnu-ld  --disable-deprecated --enable-nls --with-libgmp-prefix=/c/Users/shookie/guiletest/lib  LIBFFI_CFLAGS='-I/c/Use
rs/shookie/guiletest/lib/lib/libffi-3.0.12/include' LIBFFI_LIBS='-lffi' BDW_GC_LIBS='-lgc' BDW_GC_CFLAGS='-I/c/Users/shookie/guiletest/lib' CPPFLAGS='-D HAVE_GC_SET_FINALIZER_NOTIFIER -D HAVE_GC_GET_FREE_SPACE_DIVISOR -D HAVE_GC_GET_HEAP
_USAGE_SAFE -D HAVE_GC_SET_FINALIZE_ON_DEMAND' CFLAGS='-s' && make install

….

  CC       libguile_2.0_la-threads.lo
threads.c: In function 'scm_pthread_cond_timedwait':
threads.c:2006:3: warning: passing argument 3 of 'pthread_cond_timedwait' from incompatible pointer type [enabled by default]
In file included from ../lib/time.h:369:0,
                 from c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/sys/time.h:3,
                 from ../lib/sys/time.h:30,
                 from ../libguile/scmconfig.h:26,
                 from ../libguile/bdw-gc.h:24,
                 from threads.c:27:
c:\mingw\bin\../lib/gcc/mingw32/4.7.2/../../../../include/pthread.h:1097:31: note: expected 'const struct timespec *' but argument is of type 'const struct scm_t_timespec *'
  CC       libguile_2.0_la-throw.lo
  CC       libguile_2.0_la-trees.lo
  CC       libguile_2.0_la-uniform.lo
  CC       libguile_2.0_la-values.lo
  CC       libguile_2.0_la-variable.lo
  CC       libguile_2.0_la-vectors.lo
  CC       libguile_2.0_la-version.lo
  CC       libguile_2.0_la-vm.lo
  CC       libguile_2.0_la-vports.lo
  CC       libguile_2.0_la-weaks.lo
  CCLD     libguile-2.0.la
libtool: link: warning: library `c:/mingw/lib/libunistring.la' was moved.
copying selected object files to avoid basename conflicts...
  CC       guile-guile.o
  CCLD     guile.exe
libtool: link: warning: library `c:/mingw/lib/libunistring.la' was moved.
  GEN      guile-procedures.texi
rm -f guile-procedures.txt
makeinfo --force -o guile-procedures.txt guile-procedures.texi || test -f guile-procedures.txt
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:10246: Cross reference to nonexistent node `Backslash Escapes' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:9941: Cross reference to nonexistent node `Network Address Conversion' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:9880: Cross reference to nonexistent node `Network Databases' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:9830: Cross reference to nonexistent node `Network Databases' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:9304: Cross reference to nonexistent node `Hash Tables' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:9297: Cross reference to nonexistent node `Hash Tables' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:9290: Cross reference to nonexistent node `Hash Tables' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:9204: Cross reference to nonexistent node `File Ports' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:8569: Cross reference to nonexistent node `Vtables' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:8187: Cross reference to nonexistent node `Locales' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:8006: Cross reference to nonexistent node `Bitwise Operations' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:6697: Cross reference to nonexistent node `Character Sets' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:6675: Cross reference to nonexistent node `Character Sets' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:6619: Cross reference to nonexistent node `Multiple Values' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:5563: Cross reference to nonexistent node `File Ports' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:5272: Cross reference to nonexistent node `Ports and File Descriptors' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:5261: Cross reference to nonexistent node `Ports and File Descriptors' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:5250: Cross reference to nonexistent node `Ports and File Descriptors' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:3319: Cross reference to nonexistent node `File Ports' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:3126: Cross reference to nonexistent node `Locales' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:2797: Cross reference to nonexistent node `Hash Tables' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:2790: Cross reference to nonexistent node `Hash Tables' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:2783: Cross reference to nonexistent node `Hash Tables' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:2213: Cross reference to nonexistent node `Character Encoding of Source Files' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:2207: Cross reference to nonexistent node `Ports and File Descriptors' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:2189: Cross reference to nonexistent node `Ports and File Descriptors' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:1575: Cross reference to nonexistent node `Ports and File Descriptors' (perhaps incorrect sectioning?).
/c/Users/shookie/guiletest/lib/guile-2.0/libguile//guile-procedures.texi:1563: Cross reference to nonexistent node `Closing' (perhaps incorrect sectioning?).
make[5]: Entering directory `/c/Users/shookie/guiletest/lib/guile-2.0/libguile'
 /bin/mkdir -p '/c/Users/user/guiletest/lib/lib'