Compiling llvm-gcc in linux/ppc

Hi everyone, I am using linux/ppc and after porting llvm's jit for this
architecture, I am currently trying to compile llvm-gcc on it.

I have gcc 4.1.1 and use llvm-gcc from cvs.

Compilation fails and the message is:

gcc -O2 -DIN_GCC
-DDEFAULT_TARGET_MACHINE=\"powerpc-unknown-linux-gnu\" -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic
-Wno-long-long -fno-common -DHAVE_CONFIG_H -o f771 f/bad.o f/bit.o
f/bld.o f/com.o f/data.o f/equiv.o f/expr.o f/global.o f/implic.o
f/info.o f/intrin.o f/lab.o f/lex.o f/malloc.o f/name.o f/parse.o
f/src.o f/st.o f/sta.o f/stb.o f/stc.o f/std.o f/ste.o f/storag.o
f/stp.o f/str.o f/sts.o f/stt.o f/stu.o f/stv.o f/stw.o f/symbol.o
f/target.o f/top.o f/type.o f/where.o main.o libbackend.a
../libiberty/libiberty.a
libbackend.a(llvm-out.o): In function `llvm_c_expand_body':
llvm-out.c:(.text+0x1c2): undefined reference to `lang_expand_function_end'
llvm-out.c:(.text+0x1c6): undefined reference to `lang_expand_function_end'
libbackend.a(llvm-out.o): In function `llvm_init_asm_output':
llvm-out.c:(.text+0x70e): undefined reference to `c_language'
llvm-out.c:(.text+0x716): undefined reference to `c_language'
llvm-out.c:(.text+0x7ba): undefined reference to `c_language'
llvm-out.c:(.text+0x7c2): undefined reference to `c_language'
llvm-out.c:(.text+0x7ea): undefined reference to `c_language'
libbackend.a(llvm-expand.o): In function `llvm_emit_local_var':
llvm-expand.c:(.text+0x16f48): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x16f60): undefined reference to
`stmts_are_full_exprs_p'
libbackend.a(llvm-expand.o): In function `genllvm_decl_stmt':
llvm-expand.c:(.text+0x203a6): undefined reference to
`lang_expand_decl_stmt'
llvm-expand.c:(.text+0x203aa): undefined reference to
`lang_expand_decl_stmt'
llvm-expand.c:(.text+0x204d8): undefined reference to `anon_aggr_type_p'
libbackend.a(llvm-expand.o): In function `llvm_expand_stmt':
llvm-expand.c:(.text+0x20c98): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x20ca4): undefined reference to `prep_stmt'
llvm-expand.c:(.text+0x20d64): undefined reference to `current_stmt_tree'
llvm-expand.c:(.text+0x20ea4): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x20ecc): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x210fc): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x21108): undefined reference to `prep_stmt'
llvm-expand.c:(.text+0x21118): undefined reference to `current_stmt_tree'
libbackend.a(llvm-expand.o): In function `genllvm_for_stmt':
llvm-expand.c:(.text+0x227e8): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x2283c): undefined reference to
`stmts_are_full_exprs_p'
libbackend.a(tree-inline.o): In function `copy_tree_r':
tree-inline.c:(.text+0x2e2): undefined reference to `statement_code_p'
tree-inline.c:(.text+0x2e6): undefined reference to `statement_code_p'
libbackend.a(tree-inline.o): In function `walk_tree':
tree-inline.c:(.text+0x436): undefined reference to `statement_code_p'
tree-inline.c:(.text+0x43a): undefined reference to `statement_code_p'
tree-inline.c:(.text+0x546): undefined reference to `statement_code_p'
libbackend.a(tree-inline.o):tree-inline.c:(.text+0x54a): more undefined
references to `statement_code_p' follow
libbackend.a(tree-inline.o): In function `copy_body_r':
tree-inline.c:(.text+0x2620): undefined reference to `build_stmt'
tree-inline.c:(.text+0x26d4): undefined reference to `build_stmt'
libbackend.a(tree-inline.o): In function `expand_call_inline':
tree-inline.c:(.text+0x37a0): undefined reference to `build_stmt'
tree-inline.c:(.text+0x3808): undefined reference to `build_stmt'
tree-inline.c:(.text+0x386c): undefined reference to `build_stmt'
libbackend.a(tree-inline.o):tree-inline.c:(.text+0x3c44): more undefined
references to `build_stmt' follow
libbackend.a(tree-inline.o): In function `expand_call_inline':
tree-inline.c:(.text+0x3d54): undefined reference to `decl_constant_value'
tree-inline.c:(.text+0x4108): undefined reference to `build_stmt'
tree-inline.c:(.text+0x4390): undefined reference to `build_stmt'
tree-inline.c:(.text+0x446c): undefined reference to `build_stmt'
tree-inline.c:(.text+0x44e4): undefined reference to `build_stmt'
tree-inline.c:(.text+0x4b78): undefined reference to `build_stmt'
libbackend.a(tree-inline.o):tree-inline.c:(.text+0x4b90): more undefined
references to `build_stmt' follow
collect2: ld returned 1 exit status
make[1]: *** [f771] Error 1
make[1]: Leaving directory `/home/varth/project/llvm-cvs/llvm-gcc/gcc'
make: *** [all-gcc] Error 2

If anyone has a clue...

Best,
Nicolas

Hi everyone, I am using linux/ppc and after porting llvm's jit for this
architecture, I am currently trying to compile llvm-gcc on it.

I have gcc 4.1.1 and use llvm-gcc from cvs.

This looks like you're compiling llvm-gcc3, which is quite dead by now. Please follow these instructions:
http://llvm.org/docs/CFEBuildInstrs.html

In particular, following the instructions in README.LLVM is very important. Building the fortran front-end, for example, won't work.

-Chris

Compilation fails and the message is:

gcc -O2 -DIN_GCC
-DDEFAULT_TARGET_MACHINE=\"powerpc-unknown-linux-gnu\" -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic
-Wno-long-long -fno-common -DHAVE_CONFIG_H -o f771 f/bad.o f/bit.o
f/bld.o f/com.o f/data.o f/equiv.o f/expr.o f/global.o f/implic.o
f/info.o f/intrin.o f/lab.o f/lex.o f/malloc.o f/name.o f/parse.o
f/src.o f/st.o f/sta.o f/stb.o f/stc.o f/std.o f/ste.o f/storag.o
f/stp.o f/str.o f/sts.o f/stt.o f/stu.o f/stv.o f/stw.o f/symbol.o
f/target.o f/top.o f/type.o f/where.o main.o libbackend.a
../libiberty/libiberty.a
libbackend.a(llvm-out.o): In function `llvm_c_expand_body':
llvm-out.c:(.text+0x1c2): undefined reference to `lang_expand_function_end'
llvm-out.c:(.text+0x1c6): undefined reference to `lang_expand_function_end'
libbackend.a(llvm-out.o): In function `llvm_init_asm_output':
llvm-out.c:(.text+0x70e): undefined reference to `c_language'
llvm-out.c:(.text+0x716): undefined reference to `c_language'
llvm-out.c:(.text+0x7ba): undefined reference to `c_language'
llvm-out.c:(.text+0x7c2): undefined reference to `c_language'
llvm-out.c:(.text+0x7ea): undefined reference to `c_language'
libbackend.a(llvm-expand.o): In function `llvm_emit_local_var':
llvm-expand.c:(.text+0x16f48): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x16f60): undefined reference to
`stmts_are_full_exprs_p'
libbackend.a(llvm-expand.o): In function `genllvm_decl_stmt':
llvm-expand.c:(.text+0x203a6): undefined reference to
`lang_expand_decl_stmt'
llvm-expand.c:(.text+0x203aa): undefined reference to
`lang_expand_decl_stmt'
llvm-expand.c:(.text+0x204d8): undefined reference to `anon_aggr_type_p'
libbackend.a(llvm-expand.o): In function `llvm_expand_stmt':
llvm-expand.c:(.text+0x20c98): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x20ca4): undefined reference to `prep_stmt'
llvm-expand.c:(.text+0x20d64): undefined reference to `current_stmt_tree'
llvm-expand.c:(.text+0x20ea4): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x20ecc): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x210fc): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x21108): undefined reference to `prep_stmt'
llvm-expand.c:(.text+0x21118): undefined reference to `current_stmt_tree'
libbackend.a(llvm-expand.o): In function `genllvm_for_stmt':
llvm-expand.c:(.text+0x227e8): undefined reference to
`stmts_are_full_exprs_p'
llvm-expand.c:(.text+0x2283c): undefined reference to
`stmts_are_full_exprs_p'
libbackend.a(tree-inline.o): In function `copy_tree_r':
tree-inline.c:(.text+0x2e2): undefined reference to `statement_code_p'
tree-inline.c:(.text+0x2e6): undefined reference to `statement_code_p'
libbackend.a(tree-inline.o): In function `walk_tree':
tree-inline.c:(.text+0x436): undefined reference to `statement_code_p'
tree-inline.c:(.text+0x43a): undefined reference to `statement_code_p'
tree-inline.c:(.text+0x546): undefined reference to `statement_code_p'
libbackend.a(tree-inline.o):tree-inline.c:(.text+0x54a): more undefined
references to `statement_code_p' follow
libbackend.a(tree-inline.o): In function `copy_body_r':
tree-inline.c:(.text+0x2620): undefined reference to `build_stmt'
tree-inline.c:(.text+0x26d4): undefined reference to `build_stmt'
libbackend.a(tree-inline.o): In function `expand_call_inline':
tree-inline.c:(.text+0x37a0): undefined reference to `build_stmt'
tree-inline.c:(.text+0x3808): undefined reference to `build_stmt'
tree-inline.c:(.text+0x386c): undefined reference to `build_stmt'
libbackend.a(tree-inline.o):tree-inline.c:(.text+0x3c44): more undefined
references to `build_stmt' follow
libbackend.a(tree-inline.o): In function `expand_call_inline':
tree-inline.c:(.text+0x3d54): undefined reference to `decl_constant_value'
tree-inline.c:(.text+0x4108): undefined reference to `build_stmt'
tree-inline.c:(.text+0x4390): undefined reference to `build_stmt'
tree-inline.c:(.text+0x446c): undefined reference to `build_stmt'
tree-inline.c:(.text+0x44e4): undefined reference to `build_stmt'
tree-inline.c:(.text+0x4b78): undefined reference to `build_stmt'
libbackend.a(tree-inline.o):tree-inline.c:(.text+0x4b90): more undefined
references to `build_stmt' follow
collect2: ld returned 1 exit status
make[1]: *** [f771] Error 1
make[1]: Leaving directory `/home/varth/project/llvm-cvs/llvm-gcc/gcc'
make: *** [all-gcc] Error 2

If anyone has a clue...

Best,
Nicolas
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-Chris

Chris Lattner wrote:

This looks like you're compiling llvm-gcc3, which is quite dead by now.
Please follow these instructions:
http://llvm.org/docs/CFEBuildInstrs.html

Oups, sorry for that. Here is the error message with the latest svn version:

gcc -c -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros
-Wold-style-definition -DHAVE_CONFIG_H -DENABLE_LLVM
-D__STDC_LIMIT_MACROS -I. -I. -I../../trunk/gcc -I../../trunk/gcc/.
-I../../trunk/gcc/../include -I../../trunk/gcc/../libcpp/include
-I/home/varth/project/llvm-cvs/llvm/include
-I/usr/local/home/varth/project/llvm-cvs/llvm/include
../../trunk/gcc/stor-layout.c -o stor-layout.o
../../trunk/gcc/stor-layout.c:450:25: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c: In function 'layout_decl':
../../trunk/gcc/stor-layout.c:449: error: 'ADJUST_FIELD_ALIGN'
undeclared (first use in this function)
../../trunk/gcc/stor-layout.c:449: error: (Each undeclared identifier is
reported only once
../../trunk/gcc/stor-layout.c:449: error: for each function it appears in.)
../../trunk/gcc/stor-layout.c:711:43: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c: In function 'update_alignment_for_field':
../../trunk/gcc/stor-layout.c:708: error: 'ADJUST_FIELD_ALIGN'
undeclared (first use in this function)
../../trunk/gcc/stor-layout.c:760:41: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c:994:44: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c: In function 'place_field':
../../trunk/gcc/stor-layout.c:991: error: 'ADJUST_FIELD_ALIGN'
undeclared (first use in this function)
../../trunk/gcc/stor-layout.c:1031:44: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
make[1]: *** [stor-layout.o] Error 1
make[1]: Leaving directory `/home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc'
make: *** [all-gcc] Error 2

I looked a bit at the source, and the gcc/config/darwin.h declares a
ADJUST_FIELD_ALIGN with two arguments whereas all other back-ends that
declare ADJUST_FIELD_ALIGN have only two arguments. And it seems that
stor-layout.c assumes that if we have ADJUST_FIELD_ALIGN defined, then
we're on darwin.

Nicolas

OK, seems like there were unused TARGET_MACHO macros that would protect
these errors from happening. I made some modifications that add #if
TARGET_MACHO.

Now the error is a linkage problem:

/home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc/xgcc: symbol lookup
error: /home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc/libgcc_s.so.1:
undefined symbol: __thenan_sf

And even if I force the definition of thenan_sf with
const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };

I still get the error.

Cheers,
Nicolas

Nicolas Geoffray wrote:

OK, seems like there were unused TARGET_MACHO macros that would protect
these errors from happening. I made some modifications that add #if
TARGET_MACHO.

ok. If you send a patch in that adds these, I would be happy to apply it.

Now the error is a linkage problem:

/home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc/xgcc: symbol lookup
error: /home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc/libgcc_s.so.1:
undefined symbol: __thenan_sf

And even if I force the definition of thenan_sf with
const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };

I still get the error.

Unfortunately, I really don't know. I assume this is supposed to be coming from gcc/config/fp-bit.c, but I don't know how any of this stuff works.

-Chris

Cheers,
Nicolas

Nicolas Geoffray wrote:

Chris Lattner wrote:

This looks like you're compiling llvm-gcc3, which is quite dead by now.
Please follow these instructions:
http://llvm.org/docs/CFEBuildInstrs.html

Oups, sorry for that. Here is the error message with the latest svn version:

gcc -c -g -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes
-Wmissing-prototypes -pedantic -Wno-long-long -Wno-variadic-macros
-Wold-style-definition -DHAVE_CONFIG_H -DENABLE_LLVM
-D__STDC_LIMIT_MACROS -I. -I. -I../../trunk/gcc -I../../trunk/gcc/.
-I../../trunk/gcc/../include -I../../trunk/gcc/../libcpp/include
-I/home/varth/project/llvm-cvs/llvm/include
-I/usr/local/home/varth/project/llvm-cvs/llvm/include
../../trunk/gcc/stor-layout.c -o stor-layout.o
../../trunk/gcc/stor-layout.c:450:25: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c: In function 'layout_decl':
../../trunk/gcc/stor-layout.c:449: error: 'ADJUST_FIELD_ALIGN'
undeclared (first use in this function)
../../trunk/gcc/stor-layout.c:449: error: (Each undeclared identifier is
reported only once
../../trunk/gcc/stor-layout.c:449: error: for each function it appears in.)
../../trunk/gcc/stor-layout.c:711:43: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c: In function 'update_alignment_for_field':
../../trunk/gcc/stor-layout.c:708: error: 'ADJUST_FIELD_ALIGN'
undeclared (first use in this function)
../../trunk/gcc/stor-layout.c:760:41: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c:994:44: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
../../trunk/gcc/stor-layout.c: In function 'place_field':
../../trunk/gcc/stor-layout.c:991: error: 'ADJUST_FIELD_ALIGN'
undeclared (first use in this function)
../../trunk/gcc/stor-layout.c:1031:44: error: macro "ADJUST_FIELD_ALIGN"
passed 3 arguments, but takes just 2
make[1]: *** [stor-layout.o] Error 1
make[1]: Leaving directory `/home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc'
make: *** [all-gcc] Error 2

I looked a bit at the source, and the gcc/config/darwin.h declares a
ADJUST_FIELD_ALIGN with two arguments whereas all other back-ends that
declare ADJUST_FIELD_ALIGN have only two arguments. And it seems that
stor-layout.c assumes that if we have ADJUST_FIELD_ALIGN defined, then
we're on darwin.

Nicolas
_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

_______________________________________________
LLVM Developers mailing list
LLVMdev@cs.uiuc.edu http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev

-Chris

Hi Chris,

Chris Lattner wrote:

  

OK, seems like there were unused TARGET_MACHO macros that would protect
these errors from happening. I made some modifications that add #if
TARGET_MACHO.
    
ok. If you send a patch in that adds these, I would be happy to apply it.

I will when I'll figure out why it sometimes doesn't work to add these
and I have
to remove the specific instructions from the file (even an #if 0 does
not work -- maybe
there's a script somewhere that misbehaves)

Now the error is a linkage problem:

/home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc/xgcc: symbol lookup
error: /home/varth/project/llvm-cvs/llvm-gcc4/obj/gcc/libgcc_s.so.1:
undefined symbol: __thenan_sf

And even if I force the definition of thenan_sf with
const fp_number_type __thenan_sf = { CLASS_SNAN, 0, 0, {(fractype) 0} };

I still get the error.
    
Unfortunately, I really don't know. I assume this is supposed to be
coming from gcc/config/fp-bit.c, but I don't know how any of this stuff
works.

Do you know who did the APPLE_LOCAL changes? Maybe he can help.

Nicolas

I will when I'll figure out why it sometimes doesn't work to add these and I have to remove the specific instructions from the file (even an #if 0 does not work -- maybe there's a script somewhere that misbehaves)

Ok.

Unfortunately, I really don't know. I assume this is supposed to be
coming from gcc/config/fp-bit.c, but I don't know how any of this stuff
works.

Do you know who did the APPLE_LOCAL changes? Maybe he can help.

If you point out a specific file/line# that is causing you grief, I can try to find out :slight_smile:

-Chris

Chris Lattner wrote:

Do you know who did the APPLE_LOCAL changes? Maybe he can help.
    
If you point out a specific file/line# that is causing you grief, I can
try to find out :slight_smile:

Hard to tell. I think it has something to do with fp-bit.c
(or its generated equivalent) dp-bit.c not being compiled or linked with
xgcc (I forced
the definition of thenan_sf in the fp-bit.c file). So I figure
it's a Makefile somewhere that must misbehave.