bug-gzip
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gzip cross-compile failure


From: Bruno Haible
Subject: gzip cross-compile failure
Date: Mon, 11 Dec 2006 17:37:06 +0100
User-agent: KMail/1.9.1

Cross-compiling gzip-1.3.7 from Linux/x86 to Cygwin fails:

$ ./configure --host=i386-pc-cygwin --prefix=/cross/i386-pc-cygwin 
CPPFLAGS=-Wall
...
checking for underline in external names... nm: conftest.o: File format not 
recognized
no
checking for assembler... yes
...
$ make
...
cp ./match.c _match.S
/lib/cpp -DNO_UNDERLINE _match.S > match_.s
i386-pc-cygwin-gcc -std=gnu99 -c -g -O2 match_.s
mv match_.o match.o
rm -f _match.S match_.s
...
i386-pc-cygwin-gcc -std=gnu99  -g -O2   -o gzip.exe bits.o crypt.o deflate.o 
gzip.o inflate.o lzw.o trees.o unlzh.o unlzw.o unpack.o unzip.o util.o zip.o 
lib/libgzip.a 
deflate.o: In function `lm_init':
/dev/shm/gzip-1.3.7/deflate.c:335: undefined reference to `_match_init'
deflate.o: In function `deflate':
/dev/shm/gzip-1.3.7/deflate.c:615: undefined reference to `_longest_match'
/dev/shm/gzip-1.3.7/deflate.c:703: undefined reference to `_longest_match'
collect2: ld returned 1 exit status
make[1]: *** [gzip.exe] Fehler 1

There are two problems here:
1) the native nm is used instead of the cross-compiling nm,
2) /lib/cpp is used instead of the cross-compiling preprocessor.

Here is a fix for problem 1. It changes the configure output to:

checking for underline in external names... yes
checking for assembler... yes


2006-12-10  Bruno Haible  <address@hidden>

        * configure.ac (NM): New check for nm, taking into account cross-
        compiling.
        (gzip_cv_underline): Use it.

*** configure.ac.bak    2006-12-07 08:51:55.000000000 +0100
--- configure.ac        2006-12-10 22:42:05.000000000 +0100
***************
*** 28,33 ****
--- 28,34 ----
  AC_PROG_CC_STDC
  AM_PROG_CC_C_O
  AC_PROG_CPP
+ AC_CHECK_TOOL([NM], [nm], [nm])
  AC_PROG_LN_S
  AC_PROG_RANLIB
  AC_PROG_SHELL
***************
*** 44,50 ****
  AC_CACHE_CHECK([for underline in external names], [gzip_cv_underline],
    [gzip_cv_underline=yes
     AC_TRY_COMPILE([int foo() {return 0;}], [],
!      [nm conftest.$OBJEXT | grep _foo >/dev/null 2>&1 ||
        gzip_cv_underline=no])])
  if test $gzip_cv_underline = no; then
    ASCPP="${ASCPP} -DNO_UNDERLINE"
--- 45,51 ----
  AC_CACHE_CHECK([for underline in external names], [gzip_cv_underline],
    [gzip_cv_underline=yes
     AC_TRY_COMPILE([int foo() {return 0;}], [],
!      [$NM conftest.$OBJEXT | grep _foo >/dev/null 2>&1 ||
        gzip_cv_underline=no])])
  if test $gzip_cv_underline = no; then
    ASCPP="${ASCPP} -DNO_UNDERLINE"


Then here is a fix for problem 2. We must avoid /lib/cpp, and instead use
another workaround to fix up the preprocessor's output so that the assembler
accepts it. Here I use a combination of the various greps that I needed in
such cases in ffcall (part of GNU clisp). It leads to

...
cp ./match.c _match.S
i386-pc-cygwin-gcc -std=gnu99 -E  _match.S | grep -v '^ *#line' | grep -v 
'^#ident' | grep -v '^#' | sed -e 's,% ,%,g' -e 's,\. ,.,g' -e 's,//.*,,' > 
match_.s
i386-pc-cygwin-gcc -std=gnu99 -c -g -O2 match_.s
mv match_.o match.o
...

and a successful link.


2006-12-10  Bruno Haible  <address@hidden>

        Cross-compilation support.
        * configure.ac (ASCPP): Remove substituted variable.
        (ASCPPPOST, ASCPPFLAGS): New substituted variables.
        * lib/Makefile.am (ASCPP, LN_S): Remove unnecessary macro definitions.
        (match.$(OBJEXT)): Use CPP, ASCPPFLAGS, ASCPPPOST instead of ASCPP.

*** configure.ac.bak    2006-12-10 22:42:41.000000000 +0100
--- configure.ac        2006-12-10 23:01:08.000000000 +0100
***************
*** 38,66 ****
  
  gl_INIT
  
! # cc -E produces incorrect asm files on SVR4, we must use /lib/cpp.
! test -z "$ASCPP" && test -f /lib/cpp && ASCPP=/lib/cpp
! test -z "$ASCPP" && ASCPP="$CPP"
  
  AC_CACHE_CHECK([for underline in external names], [gzip_cv_underline],
    [gzip_cv_underline=yes
     AC_TRY_COMPILE([int foo() {return 0;}], [],
       [$NM conftest.$OBJEXT | grep _foo >/dev/null 2>&1 ||
        gzip_cv_underline=no])])
  if test $gzip_cv_underline = no; then
!   ASCPP="${ASCPP} -DNO_UNDERLINE"
  fi
  AC_OBJEXT
  
  # Try to assemble match.S.
  # "gcc -E match.s" ignores -E, so we must use match.S.
! AC_CACHE_CHECK([for assembler], [gzip_cv_assembler],
    [gzip_cv_assembler=no
     case " $DEFS " in
     *' NO_ASM '*) ;;
     *)
       if cp $srcdir/lib/match.c _match.S &&
!       eval "$ASCPP _match.S > match_.s 2>/dev/null"; then
         if test ! -s match_.s || grep error < match_.s > /dev/null; then
         :
         elif eval "$CC -c match_.s >/dev/null 2>&1" &&
--- 38,69 ----
  
  gl_INIT
  
! # cc -E produces incorrect asm files on SVR4, we must postprocess it.
! ASCPPPOST="grep -v '^ *#line' | grep -v '^#ident' | grep -v '^#' | sed -e 
's,% ,%,g' -e 's,\\. ,.,g' -e 's,//.*,,'"
! AC_SUBST([ASCPPPOST])
  
  AC_CACHE_CHECK([for underline in external names], [gzip_cv_underline],
    [gzip_cv_underline=yes
     AC_TRY_COMPILE([int foo() {return 0;}], [],
       [$NM conftest.$OBJEXT | grep _foo >/dev/null 2>&1 ||
        gzip_cv_underline=no])])
+ ASCPPFLAGS=
  if test $gzip_cv_underline = no; then
!   ASCPPFLAGS="-DNO_UNDERLINE"
  fi
+ AC_SUBST([ASCPPFLAGS])
  AC_OBJEXT
  
  # Try to assemble match.S.
  # "gcc -E match.s" ignores -E, so we must use match.S.
! AC_CACHE_CHECK([for an assembler syntax supported by this package],
!   [gzip_cv_assembler],
    [gzip_cv_assembler=no
     case " $DEFS " in
     *' NO_ASM '*) ;;
     *)
       if cp $srcdir/lib/match.c _match.S &&
!       eval "$CPP $ASCPPFLAGS _match.S | $ASCPPPOST > match_.s 2>/dev/null"; 
then
         if test ! -s match_.s || grep error < match_.s > /dev/null; then
         :
         elif eval "$CC -c match_.s >/dev/null 2>&1" &&
***************
*** 87,93 ****
  AC_TYPE_OFF_T
  
  AC_PREFIX_PROGRAM(gzip)
- AC_SUBST(ASCPP)dnl
  
  AC_CONFIG_FILES([Makefile doc/Makefile lib/Makefile])
  AC_OUTPUT
--- 90,95 ----
*** lib/Makefile.am.bak 2006-12-07 08:23:35.000000000 +0100
--- lib/Makefile.am     2006-12-10 23:06:49.000000000 +0100
***************
*** 22,33 ****
  libgzip_a_LIBADD += $(LIBOBJS)
  libgzip_a_DEPENDENCIES += $(LIBOBJS)
  
- ASCPP = @ASCPP@
- LN_S = @LN_S@
- 
  match.$(OBJEXT): match.c
        cp $(srcdir)/match.c _match.S
!       $(ASCPP) _match.S > match_.s
        $(CC) -c $(CFLAGS) match_.s
        mv match_.$(OBJEXT) $@
        rm -f _match.S match_.s
--- 22,30 ----
  libgzip_a_LIBADD += $(LIBOBJS)
  libgzip_a_DEPENDENCIES += $(LIBOBJS)
  
  match.$(OBJEXT): match.c
        cp $(srcdir)/match.c _match.S
!       $(CPP) $(ASCPPFLAGS) _match.S | @ASCPPPOST@ > match_.s
        $(CC) -c $(CFLAGS) match_.s
        mv match_.$(OBJEXT) $@
        rm -f _match.S match_.s




reply via email to

[Prev in Thread] Current Thread [Next in Thread]