Compiling llvm-gcc on amd64 with 32 bits: assembler still carps

Hi all,

I managed to navigate around all those issues with environment variables
and such. llvm itself now builds and checks just fine, but I can't get
llvm-gcc to compile.

Trying to 'make' from .../gcc gives me:

./xgcc -B./ -B/home/jo/i686-pc-linux-gnu/bin/
-isystem /home/jo/i686-pc-linux-gnu/include
-isystem /home/jo/i686-pc-linux-gnu/sys-include
-L/home/jo/llvm-gcc-wrk/gcc/../ld -O2 -DIN_GCC -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -isystem ./include -I. -I.
-I/home/jo/llvm-gcc-src/gcc -I/home/jo/llvm-gcc-src/gcc/.
-I/home/jo/llvm-gcc-src/gcc/../include
-I/home/jo/llvm-gcc-src/gcc/../libcpp/include
-I/home/jo/llvm-gcc-src/gcc/../libdecnumber -I../libdecnumber -g0
-finhibit-size-directive -fno-inline-functions -fno-exceptions
-fno-zero-initialized-in-bss -fno-toplevel-reorder
-fno-omit-frame-pointer \
          -c /home/jo/llvm-gcc-src/gcc/crtstuff.c -DCRT_BEGIN \
          -o crtbegin.o
/tmp/ccuWW3r0.s: Assembler messages:
/tmp/ccuWW3r0.s:27: Error: suffix or operands invalid for `push'
/tmp/ccuWW3r0.s:37: Error: suffix or operands invalid for `call'
/tmp/ccuWW3r0.s:55: Error: suffix or operands invalid for `push'
/tmp/ccuWW3r0.s:65: Error: suffix or operands invalid for `call'
make: *** [crtbegin.o] Error 1

./xgcc -dumpmachine gives
i686-pc-linux-gnu
so this is OK.

The reported lines are:
     27 pushl %ebp
     37 call *%edx
     55 pushl %ebp
     65 call *%eax

What's wrong?

Regards,
Jo

P.S.: I'm running with a freshly compiled and PATH-installed llvm
package with a clean 'make check', and use
export LLVM_GCC_SRC=$HOME/llvm-gcc-src
export LLVM_GCC_WRK=$HOME/llvm-gcc-wrk
export LLVM_CONFIGURE=
export LLVM_CONFIGURE="$LLVM_CONFIGURE --prefix=$HOME"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --enable-optimized"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --build=i686-pc-linux-gnu"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --host=i686-pc-linux-gnu"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --target=i686-pc-linux-gnu"
export CC=gcc-4.2
export CXX=g++-4.2
cd $LLVM_GCC_WRK
$LLVM_GCC_SRC/configure $LLVM_CONFIGURE
make -j3

It shoudl work fine if you set CC right and use --build --target
--host == i686-pc-linux-gnu

To clarify,

configure --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
--target=i686-pc-linux-gnu

I do this all the time on my 4 core amd64 box and it works fine.

To clarify,

configure --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
--target=i686-pc-linux-gnu

I do this all the time on my 4 core amd64 box and it works fine.

There must be some other difference, as I'm doing exactly that:

> > export LLVM_GCC_SRC=$HOME/llvm-gcc-src
> > export LLVM_GCC_WRK=$HOME/llvm-gcc-wrk
> > export LLVM_CONFIGURE=
> > export LLVM_CONFIGURE="$LLVM_CONFIGURE --prefix=$HOME"
> > export LLVM_CONFIGURE="$LLVM_CONFIGURE --enable-optimized"
> > export LLVM_CONFIGURE="$LLVM_CONFIGURE --build=i686-pc-linux-gnu"
> > export LLVM_CONFIGURE="$LLVM_CONFIGURE --host=i686-pc-linux-gnu"
> > export LLVM_CONFIGURE="$LLVM_CONFIGURE --target=i686-pc-linux-gnu"
> > export CC=gcc-4.2
> > export CXX=g++-4.2
> > cd $LLVM_GCC_WRK
> > $LLVM_GCC_SRC/configure $LLVM_CONFIGURE
> > make -j3

Look at how $LLVM_CONFIGURE is built, the final value is

--prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu"

Regards,
Jo

To clarify,

configure --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
--target=i686-pc-linux-gnu

I do this all the time on my 4 core amd64 box and it works fine.

There must be some other difference, as I'm doing exactly that:

export LLVM_GCC_SRC=$HOME/llvm-gcc-src
export LLVM_GCC_WRK=$HOME/llvm-gcc-wrk
export LLVM_CONFIGURE=
export LLVM_CONFIGURE="$LLVM_CONFIGURE --prefix=$HOME"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --enable-optimized"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --build=i686-pc-linux-gnu"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --host=i686-pc-linux-gnu"
export LLVM_CONFIGURE="$LLVM_CONFIGURE --target=i686-pc-linux-gnu"
export CC=gcc-4.2
export CXX=g++-4.2
cd $LLVM_GCC_WRK
$LLVM_GCC_SRC/configure $LLVM_CONFIGURE
make -j3

Look at how $LLVM_CONFIGURE is built, the final value is

--prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu"

This looks likes its missing some stuff. Make sure the configure line is exactly as what is in README.LLVM.

-Tanya

Ah, I see.
I seem to be missing --enable-llvm and --enable-languages.
I'll give it another try.

Regards,
Jo

OK, I now have

LLVM_VERSION_INFO=kurier-bootstrap /home/jo/llvm-gcc-src/configure
--prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
--enable-llvm=/home/jo --enable-languages=c,c++

The --enable-llvm directory is the same as --prefix, I hope that's right
(the actual binaries are in the 'bin' subdirectory).

I don't think --enable-checking should be necessary, I had
llvm ./configure'd with --enable-optimized (I hope that's the same as
specifying ENABLE_OPTIMIZED=1 during the 'make' run for LLVM proper).

Trying with OPTIMIZE_OPTION=-O2 didn't help.

Anything else I may have overlooked?

Regards,
Jo

P.S.: Rerunning the failing command with -v gave me

GNU C version 4.2.1 (Based on Apple Inc. build 5555) (LLVM build)
(i686-pc-linux-gnu)
        compiled by GNU C version 4.2.1 (Ubuntu 4.2.1-5ubuntu4).

so it seems to call the right compiler, but I still get

/home/jo/llvm-gcc-wrk/./gcc/as --traditional-format -V -Qy -o
crtbegin.o crtstuff.s
GNU assembler version 2.18 (x86_64-linux-gnu) using BFD version (GNU
Binutils for Ubuntu) 2.18
crtstuff.s: Assembler messages:
crtstuff.s:15: Error: suffix or operands invalid for `push'
crtstuff.s:29: Error: suffix or operands invalid for `call'
crtstuff.s:36: Error: suffix or operands invalid for `pop'
crtstuff.s:39: Error: suffix or operands invalid for `pop'
crtstuff.s:47: Error: suffix or operands invalid for `push'
crtstuff.s:60: Error: suffix or operands invalid for `call'
crtstuff.s:63: Error: suffix or operands invalid for `pop'

(As noted in one of my previous mails, .../gcc/as is just a shellscript
calling the installed as, which happens to be GNU as.)

Look at how $LLVM_CONFIGURE is built, the final value is

--prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu"

This looks likes its missing some stuff. Make sure the configure line
is exactly as what is in README.LLVM.

OK, I now have

LLVM_VERSION_INFO=kurier-bootstrap /home/jo/llvm-gcc-src/configure
--prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
--enable-llvm=/home/jo --enable-languages=c,c++

Where have you built llvm? The enable-llvm dir should point to where you built llvm.

The --enable-llvm directory is the same as --prefix, I hope that's right
(the actual binaries are in the 'bin' subdirectory).

I don't think --enable-checking should be necessary, I had
llvm ./configure'd with --enable-optimized (I hope that's the same as
specifying ENABLE_OPTIMIZED=1 during the 'make' run for LLVM proper).

You have to build both a release build of LLVM and llvm-gcc or both debug. You can't mix. So if you did --enable-checking that Debug. SVN by default is debug. A release of LLVM is release by default. I think --enable-optimized and ENABLE_OPTIMIZED=1 are the same, so you should be ok.

Trying with OPTIMIZE_OPTION=-O2 didn't help.

Anything else I may have overlooked?

I'm guessing its your --enable-llvm setting.

Hope that helps..

-Tanya

>
>>> Look at how $LLVM_CONFIGURE is built, the final value is
>>>
>>> --prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
>>> --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu"
>>>
>>
>> This looks likes its missing some stuff. Make sure the configure line
>> is exactly as what is in README.LLVM.
>
> OK, I now have
>
> LLVM_VERSION_INFO=kurier-bootstrap /home/jo/llvm-gcc-src/configure
> --prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
> --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
> --enable-llvm=/home/jo --enable-languages=c,c++
>

Where have you built llvm? The enable-llvm dir should point to where
you built llvm.

The --prefix for LLVM and LLVM-GCC is the same, /home/jo.
IOW the LLVM binaries are in /home/jo/bin.
I'll try with --enable-llvm=/home/jo/bin today.

> The --enable-llvm directory is the same as --prefix, I hope that's
> right
> (the actual binaries are in the 'bin' subdirectory).
>
> I don't think --enable-checking should be necessary, I had
> llvm ./configure'd with --enable-optimized (I hope that's the same as
> specifying ENABLE_OPTIMIZED=1 during the 'make' run for LLVM proper).
>

You have to build both a release build of LLVM and llvm-gcc or both
debug. You can't mix. So if you did --enable-checking that Debug. SVN
by default is debug.

Yup, I'm aware of that.
I use the SVN sources, but apply --enable-optimized for both builds, so
this should be OK.

Regards,
Jo

Look at how $LLVM_CONFIGURE is built, the final value is

--prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu"

This looks likes its missing some stuff. Make sure the configure line
is exactly as what is in README.LLVM.

OK, I now have

LLVM_VERSION_INFO=kurier-bootstrap /home/jo/llvm-gcc-src/configure
--prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
--host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
--enable-llvm=/home/jo --enable-languages=c,c++

Where have you built llvm? The enable-llvm dir should point to where
you built llvm.

The --prefix for LLVM and LLVM-GCC is the same, /home/jo.
IOW the LLVM binaries are in /home/jo/bin.
I'll try with --enable-llvm=/home/jo/bin today.

No, not where the binaries are, but I think it should point to where the libraries are. I don't usually do an install, so maybe someone else can comment on this.

-Tanya

Saying --enable-llvm=/home/jo/lib or --enable-llvm=/home/jo/bin gives me

...
checking for valgrind.h... (cached) no
checking for dsymutil... no
dsymutil is not available
checking for dsymutil... no
dsymutil is not available
configure: error: You must specify valid path to your LLVM tree with
--enable-llvm=DIR

quite early in 'make'.

--enable-llvm=/home/jo does a lot more work before it finally hits the
assembler problems.

So I conclude that --enable-llvm should point to wherever --prefix
pointed when LLVM was built, and the assembler problem have some other
source.

Regards,
Jo

*bump*

Anybody got a clue?

I can post a full transcript of a shell session that reproduces the
error if that helps.

To reiterate the original problem: I'm trying to compile LLVM-GCC on an
Ubuntu 64-bit box, with a 32-bit target (to avoid potential problems
with PIC and such).
I get errors like
  Error: suffix or operands invalid for `push'
as soon as the make process tries to assemble anything; the surface
cause of the problem is that it's calling the preinstalled GNU assembler
but not telling it to emit 32-bit code. (The root cause may be that the
--build, --host and --target options are mishandled somewhere. This
hypothesis is supported by the fact that you need to specify all three
even though normally, specifying just --build should be enough, but
unfortunately, I don't know enough about the automake machinery to
verify or falsify it.)

Regards,
Jo

-- snip --

>>
>>> OK, I now have
>>>
>>> LLVM_VERSION_INFO=kurier-bootstrap /home/jo/llvm-gcc-src/configure
>>> --prefix=/home/jo --enable-optimized --build=i686-pc-linux-gnu
>>> --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu
>>> --enable-llvm=/home/jo --enable-languages=c,c++
>>
>> Where have you built llvm? The enable-llvm dir should point to where
>> you built llvm.
>
> The --prefix for LLVM and LLVM-GCC is the same, /home/jo.
> IOW the LLVM binaries are in /home/jo/bin.
> I'll try with --enable-llvm=/home/jo/bin today.

No, not where the binaries are, but I think it should point to where
the libraries are. I don't usually do an install, so maybe someone
else can comment on this.

Saying --enable-llvm=/home/jo/lib or --enable-llvm=/home/jo/bin gives me

...
checking for valgrind.h... (cached) no
checking for dsymutil... no
dsymutil is not available
checking for dsymutil... no
dsymutil is not available
configure: error: You must specify valid path to your LLVM tree with
--enable-llvm=DIR

quite early in 'make'.

--enable-llvm=/home/jo does a lot more work before it finally hits the
assembler problems.

So I conclude that --enable-llvm should point to wherever --prefix
pointed when LLVM was built, and the assembler problem have some other
source.

Regards,
Jo

Joachim Durchholz wrote:

*bump*

Anybody got a clue?

I can post a full transcript of a shell session that reproduces the
error if that helps.

To reiterate the original problem: I'm trying to compile LLVM-GCC on an
Ubuntu 64-bit box, with a 32-bit target (to avoid potential problems
with PIC and such).
I get errors like
  Error: suffix or operands invalid for `push'
as soon as the make process tries to assemble anything; the surface
cause of the problem is that it's calling the preinstalled GNU assembler
but not telling it to emit 32-bit code. (The root cause may be that the
--build, --host and --target options are mishandled somewhere. This
hypothesis is supported by the fact that you need to specify all three
even though normally, specifying just --build should be enough, but
unfortunately, I don't know enough about the automake machinery to
verify or falsify it.)

Regards,
Jo

Try downloading the upstream gcc-4.2 (without any vendor-specific
patches), and build with same configure line (except the --enable-llvm).
If it works, compare the Makefiles. This should give a starting point.

Best regards,
--Edwin