problem compiling the cfrontend on Linux/PPC

Hi,

When compiling the cfrontend for Linux/PPC architecture on a powermac G5, i got
the following error :

-------------------------------Compilation error listing

if [ -f stmp-dirs ]; then true; else touch stmp-dirs; fi
make
GCC_FOR_TARGET="/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/xgcc
-B/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/
-B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/bin/
-B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/lib/
-isystem
/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/include
-isystem
/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/sys-include"
\
  AR_FOR_TARGET="powerpc-unknown-linux-gnu-ar" \
  AR_CREATE_FOR_TARGET="powerpc-unknown-linux-gnu-ar rc" \
  AR_EXTRACT_FOR_TARGET="powerpc-unknown-linux-gnu-ar x" \
  AR_FLAGS_FOR_TARGET="" \
  CC="gcc" CFLAGS="-O2 -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -pedantic -Wno-long-long -fno-common " \
  BUILD_PREFIX="" \
  BUILD_PREFIX_1="loser-" \
  LANGUAGES="" \
  LIBGCC2_CFLAGS="-O2 -DIN_GCC -DDEFAULT_TARGET_MACHINE=\"powerpc-unknown-linux-gnu\" -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -isystem ./include -fPIC -g -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -fPIC -mstrict-align " \
  MULTILIB_CFLAGS=" -fPIC -mstrict-align" T= ecrti.o
make[3]: Entering directory
`/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc'
/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/xgcc
-B/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/
-B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/bin/
-B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/lib/
-isystem
/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/include
-isystem
/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/sys-include
-DIN_GCC -DDEFAULT_TARGET_MACHINE=\"powerpc-unknown-linux-gnu\" -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -isystem ./include -I.
-I. -I../../src/gcc -I../../src/gcc/. -I../../src/gcc/../include -fPIC
-mstrict-align -c ecrti.S -o ecrti.o
gccas: /tmp/ccxlWeFz.s:1: syntax error, unexpected $undefined
/tmp/ccxlWeFz.s:1: while reading token: '#'
make[3]: *** [ecrti.o] Erreur 1
make[3]: Leaving directory
`/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc'
make[2]: *** [ecrti.o] Erreur 2
make[2]: Leaving directory
`/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc'
make[1]: *** [stmp-multilib] Erreur 2
make[1]: Leaving directory
`/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc'
make: *** [all-gcc] Erreur 2

-------------------------------END Compilation error listing

It seems that error has to do with gccas which failed to parse a file (?!)

If anyone has an idea...

Regards.

Cyrille Mescam

Hi,

just a guess, but on my x86-64 box I had to compile the gcc frontend
with --disable-multilib

Good luck !

Marco

Cyrille Mescam wrote:

Hi,

When compiling the cfrontend for Linux/PPC architecture on a powermac G5, i got
the following error :

I hate to ask a silly question, but are you using "make bootstrap" to build the cfrontend? Your output looks like gccas is being given a native code assembly language file to parse, and I seem to recall that that happens if you try doing a "make bootstrap".

Our cfrontend doesn't follow the standard GCC build procedures (mainly because we haven't gotten the cfrontend to compile itself with LLVM). Instead, you have to follow our CFE build procedures (http://llvm.cs.uiuc.edu/docs/CFEBuildInstrs.html) to get it to build.

-- John T.

In fact, i am using the CFE build procedures. I am on instructions 5.

cyrille

Cyrille Mescam wrote:

Cyrille Mescam wrote:

[snip]

In fact, i am using the CFE build procedures. I am on instructions 5.

cyrille

Okay, I took a closer look at your output.

I was correct in that gccas is attempting to assemble a native PPC assembly language file. However, this appears to be happening because the assembly file is generated by the GCC Makefiles for libgcc2 (in llvm-gcc/gcc/config/rs6000/t-ppccomm, I think).

The first thing I would try is Marco's suggestion: add --disable-multilib to the configure command line and rebuild. Hopefully this will disable the generation of this assembly code.

If that doesn't work, then you will need to comment out stuff in llvm-gcc/gcc/config/rs6000/t-ppccomm and try to rebuild (you may need to reconfigure and rebuild). Hopefully, we will not need to create LLVM equivalents of this assembly code; I think it's there for ABI compatibility and shouldn't be needed by LLVM.

-- John T.

Okay, I took a closer look at your output.

I was correct in that gccas is attempting to assemble a native PPC
assembly language file. However, this appears to be happening because
the assembly file is generated by the GCC Makefiles for libgcc2 (in
llvm-gcc/gcc/config/rs6000/t-ppccomm, I think).

The first thing I would try is Marco's suggestion: add
--disable-multilib to the configure command line and rebuild. Hopefully
this will disable the generation of this assembly code.

it doesn't work for me

If that doesn't work, then you will need to comment out stuff in
llvm-gcc/gcc/config/rs6000/t-ppccomm and try to rebuild (you may need to
reconfigure and rebuild). Hopefully, we will not need to create LLVM
equivalents of this assembly code; I think it's there for ABI
compatibility and shouldn't be needed by LLVM.

-- John T.

i edit the file llvm-gcc/gcc/config/rs6000/t-ppccomm and remove some
targets from the variable EXTRA_MULTILIB_PARTS (bug stop after bug stop)
:

Cyrille Mescam wrote:

Okay, I took a closer look at your output.

Please see below.

[snip]

Now, it stoppes there:

gmake[1]: Entering directory
`/usr/local/home/cyrille/project/llvm/cfrontend/build/powerpc-unknown-linux-gnu/libiberty'
if [ x"" != x ] && [ ! -d pic ]; then \
  mkdir pic; \
  else true; fi
  touch stamp-picdir
  CONFIG_FILES= CONFIG_HEADERS=config.h:config.in /bin/sh
  ./config.status
  config.status: creating config.h
  config.status: config.h is unchanged
  config.status: executing default commands

--------------------------------
.... (xgcc compilation with no error), then
--------------------------------

/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/xgcc
-B/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/
-B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/bin/
-B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/lib/
-isystem
/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/include
-isystem
/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/sys-include
-c -DHAVE_CONFIG_H -O2 -O2 -I. -I../../../src/libiberty/../include -W
-Wall -Wtraditional -pedantic ../../../src/libiberty/cp-demangle.c -o
cp-demangle.o
Call parameter type does not match function signature!
ubyte* getelementptr ([27 x ubyte]* %.str_247, int 0, int 0)
sbyte* %tmp.51 = tail call uint %fwrite( ubyte* getelementptr ([27 x
ubyte]* %.str_247, int 0, int 0), uint 26, uint 1, %struct._IO_FILE*
%tmp.52 ) ; <uint> [#uses=0]

For some reason, this call to fwrite() is using a first parameter that is a ubyte *. In the function declaration in the file that you sent me, fwrite's first parameter is an sbyte *:

declare uint %fwrite(sbyte*,uint,uint,sbyte*) ;; __builtin_fwrite

Such a mismatch would cause the assertion that you've seen. The assertion is correct; either the fwrite() declaration is wrong or the instruction above should cast the ubyte * to an sbyte *.

I'd like to see what llvm-gcc is doing on your system with a smaller program. Can you generate and send to the list the LLVM assembly for the program below by doing the following:

/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/xgcc
-B/usr/local/home/cyrille/project/llvm/cfrontend/build/gcc/ -B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/bin/
-B/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/lib/
-isystem
/usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/include
-isystem /usr/local/home/cyrille/project/llvm/cfrontend/install/powerpc-unknown-linux-gnu/sys-include
-S -DHAVE_CONFIG_H -O2 -O2 -I. -I../../../src/libiberty/../include -W
-Wall -Wtraditional -pedantic test.c -o
test.ll

... where test.c is:

#include <stdio.h>

void
function ()
{
  char buffer[4];
  FILE * f;

  fwrite (buffer, 1, 1, f);
}

-- John T.

i edit the file llvm-gcc/gcc/config/rs6000/t-ppccomm and remove some
targets from the variable EXTRA_MULTILIB_PARTS (bug stop after bug stop)
:

-------------------------------------------------------------
EXTRA_MULTILIB_PARTS = crtbegin$(objext) crtend$(objext) \
crtbeginS$(objext) crtendS$(objext) crtbeginT$(objext)
-------------------------------------------------------------

Great. Please send these patches so we can apply them. Question: Does llvm-gcc get as far as you do below, if you just comment out lines 1599 and 1684 of llvm-gcc/config.gcc (the tmake_file=...) lines?

Now, it stoppes there:

...

Please follow the directions John provided and we'll try to get this resolved ASAP! Thanks for all of help, and sorry for the problems you've hit! :frowning:

-Chris