Unable to build LLVM-GCC 2.3 (using x86_64 and gcc 4.2.3-2ubuntu7)

I read the README and I think I noted all the relevant pitfalls, but
something still goes wrong. I didn't see anything similar in this
months list archives either.

On the other hand, I see the release notes do not list linux x86_64 as a
known good architecture - only linux IA32 (though MacOS X is said to be
supported on x86 in 64 bit mode). Am I trying to do the impossible?

$ tar xvf llvm-2.3.tar.gz && \
tar xvf llvm-gcc-4.2-2.3.source.tar.gz && \
cd llvm-2.3 && \
./configure --enable-optimized && \
make -j 2 && \
cd .. && \
mkdir obj && \
cd obj && \
../llvm-gcc4.2-2.3.source/configure --program-prefix=llvm-
--enable-languages=c --enable-llvm=`pwd`/../llvm-2.3 --disable-shared
--disable-multilib && \
make -j 2

llvm succeeds, and it looks like the llvm-gcc build chokes at the start
of "stage 2"

Configuring stage 2 in ./intl
Configuring stage 2 in ./libiberty
configure: creating cache ./config.cache
configure: creating cache ./config.cache
checking whether make sets $(MAKE)... checking whether to enable
maintainer-specific portions of Makefiles... no
checking for makeinfo... makeinfo --split-size=5000000 --split-size=5000000
checking for perl... perl
yes
checking for a BSD-compatible install... /usr/bin/install -c
checking whether NLS is requested... yes
checking build system type... checking for msgfmt... /usr/bin/msgfmt
checking for gmsgfmt... /usr/bin/msgfmt
checking for xgettext... /usr/bin/xgettext
x86_64-unknown-linux-gnu
checking for msgmerge... checking host system type... /usr/bin/msgmerge
x86_64-unknown-linux-gnu
checking for x86_64-unknown-linux-gnu-gcc...
/home/alan/pkg/llvm/obj/./prev-gcc/xgcc
-B/home/alan/pkg/llvm/obj/./prev-gcc/
-B/usr/local/x86_64-unknown-linux-gnu/bin/
checking for C compiler default output file name... checking for
x86_64-unknown-linux-gnu-ar... ar
checking for x86_64-unknown-linux-gnu-ranlib... ranlib
checking for x86_64-unknown-linux-gnu-gcc...
/home/alan/pkg/llvm/obj/./prev-gcc/xgcc
-B/home/alan/pkg/llvm/obj/./prev-gcc/
-B/usr/local/x86_64-unknown-linux-gnu/bin/
a.out
checking whether the C compiler works... configure: error: cannot run C
compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
checking for C compiler default output file name... make[2]: ***
[configure-stage2-intl] Error 1
make[2]: *** Waiting for unfinished jobs....
a.out
checking whether the C compiler works... configure: error: cannot run C
compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.
make[2]: *** [configure-stage2-libiberty] Error 1
make[2]: Leaving directory `/home/alan/pkg/llvm/obj'
make[1]: *** [stage2-bubble] Error 2
make[1]: Leaving directory `/home/alan/pkg/llvm/obj'
make: *** [all] Error 2

config.log:

configure:2119: checking for C compiler default output file name
configure:2122: /home/alan/pkg/llvm/obj/./prev-gcc/xgcc
-B/home/alan/pkg/llvm/obj/./prev-gcc/
-B/usr/local/x86_64-unknown-linux-gnu/bin/ -g -O2 conftest.c >&5
configure:2125: $? = 0
configure:2171: result: a.out
configure:2176: checking whether the C compiler works
configure:2182: ./a.out
Segmentation fault
configure:2185: $? = 139
configure:2192: error: cannot run C compiled programs.
If you meant to cross compile, use `--host'.
See `config.log' for more details.

$ cat > test.c << EOF
main(){}
EOF
$ cd prev-gcc

Weirdness with different compile options:

./xgcc -g ../test.c -B.
/usr/local/x86_64-unknown-linux-gnu/bin/ld: internal error in
starting_output_address, at output.cc:2097
collect2: ld returned 1 exit status

Backtrace:

$ ./xgcc -O2 -g ../test.c -B.
$ gdb ./a.out
GNU gdb 6.8-debian
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later
<http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu"...
Function "fancy_abort" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
Function "internal_error" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
Function "exit" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
Function "abort" not defined.
Make breakpoint pending on future shared library load? (y or [n])
[answered N; input not from terminal]
(gdb) run
Starting program: /home/alan/pkg/llvm/obj/prev-gcc/a.out

Program received signal SIGSEGV, Segmentation fault.
0x00000000004002c4 in frame_dummy ()
Current language: auto; currently asm
(gdb) where
#0 0x00000000004002c4 in frame_dummy ()
#1 0x00000000004003ea in _init ()
#2 0x00007f5bf497a778 in ?? () from /lib/libc.so.6
#3 0x0000000000400355 in __libc_csu_init ()
#4 0x00007f5bf464015e in __libc_start_main () from /lib/libc.so.6
#5 0x0000000000400249 in _start ()
(gdb)

Thanks in advance
Alan

It seems you can't compile and run C programs at all.

Maybe because you are using /home/alan/pkg/llvm/obj/./prev-gcc/xgcc instead of the system's gcc, which might be broken.

Regards,
Jo

It seems you can't compile and run C programs at all.

Maybe because you are using /home/alan/pkg/llvm/obj/./prev-gcc/xgcc instead of the system's gcc, which might be broken.

During bootstrap stage 2 it is normal to use the just
built gcc. I don't understand why he is having this
problem - I bootstrap llvm-gcc from time to time on
x86-64 linux.

Ciao,

Duncan.

Duncan Sands wrote:

It seems you can't compile and run C programs at all.

Maybe because you are using /home/alan/pkg/llvm/obj/./prev-gcc/xgcc instead of the system's gcc, which might be broken.
    
During bootstrap stage 2 it is normal to use the just
built gcc.

Yah. I tried --disable-bootstrap now but it fails at
[configure-target-libmudflap]. I'm just getting a completely broken
compiler.

  I don't understand why he is having this
problem - I bootstrap llvm-gcc from time to time on
x86-64 linux.

Ciao,

Duncan.
  

OK. Next time I'll try a 32-bit chroot and see if that helps.

Alan