Skip to content

windows: cross-compilation: file-not-found

Apparently ECL exports symbol GC_CreateThread (I think we supported Windows with threads before bdwgc implemented that), which is already exported by bdwgc, what signals an error about conflicting types for this define.

$ ./configure --host=i686-w64-mingw32
$ make
[...]
i686-w64-mingw32-gcc -DECLDIR="\"/usr/local/lib/ecl-16.1.2\"" -I.
-I/tmp/ecl/build -I/tmp/ecl/src/c -I../ecl/gc -DECL_API -DECL_NO_LEGACY
   -g -O2 -D_THREAD_SAFE -Dmingw32 -c -o threads/process.o
threads/process.o.c
/tmp/ecl/src/c/threads/process.d:40:22: error: conflicting types for
'GC_CreateThread'
 extern HANDLE WINAPI GC_CreateThread(
                      ^
In file included from /tmp/ecl/build/ecl/config.h:84:0,
                 from /tmp/ecl/build/ecl/ecl.h:37,
                 from /tmp/ecl/src/c/threads/process.d:20:
/tmp/ecl/build/ecl/gc/gc.h:1536:26: note: previous declaration of
'GC_CreateThread' was here
     GC_API HANDLE WINAPI GC_CreateThread(
                          ^
/tmp/ecl/src/c/threads/process.d: In function 'mp_exit_process':
/tmp/ecl/src/c/threads/process.d:604:1: warning: 'noreturn' function
does return
Makefile:85: recipe for target 'threads/process.o' failed
make[2]: *** [threads/process.o] Error 1
make[2]: Leaving directory '/tmp/ecl/build/c'
Makefile:120: recipe for target 'libeclmin.a' failed
make[1]: *** [libeclmin.a] Error 2
make[1]: Leaving directory '/tmp/ecl/build'
Makefile:70: recipe for target 'all' failed
make: *** [all] Error 2

I suspect that removing our own define should solve the problem.

diff --git a/src/c/threads/process.d b/src/c/threads/process.d
index 19e98e3..944bd16 100755
--- a/src/c/threads/process.d
+++ b/src/c/threads/process.d
@@ -31,16 +31,6 @@
 #include "threads/ecl_atomics.h"

 #ifdef ECL_WINDOWS_THREADS
-/*
- * We have to put this explicit definition here because Boehm GC
- * is designed to produce a DLL and we rather want a static
- * reference
- */
-# include <gc.h>
-extern HANDLE WINAPI GC_CreateThread(
-                                     LPSECURITY_ATTRIBUTES lpThreadAttributes,
-                                     DWORD dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress,
-                                     LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId );
 # ifndef WITH___THREAD
 DWORD cl_env_key;
 # endif

Some notes from the source code (in ECL):

/*
 * We have to put this explicit definition here because Boehm GC
 * is designed to produce a DLL and we rather want a static
 * reference
 */

We have to verify, if this comment is still up-to-date, or if we can safely get rid of the mentioned code block. The first step is to check, if the cross-compilation for windows works now.

Reported by Wolfgang Dautermann.