This is the mail archive of the java@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

what i learned making a gcj cross-compile environment for target=i386-cygwin



I thought it would be easiest to debug the compiler in a linux
environment, so I should make a cross-compiler, in order to work with
a mingw32 target.  That turned out to be easier concieved than
executed.  I thought better of the whole adventure when I started
running into problems building libgcj.  This message is intended
simply to document my effort for any future adventurers -- false moves
and all:

building cygwin cross-compilation environment from /home/anon into /usr/local/pkgs/cygwin:

obj: cygwin-binutils, src: src
obj: cygwin-trunk, src: trunk

0. cd cygwin-binutils

1. configure 
  use ../cygwin-binutils.sh:
  ../src/configure --target=i386-cygwin --prefix=/usr/local/pkgs/cygwin --disable-gdb --disable-tcl --disable-tk --disable-itcl --disable-tix --disable-expect --disable-libgui --disable-gdbtk --disable-sid --disable-sim
  some of these options may be superfluous

2. make
  fails in /usr/home/anon/cygwin-binutils/i386-cygwin/newlib/libc/stdlib
  due to lack of gcc cross-compiler

3. make install
  (same failure, but populates /usr/local/pkgs/cygwin with xdev binutils and libs)

4. cd ../cygwin-trunk

5. configure
  use ../cygwin-trunk.sh:
  ../trunk/configure --target=i386-cygwin --prefix=/usr/local/pkgs/cygwin --enable-threads=pthreads --enable-shared --enable-languages=c,c++,java

  Issues:  --enable-threads?  --enable-threads=win32?  --enable-shared?  i386-cygwin vs. i386-cygwin32?

6. make
  fails in libgcc:
  /home/anon/cygwin-trunk/gcc/xgcc -B/home/anon/cygwin-trunk/gcc/ -B/usr/local/pkgs/cygwin/i386-cygwin/bin/ 
    -B/usr/local/pkgs/cygwin/i386-cygwin/lib/ -isystem /usr/local/pkgs/cygwin/i386-cygwin/include -O2 
    -I../../trunk/gcc/../winsup/include -I../../trunk/gcc/../winsup/cygwin/include 
    -I../../trunk/gcc/../winsup/w32api/include -DCROSS_COMPILE -DIN_GCC    -W -Wall 
    -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -isystem ./include   -g1 
    -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. -I. 
    -I../../trunk/gcc -I../../trunk/gcc/. -I../../trunk/gcc/config -I../../trunk/gcc/../include  
    -DL_muldi3 -c ../../trunk/gcc/libgcc2.c -o libgcc/./_muldi3.o

  In file included from tconfig.h:4,

                 from ../../trunk/gcc/libgcc2.c:36:

  ../../trunk/gcc/config/i386/cygwin.h:31:19: stdio.h: No such file or directory

  ... 
  Immediate failure is due to lack of stdio.h installation

7. make install
   This populates /usr/local/pkgs/cygwin/lib/gcc-lib, but fails to install gcc.

8. shuffle binaries around

   cp gcc/xgcc /usr/local/pkgs/cygwin/bin/gcc
   cd /usr/local/pkgs/cygwin/bin
   mv gcj i386-cygwin-gcj
     etc.  (i.e. rename the gcc binaries to i386-cygwin-${NAME} for NAME in gcc, gcjh, gcov, 
     jcf-dump, jv-scan, gccbug).
   ln i386-cygwin-gcc i386-cygwin-c++

9. cd /home/anon/cygwin-binutils

10. make
  fails in newlib:
  i386-cygwin-gcc -L/home/anon/cygwin-binutils/i386-cygwin/winsup 
    -L/home/anon/cygwin-binutils/i386-cygwin/winsup/cygwin 
    -L/home/anon/cygwin-binutils/i386-cygwin/winsup/w32api/lib -isystem /home/anon/src/winsup/include 
    -isystem /home/anon/src/winsup/cygwin/include -isystem /home/anon/src/winsup/w32api/include 
    -isystem /home/anon/src/newlib/libc/sys/cygwin -isystem /home/anon/src/newlib/libc/sys/cygwin32 
    -B/home/anon/cygwin-binutils/i386-cygwin/newlib/ 
    -isystem /home/anon/cygwin-binutils/i386-cygwin/newlib/targ-include 
    -isystem /home/anon/src/newlib/libc/include -L/home/anon/cygwin-binutils/ld -c 
    -nostdinc -DHAVE_CONFIG_H  -g -O2 -Wall -Wwrite-strings   -I. -I/usr/home/anon/src/winsup/cygwin/include 
    -I/usr/home/anon/src/winsup/cygwin -I/usr/home/anon/src/newlib/libc/sys/cygwin 
    -I/usr/home/anon/src/newlib/libc/include -I/usr/home/anon/src/winsup/w32api/include 
    -I../../../../src/winsup/cygwin/config/i386 -I.//include -o ./glob.o ../../../../src/winsup/cygwin/glob.c

  In file included from /usr/home/anon/src/newlib/libc/sys/cygwin/sys/param.h:12,

                from ../../../../src/winsup/cygwin/glob.c:72:

  /usr/home/anon/src/newlib/libc/include/sys/types.h:31:21: stddef.h: No such file or directory


11. make install
  This is an attempt to get the header files installed for making libgcc.

12. cd ../cygwin-trunk

13. make
  Same failure as in 6
  Presumably the file ../src/winsup/cygwin/include/cygwin/types.h
  (should be getting included via -isystem?)
  -isystem /usr/local/pkgs/cygwin/i386-cygwin/include <-- this option is present
  presumably the install in cygwin-binutils is not doing something that it should do here..

14. cd ../cygwin-binutils

  There are 4 places to find stddef.h at this point:
  a. /usr/local/pkgs/cygwin/lib/gcc-lib/i386-cygwin/3.1/include/stddef.h
  b. ../trunk/gcc/ginclude/stddef.h
  c. ../trunk/libstdc++-v3/include/c_shadow/stddef.h
  d. ../src/winsup/mingw/include/stddef.h

  I would be happiest with (a) or (d), but..
  it appears that the -nostdinc option is preventing (a), and the others aren't really candidates,
  since binutils is in a sep. workspace from trunk gcc.

15. patch src/winsup/Makefile.common:

cvs -z3 diff winsup/Makefile.common
Index: winsup/Makefile.common
===================================================================
RCS file: /cvs/src/src/winsup/Makefile.common,v
retrieving revision 1.23
diff -r1.23 Makefile.common
90a91,93
> tgt_cpp:=$(shell $(CC_FOR_TARGET) -print-prog-name=cpp0)
> cpp_sysdirs:=$(shell $(tgt_cpp) -v </dev/null 2>&1 | grep gcc-lib)
> 
93c96
< COMPILE_CC:=$(CC) $c -nostdinc $(ALL_CFLAGS) -I$(GCC_INCLUDE)
---
> COMPILE_CC:=$(CC) $c -nostdinc $(ALL_CFLAGS) -I$(GCC_INCLUDE) $(patsubst %,-isystem %,$(cpp_sysdirs))

16. make
    fails linking cygwin.dll due to -lstdc++ 
    make install
    fails similarly -- still no install of cygwin/types.h needed by libgcc...
    so patch src/winsup/cygwin/Makefile.in and reconfigure:
cvs -z3 diff -u winsup/cygwin/Makefile.in
Index: winsup/cygwin/Makefile.in
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/Makefile.in,v
retrieving revision 1.55
diff -u -r1.55 Makefile.in
--- Makefile.in	2001/04/20 13:02:32	1.55
+++ Makefile.in	2001/04/25 04:54:32
@@ -146,11 +146,13 @@
 
 force:
 
-install: all $(install_host) $(install_target)
+install_data:
 	$(INSTALL_DATA) new-$(DLL_NAME) $(bindir)/$(DLL_NAME); \
 	for i in $(LIB_NAME) $(GMON_START) $(LIBGMON_A) automode.o binmode.o textmode.o ; do \
 	    $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \
-	done ; \
+	done 
+
+install_includes:
 	cd $(srcdir); \
 	for sub in `find include -name '[a-z]*' -type d -print | sort`; do \
 	    for i in $$sub/*.h ; do \
@@ -158,6 +160,8 @@
 	    done ; \
 	done ; \
 	$(INSTALL_DATA) regexp/regexp.h $(tooldir)/include/regexp.h
+
+install: all $(install_host) $(install_target) install_data install_includes
 
 install_host:
 
17. At this point, i found that --enable-threads=pthreads is wrong for gcc... it requires
  --enable-threads=posix instead, so i reconfigured cygwin-trunk.  cygwin-trunk make
  failed in libiberty, but since i already had a working libiberty, I skipped it, and
  built/installed in cygwin-trunk/gcc, then moved on to cygwin-trunk/i386-cygwin/libstdc++-v3,
  did make install.

18. back to binutils, now that I have an installed libstdc++:
    make -- failure is:
  i386-cygwin-gcc -L/home/anon/cygwin-binutils/i386-cygwin/winsup 
    -L/home/anon/cygwin-binutils/i386-cygwin/winsup/cygwin 
    -L/home/anon/cygwin-binutils/i386-cygwin/winsup/w32api/lib 
    -isystem /home/anon/src/winsup/include -isystem /home/anon/src/winsup/cygwin/include 
    -isystem /home/anon/src/winsup/w32api/include -isystem /home/anon/src/newlib/libc/sys/cygwin 
    -isystem /home/anon/src/newlib/libc/sys/cygwin32 -B/home/anon/cygwin-binutils/i386-cygwin/newlib/ 
    -isystem /home/anon/cygwin-binutils/i386-cygwin/newlib/targ-include 
    -isystem /home/anon/src/newlib/libc/include -L/home/anon/cygwin-binutils/ld 
    -Wl,--base-file=mingwthrd.base -B./ -mdll -mno-cygwin -Wl,--image-base,0x6FBC0000 
    -Wl,--entry,_DllMainCRTStartup@12 mthr.o mthr_init.o
  /usr/local/pkgs/cygwin/lib/gcc-lib/i386-cygwin/3.1/../../../../i386-cygwin/bin/ld: 
    cannot open mingw/dllcrt2.o: No such file or directory

  collect2: ld returned 1 exit status

  make[2]: *** [mingwthrd.def] Error 1

  make[2]: Leaving directory `/usr/home/anon/cygwin-binutils/i386-cygwin/winsup/mingw'

   
  for reasons unknown, this was overcome by the following steps:
  cd i386-cygwin/winsup/mingw
  make
  cd ..
  make
  cd ../..
  make
  make install
 
  at this point, i expect all the headers to be installed, so that gcc can be fully and finally installed.
  
19. back to cygwin-trunk
   make
   fails configuring libffi
   re-configure trunk
   remove libffi from cygwin-trunk/Makefile TARGET_CONFIGDIRS
   make
   now libjava fails to configure, due to sizeof(void *) config test
   add line to i386-cygwin/config.cache:
     ac_cv_sizeof_void_p=${ac_cv_sizeof_void_p=4}
   this works, so i add lines:
     ac_cv_sizeof_double=${ac_cv_sizeof_double=8}
     ac_cv_sizeof_float=${ac_cv_sizeof_float=4}
     ac_cv_sizeof_int=${ac_cv_sizeof_int=4}
     ac_cv_sizeof_long=${ac_cv_sizeof_long=4}
     ac_cv_sizeof_long_double=${ac_cv_sizeof_long_double=12}
     ac_cv_sizeof_long_long=${ac_cv_sizeof_long_long=8}
     ac_cv_sizeof_short=${ac_cv_sizeof_short=2}
   and restore libffi to the Makefile,
   which solves the config problem
   make builds libffi okay
   make install in libffi doesn't work, but i'm not going to worry about that yet, because:

20.  libgcj failures:
    ./libtool: cygpath: command not found

    libtool: link: warning: undefined symbols not allowed in i386-pc-cygwin shared libraries

    lib /OUT:.libs/libzgcj.lib  
      adler32.o compress.o crc32.o deflate.o gzio.o infblock.o infcodes.o inffast.o inflate.o 
      inftrees.o infutil.o trees.o uncompr.o zutil.o

    ./libtool: lib: command not found


at this point i'm thinking:  'lib' is not going to be available on linux
i'll probably have to substitute i386-cygwin tool based scripts  or some such...
and when i try 'make' again, i get problems with missing java class .h files,

(Tue 24 Apr 2001 Midnight)

i finally decided to put the cross-compiler on the back burner until
i've explored using the compiler on cygwin directly.
i submitted the patches above to the cygwin mailing list.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]