linux-gnu to mingw32 cross

Martin Aliger martin_aliger@email.cz
Tue Nov 26 17:32:00 GMT 2002


Hi all,

I after all made gcj linux->ming cross-compiler. I summarize my feeling there. As well a little HOWTO is attached.

Main magic was using two configure options:
--enable-libgcj 
--enable=threads=win32

Is there any problem to enable theese as default? Compile gcj without library is not very useful. And not including thread option results in compile error in many places (boehm_gc and awt as examples)

As well this process could be a little better documented


Bugs in sources:

First: gcc3.2 sources does NOT compile libjava due to error in java/net native classes (not defined IP_BROADCAST_*)

Second: gcc3.2 2002/11/18 snapshot has completely reworked java/net (through java/nio) and it works but it does not compile other packages (awt+swing+xlib , accessibility, ...), use unknown gcc option -fswitch-enum, ... 



> Martin> and I must delete boehm-gc directory and hand-edit
> Martin> libjava/Makefile to skip java.awt.*, javax.* and some xlib
> Martin> stuff
> 
> Why do you need to skip these?
> The java.awt.* and javax.* files should be ok.
> The xlib files shouldn't be built by default.

Theese brokes build when wrong thread support is choosen (no --enable-threads=win32). Awt+swing was as well broken in snapshot I used

> Martin> include/java-threads.h: In function `int _Jv_CondWait(_Jv_ConditionVariable_t*, 
> Martin>    _Jv_Mutex_t*, __java_long, __java_int)':
> Martin> include/java-threads.h:53: `sleep' undeclared (first use this function)
> Martin> include/java-threads.h:53: (Each undeclared identifier is reported only once 
> Martin>    for each function it appears in.)
> 
> That looks like a bug of some kind.

Yes. Thread support (no --enable-threads=win32).
I dont underestand, why this option help compile it. I look pretty deep into sources and it looks ok. Conditional compiling is real magic!

> Martin> In file included from /home/alik/java/crossgcc-src/libjava/prims.cc:46:
> Martin> java/lang/Thread.h: At global scope:
> Martin> java/lang/Thread.h:80: declaration does not declare anything
> Martin> java/lang/Thread.h:80: storage class specified for typename
> Martin> java/lang/Thread.h:80: parse error before numeric constant
> Martin> java/lang/Thread.h:81: declaration does not declare anything
> Martin> java/lang/Thread.h:81: storage class specified for typename
> Martin> java/lang/Thread.h:81: parse error before numeric constant
> 
> This shouldn't happen.
> Could you clip and send this part of Thread.h?

I could, of course. I think is not needed now (I do not wanna waste your time!)
BTW: Exactly this error helps me to find there is something broken in thread support...


Thanks all for your time
Martin




PS:

There is error it throws when compiling without --enable-threads:
boehm-gc build fails:
...
/home/alik/java/crossgcc-obj/gcc/xgcc -B/home/alik/java/crossgcc-obj/gcc/ -B/home/alik/java/crossgcc-install/i386-pc-mingw32/bin/ -B/home/alik/java/crossgcc-install/i386-pc-mingw32/lib/ -isystem /home/alik/java/crossgcc-install/i386-pc-mingw32/include -DSILENT=1 -DNO_SIGNALS=1 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 -DJAVA_FINALIZATION=1 -DGC_GCJ_SUPPORT=1 -DATOMIC_UNCOLLECTABLE=1 -DNO_SIGSET=1 -DNO_DEBUGGING=1 -I. -I/home/alik/java/crossgcc-src/boehm-gc -I/home/alik/java/crossgcc-src/boehm-gc/include -I././targ-include -I/home/alik/java/crossgcc-src/boehm-gc/./libc/include -g -O2 -c /home/alik/java/crossgcc-src/boehm-gc/mark_rts.c -o mark_rts.o
/home/alik/java/crossgcc-src/boehm-gc/mark_rts.c: In function `GC_approx_sp':
/home/alik/java/crossgcc-src/boehm-gc/mark_rts.c:337: warning: function returns address of local variable
/bin/sh ./libtool --mode=compile /home/alik/java/crossgcc-obj/gcc/xgcc -B/home/alik/java/crossgcc-obj/gcc/ -B/home/alik/java/crossgcc-install/i386-pc-mingw32/bin/ -B/home/alik/java/crossgcc-install/i386-pc-mingw32/lib/ -isystem /home/alik/java/crossgcc-install/i386-pc-mingw32/include -DSILENT=1 -DNO_SIGNALS=1 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 -DJAVA_FINALIZATION=1 -DGC_GCJ_SUPPORT=1 -DATOMIC_UNCOLLECTABLE=1 -DNO_SIGSET=1 -DNO_DEBUGGING=1  -I. -I/home/alik/java/crossgcc-src/boehm-gc  -I/home/alik/java/crossgcc-src/boehm-gc/include   -I././targ-include -I/home/alik/java/crossgcc-src/boehm-gc/./libc/include -g -O2 -c /home/alik/java/crossgcc-src/boehm-gc/misc.c
/home/alik/java/crossgcc-obj/gcc/xgcc -B/home/alik/java/crossgcc-obj/gcc/ -B/home/alik/java/crossgcc-install/i386-pc-mingw32/bin/ -B/home/alik/java/crossgcc-install/i386-pc-mingw32/lib/ -isystem /home/alik/java/crossgcc-install/i386-pc-mingw32/include -DSILENT=1 -DNO_SIGNALS=1 -DNO_EXECUTE_PERMISSION=1 -DALL_INTERIOR_POINTERS=1 -DJAVA_FINALIZATION=1 -DGC_GCJ_SUPPORT=1 -DATOMIC_UNCOLLECTABLE=1 -DNO_SIGSET=1 -DNO_DEBUGGING=1 -I. -I/home/alik/java/crossgcc-src/boehm-gc -I/home/alik/java/crossgcc-src/boehm-gc/include -I././targ-include -I/home/alik/java/crossgcc-src/boehm-gc/./libc/include -g -O2 -c /home/alik/java/crossgcc-src/boehm-gc/misc.c -o misc.o
/home/alik/java/crossgcc-src/boehm-gc/misc.c: In function `GC_init':
/home/alik/java/crossgcc-src/boehm-gc/misc.c:451: `GC_allocate_ml' undeclared (first use in this function)
/home/alik/java/crossgcc-src/boehm-gc/misc.c:451: (Each undeclared identifier is reported only once
/home/alik/java/crossgcc-src/boehm-gc/misc.c:451: for each function it appears in.)
make[2]: *** [misc.lo] Error 1
make[2]: Leaving directory `/home/alik/java/crossgcc-obj/i386-pc-mingw32/boehm-gc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/alik/java/crossgcc-obj/i386-pc-mingw32/boehm-gc'
make: *** [all-target-boehm-gc] Error 2
[alik@explorer crossgcc-obj]$ 

misc.c CONTAINS:

450 #ifdef MSWIN32
451    if (!GC_is_initialized) InitializeCriticalSection(&GC_allocate_ml);
452 #endif /* MSWIN32 */

so MSWIN32 seems be defined here.

include/internal/gc_locks.h defines GC_allocate_ml but seems not in mine case







______________________________________________________________________________
Email.cz -----> Vaše emailová schránka zdarma.
http://www.Email.cz <------------Pošta zdarma!


-------------- next part --------------

[alik@explorer alik]$ cat /proc/version 
Linux version 2.4.2-2 (root@porky.devel.redhat.com) (gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-79)) #1 Sun Apr 8 20:41:30 EDT 2001
[alik@explorer alik]$ cat /etc/issue

Red Hat Linux release 7.1 (Seawolf)
Kernel 2.4.2-2 on an i686


1/ make empty target install dir (~/java/crossgcc-install)
2/ make empty build dir (~/java/crossgcc-obj)
3/ make empty source dir (~/java/crossgcc-src)
4/ untar gcc 3.2 sources into src (gcc-3.2.tar.bz2)

5/ check native tools
[alik@explorer alik]$ gcc --version
gcc (GCC) 3.2
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

[alik@explorer alik]$ar --version
GNU ar 2.10.91
Copyright 1997, 98, 99, 2000, 2001 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.



6/ copy mingw includes into ~/java/crossgcc-install/i386-pc-mingw32/include/
   copy mingw runtime libs (*.o, *.a, *.la) files into ~/java/crossgcc-install/i386-pc-mingw32/lib (except libiberty.a)

There is error in mine ming stdlib.h line 153 - missing semicolon. Fixed it.
I _MUST_ replace stdarg.h and stddef.h and varargs.h with that from GCC sources to get it work! [it complains that stddef.h not found - in include_next]

I could _NOT_ compile mingw runtime from sources - haven't got cross compiler which is needed (chicken-egg problem)
 [I copy theese from mingw windows installation (MinGW-2.0.0-3.exe) - should this be a problem?]
 [I have downloaded mingw-runtime and w32api sources and includes seems identical including error in stdlib]


7/ build cross bin-utils
[alik@explorer crossgcc-obj]$ ~/java/binutils-2.13/configure --prefix=$HOME/java/crossgcc-install --target=i386-pc-mingw32 --with-headers=$HOME/java/crossgcc-install/i386-pc-mingw32/include/
...
[alik@explorer crossgcc-obj]$ make
...
[alik@explorer crossgcc-obj]$ make install

OK
clean crossgcc-obj dir



8/ Configure
[alik@explorer crossgcc-obj]$ ~/java/crossgcc-src/configure --prefix=$HOME/java/crossgcc-install --target=i386-pc-mingw32 --with-headers=$HOME/java/crossgcc-install/i386-pc-mingw32/include/ --enable-languages=c,c++,java --enable-libgcj --enable-threads=win32

Configuring for a i686-pc-linux-gnu host.
Copying /home/alik/java/crossgcc-install/i386-pc-mingw32/include/ to /home/alik/java/crossgcc-install/i386-pc-mingw32/sys-include
*** This configuration is not supported in the following subdirectories:
     target-libf2c target-libobjc
    (Any other directories should still work fine.)
...
checking host system type... i686-pc-linux-gnu
checking target system type... i386-pc-mingw32
checking build system type... i686-pc-linux-gnu
...
rest looks OK


9/ Build
[alik@explorer crossgcc-obj]$ export PATH=$PATH:/home/alik/java/crossgcc-install/bin [needed to find ar and other from binutil]
[alik@explorer crossgcc-obj]$ make
C compiler OK
C++ compiler OK
java compiler OK
libgcc runtime OK [using i386-pc-mingw32-ar]
stdc++ lib OK [successfully using ming runtime]
libffi OK
zlib OK
boehm-gc OK [needs --enable-threads=win32]
libjava OK [needs --enable-threads=win32 and corrected java/net/nat*.cc]

 [There was error in mine java/net native classes (not defined IP_BROADCAST_*) !]



More information about the Java mailing list