This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Configure tries to run cross-compiled programs


I think I may have found a bug in the configuration scripts.

I'm building a cross-compiler. I am following the directions posted by Mumit Khan. They can be found at http://www.xraylith.wisc.edu/~khan/software/gnu-win32/cygwin-to-linux-cross-howto.txt

The instructions are very complete and I've managed to build the compiler. The problem is that it isn't a smooth process and I need it to be for other developers to use.

Here is the configuration:
WinNT 4 SP6 Running the latest Cygwin
Compiling gcc as a cross compiler for a Linux 2.4.18 target runtime environment

Here is what is going on. I've gathered up the glibc libraries and headers that I need and the kernel headers that I need from a RedHat Linux box. Versions are:
glibc 2.2.4-13
kernel 2.4.18

I have successfully followed the directions and built and installed binutils (v 2.12) using the following commands
$ target=i586-pc-linux-gnu
$ host=i686-pc-cygwin
$ build=i686-pc-cygwin
$ prefix=/usr/local/xdevel
$ src_root=/tmp/src/gnu
$ PATH=$PATH:$prefix/bin
$ mkdir -p $prefix/$target
$ cd $prefix/$target
$ tar xzvf linux-target-runtime.tar.gz
           ^- This is a tar.gz file containing the
	      headers and libraries from the linux
	      target environment
$ mkdir -p $src_root
$ cd $src_root
$ mkdir -p BUILD/gcc
$ mkdir BUILD/binutils
$ tar xzvf binutils-2.12.tar.gz
$ tar xzvf gcc-3.0.4.tar.gz
$ cd BUILD/binutils
$ $src_root/binutils-2.12/configure --with-included-gettext --target=$target --host=$host --build=$build --prefix=$prefix -v
$ make > make.log 2>&1
$ make install > install.log 2>&1

Up to this point, things move without a hitch. Compiling gcc is where I run into problems.

So next I run the following commands
$ $target-ld --version
  This works and lets me know that my new ld tool works.
$ cd $src_root/BUILD/gcc
$ $src_root/gcc-3.0.4/configure --with-included-gettext --enable-threads --enable-shared --target=$target --host=$host --build=$build --prefix=$prefix -v
$ make > make.log 2>&1

Here I run into a problem. The build seems to progress fine until it tries to run 'ltconfig' for libstdc++. From the make.log file:

<snip>
make[1]: Leaving directory `/tmp/src/gnu/BUILD/gcc/gcc'
Configuring in i586-pc-linux-gnu/libstdc++-v3
creating cache ../config.cache
checking host system type... i586-pc-linux-gnu
checking target system type... i586-pc-linux-gnu
checking build system type... i686-pc-cygwin
<snip>
checking whether a program can dlopen itself...

And here it stops and waits indefinitely. So I started investigating and found the config.log file for libstdc++. From the config.log file in the /tmp/src/gnu/BUILD/gcc/i586-pc-linux-gnu/libstdc++-v3 directory:

<snip>
ltconfig:1910: checking whether a program can dlopen itself
ltconfig:1965: /tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -o conftest -g -O2 -fno-builtin -fno-rtti -fno-exceptions  -DHAVE_DLFCN_H  -Wl,--export-dynamic conftest.c -ldl  1>&5

Then from the ltconfig file found in /tmp/src/gnu/gcc-3.0.4:

<snip>
echo "$progname:1910: checking whether a program can dlopen itself" >&5
if test "X${lt_cv_dlopen_self+set}" = Xset; then
  echo $ac_n "(cached) $ac_c" 1>&6
else
  if test "$cross_compiling" = yes; then
    lt_cv_dlopen_self=cross
  else
    cat > conftest.$ac_ext <<EOF
#line 1918 "ltconfig"

#if HAVE_DLFCN_H
<snip - a bunch of test code>
int main() {
    void *self, *ptr1, *ptr2; self=dlopen(0,LTDL_GLOBAL|LTDL_LAZY_OR_NOW);
    if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
               if(ptr1 || ptr2) { dlclose(self); exit(0); } } exit(1); }

EOF
if { (eval echo $progname:1965: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest && (./conftest; exit) 2>/dev/null
then
  lt_cv_dlopen_self=yes
else
  echo "$progname: failed program was:" >&5
  cat conftest.$ac_ext >&5
  rm -fr conftest*
  lt_cv_dlopen_self=no
fi
rm -fr conftest*
fi

fi

The second 'if' statement seems to me to be checking for a cross compiling setup and should dutifully ignore compiling and running this test program. But for some reason it is trying to compile and run it and this is a problem.

At this point the make has stopped, the running processes from 'ps' are:
      PID    PPID    PGID     WINPID  TTY  UID    STIME COMMAND
      390       1     390        390  con  500 13:33:28 /usr/bin/bash
      300     390     300        485  con  500 14:25:01 /usr/bin/make
      478     300     300        478  con  500 14:25:24 /usr/bin/sh
      409     478     300        409  con  500 14:25:25 /usr/bin/sh
      329     409     300        329  con  500 14:25:42 /usr/bin/sh
      426     329     300        426  con  500 14:26:01 /usr/bin/sh
      216     426     300        216  con  500   Dec 31 /tmp/src/gnu/BUILD/gcc/i586-pc-linux-gnu/libstdc++-v3/conftest

Under the NT Task Manager the process looks like this:
Image Name	PID CPU  CPU Time   Mem Usage
NTVDM.EXE	216  00   0:00:00       2076K

It would appear that 'conftest' being compiled for the linux environment has hung and is not going to exit properly (as expected since this is a WinNT box).

Now, if I kill the offending program using 'kill' in cygwin or using the WinNT Task Manager, the build will continue. 

After killing the conftest program, the make.log gets a 'yes':
checking whether a program can dlopen itself... yes

And continues with:
checking whether a statically linked program can dlopen itself... Program too big to fit in memory
yes

It continues normally from there until I get an NT error
(It's actually a message box but I'm not sending a picture,
so here's my text rendition ;) ):
----------------------------------------------------------------
| 16 bit MS-DOS Subsystem
|
|      /tmp/src/gnu/BUILD/gcc
|
|      The NTVDM CPU has encountered an illegal instruction.
|      CS:1189 IP:830f OP:ff ff c7 43 50
|
|          Terminate   Ignore
----------------------------------------------------------------

In reviewing the logs we have a similar situation.
make.log:
<snip>
Configuring in i586-pc-linux-gnu/libiberty
loading cache ../config.cache
checking host system type... i586-pc-linux-gnu
checking build system type... i686-pc-cygwin
<snip>
checking whether the C compiler (/tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -g -O2 ) works...

config.log:
<snip>
configure:1934: checking whether the C compiler (/tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -g -O2 ) works
configure:1950: /tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -o conftest -g -O2   conftest.c  1>&5

The interesting thing about this one is that the configure script is actually trying to check for a cross compiler. From /tmp/src/gnu/gcc-3.0.4/libiberty/configure:
echo "configure:1934: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5

ac_ext=c
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
ac_cpp='$CPP $CPPFLAGS'
ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5'
ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5'
cross_compiling=$ac_cv_prog_cc_cross

cat > conftest.$ac_ext << EOF

#line 1945 "configure"
#include "confdefs.h"

main(){return(0);}
EOF
if { (eval echo configure:1950: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_
exeext}; then
  ac_cv_prog_cc_works=yes
  # If we can't run a trivial program, we are probably using a cross compiler.
  if (./conftest; exit) 2>/dev/null; then
    ac_cv_prog_cc_cross=no
  else
    ac_cv_prog_cc_cross=yes
  fi
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  ac_cv_prog_cc_works=no
fi

If I choose ignore, the error box will continue to popup. If I choose terminate then the configuration script continues but since it doesn't get a non-zero error code back ac_cv_prog_cc_cross gets set to 'no'.

After a few similar situations where programs compiled using the cross compiler hang and I kill them, the build finishes and appears to complete successfully.

Other places errors occur in libiberty/configure are:
make.log: checking for ANSI C header files...
libiberty/config.log: configure:2373: /tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -o conftest -g -O2   conftest.c  1>&5
libiberty/configure: 
if test "$cross_compiling" = yes; then
  :
else
  cat > conftest.$ac_ext <<EOF
#line 2362 "configure"
#include "confdefs.h"
#include <ctype.h>
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
int main () { int i; for (i = 0; i < 256; i++)
if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
exit (0); }

EOF
if { (eval echo configure:2373: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_
exeext} && (./conftest; exit) 2>/dev/null
then
  :
else
  echo "configure: failed program was:" >&5
  cat conftest.$ac_ext >&5
  rm -fr conftest*
  ac_cv_header_stdc=no
fi
rm -fr conftest*
fi

fi

Next error at libiberty/config.log: 
configure:2466: checking for working vfork
configure:2617: /tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -o conftest -g -O2   conftest.c  1>&5

Next error at libiberty/config.log:
configure:2832: checking for working mmap
configure:2980: /tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -o conftest -g -O2   conftest.c  1>&5

Next error at libiberty/config.log:
configure:3004: checking for working strncmp
configure:3073: /tmp/src/gnu/BUILD/gcc/gcc/xgcc -B/tmp/src/gnu/BUILD/gcc/gcc/ -B/usr/local/xdevel/i586-pc-linux-gnu/bin/ -B/usr/local/xdevel/i586-pc-linux-gnu/lib/ -isystem /usr/local/xdevel/i586-pc-linux-gnu/include -o conftest -g -O2   conftest.c  1>&5

All this leads up to my questions which are:
Are the configure scripts and make files working properly?
Do I just have messed up situation or was there some oversight that needs to be fixed?
Is there some way that the later configuration scripts for libstdc++-v3 and libiberty can just use the cross-compile flag set in the initial configuration script? Should they?

Any help or guidance would be appreciated. If any knows if I should submit this to the bug list please tell me.

Thanks,

Brett Hunt



________________________________________________________
Outgrown your current e-mail service?
Get a 25MB Inbox, POP3 Access, No Ads and No Taglines with LYCOS MAIL PLUS.
http://login.mail.lycos.com/brandPage.shtml?pageId=plus


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