public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Porting GCC on a new arch (cross-compilation)
@ 2009-02-24 13:02 Florent DEFAY
  2009-02-24 13:12 ` Andrew Haley
  0 siblings, 1 reply; 5+ messages in thread
From: Florent DEFAY @ 2009-02-24 13:02 UTC (permalink / raw)
  To: gcc-help

Hi,

I have to port GCC on a new arch. I'm working on an i686-pc-linux-gnu
machine so it is cross-compilation.

I read tutorials from IIT of Bombay. I read parts of GCC Internals.
I'm working with gcc-4.3.3 sources. The binutils are already installed
in /home/me/target/.

I began the port from scratch, I have done these steps :
- modify config.gcc and config.sub to recognize the new target
- create empty files $GCCSOURCES/gcc/config/target/target.h target.c target.md
- fill in target.h with macros, following GCC internals's list, adding
new macros until able to compile target-gcc.
 I configure gcc this way :
configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
--target=target --enable-langauges=c --prefix=/home/me/target/

When I run 'make', it finishes with this :

checking for suffix of object files... configure: error: cannot
compute suffix of object files: cannot compile
See `config.log' for more details.
make[1]: *** [configure-target-libgcc] Error 1
make[1]: Leaving directory `/home/me/gcc/build_target'
make: *** [all] Error 2

When I look at config.log in libgcc I find these errors :

configure:2398: /home/me/gcc/build_target/./gcc/xgcc
-B/home/me/gcc/build_target/./gcc/ -B/home/me/target/target/bin/
-B/home/me/target/target/lib/ -isystem /home/me/target/target/include
-isystem /home/me/target/target/sys-include -o conftest -O2 -g -g -O2
   conftest.c  >&5
xgcc: Internal error: Killed (program cc1)

configure:2567: checking for suffix of object files
configure:2588: /home/me/gcc/build_target/./gcc/xgcc
-B/home/me/gcc/build_target/./gcc/ -B/home/me/target/target/bin/
-B/home/me/target/target/lib/ -isystem /home/me/target/target/include
-isystem /home/me/target/target/sys-include -c -O2 -g -g -O2
conftest.c >&5
xgcc: Internal error: Killed (program cc1)

configure: failed program was:
| /* confdefs.h.  */
|
| #define PACKAGE_NAME "GNU C Runtime Library"
| #define PACKAGE_TARNAME "libgcc"
| #define PACKAGE_VERSION "1.0"
| #define PACKAGE_STRING "GNU C Runtime Library 1.0"
| #define PACKAGE_BUGREPORT ""
| /* end confdefs.h.  */
|
| int
| main ()
| {
|
|   ;
|   return 0;
| }
configure:2605: error: cannot compute suffix of object files: cannot compile

Is these errors about libgcc in my machine description ? Is libgcc
compulsory in a port ? If it is, how should I implement it ? If not,
how to configure to avoid these problems ?

Finally, I can run 'make install' and in /home/me/target/bin/ I have
my target-gcc built. But when I use it this way :
target-gcc -da -S emptyfile.c

the result is that it does nothing for a while and respond :
target-gcc: Internal error: Killed (program cc1)
Please submit a full bug report.
See <http://gcc.gnu.org/bugs.html> for instructions.

Maybe the target-gcc error and make errors are linked ? Are xgcc and
target-gcc equals ?

Thank you.

Florent

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Porting GCC on a new arch (cross-compilation)
  2009-02-24 13:02 Porting GCC on a new arch (cross-compilation) Florent DEFAY
@ 2009-02-24 13:12 ` Andrew Haley
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Haley @ 2009-02-24 13:12 UTC (permalink / raw)
  To: Florent DEFAY; +Cc: gcc-help

Florent DEFAY wrote:
> Hi,
> 
> I have to port GCC on a new arch. I'm working on an i686-pc-linux-gnu
> machine so it is cross-compilation.
> 
> I read tutorials from IIT of Bombay. I read parts of GCC Internals.
> I'm working with gcc-4.3.3 sources. The binutils are already installed
> in /home/me/target/.
> 
> I began the port from scratch, I have done these steps :
> - modify config.gcc and config.sub to recognize the new target
> - create empty files $GCCSOURCES/gcc/config/target/target.h target.c target.md
> - fill in target.h with macros, following GCC internals's list, adding
> new macros until able to compile target-gcc.
>  I configure gcc this way :
> configure --build=i686-pc-linux-gnu --host=i686-pc-linux-gnu
> --target=target --enable-langauges=c --prefix=/home/me/target/
> 
> When I run 'make', it finishes with this :
> 
> checking for suffix of object files... configure: error: cannot
> compute suffix of object files: cannot compile
> See `config.log' for more details.
> make[1]: *** [configure-target-libgcc] Error 1
> make[1]: Leaving directory `/home/me/gcc/build_target'
> make: *** [all] Error 2
> 
> When I look at config.log in libgcc I find these errors :
> 
> configure:2398: /home/me/gcc/build_target/./gcc/xgcc
> -B/home/me/gcc/build_target/./gcc/ -B/home/me/target/target/bin/
> -B/home/me/target/target/lib/ -isystem /home/me/target/target/include
> -isystem /home/me/target/target/sys-include -o conftest -O2 -g -g -O2
>    conftest.c  >&5
> xgcc: Internal error: Killed (program cc1)
> 
> configure:2567: checking for suffix of object files
> configure:2588: /home/me/gcc/build_target/./gcc/xgcc
> -B/home/me/gcc/build_target/./gcc/ -B/home/me/target/target/bin/
> -B/home/me/target/target/lib/ -isystem /home/me/target/target/include
> -isystem /home/me/target/target/sys-include -c -O2 -g -g -O2
> conftest.c >&5
> xgcc: Internal error: Killed (program cc1)
> 
> configure: failed program was:
> | /* confdefs.h.  */
> |
> | #define PACKAGE_NAME "GNU C Runtime Library"
> | #define PACKAGE_TARNAME "libgcc"
> | #define PACKAGE_VERSION "1.0"
> | #define PACKAGE_STRING "GNU C Runtime Library 1.0"
> | #define PACKAGE_BUGREPORT ""
> | /* end confdefs.h.  */
> |
> | int
> | main ()
> | {
> |
> |   ;
> |   return 0;
> | }
> configure:2605: error: cannot compute suffix of object files: cannot compile
> 
> Is these errors about libgcc in my machine description ? Is libgcc
> compulsory in a port ? If it is, how should I implement it ? If not,
> how to configure to avoid these problems ?

xgcc is your newly built cross-compiler.  It aborts because there is an error.

Now you have to debug your compiler with gdb.

> Finally, I can run 'make install' and in /home/me/target/bin/ I have
> my target-gcc built. But when I use it this way :
> target-gcc -da -S emptyfile.c
> 
> the result is that it does nothing for a while and respond :
> target-gcc: Internal error: Killed (program cc1)
> Please submit a full bug report.
> See <http://gcc.gnu.org/bugs.html> for instructions.
> 
> Maybe the target-gcc error and make errors are linked ? Are xgcc and
> target-gcc equals ?

xgcc is the target gcc.

Andrew.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Porting GCC on a new arch (cross-compilation)
  2009-02-25  8:58 ` Meena
@ 2009-02-25 23:49   ` Ian Lance Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 2009-02-25 23:49 UTC (permalink / raw)
  To: meena; +Cc: Florent DEFAY, gcc-help

Meena <meena@acmet.com> writes:

> To verify this, I have added the dummy machine description for 'move'
> instruction in the .md file as shown below:
>
> (define_expand "movsi"
>   [(set (match_operand:SI 0 "general_operand" "")
>         (match_operand:SI 1 "general_operand" ""))
>   ]
>   ""
>   ""
> )
>
> The above added machine description for 'move' instruction results into
> successful building of GCC i.e. cc1 executable is generated. The
> generated cc1 executable successfully compiled the empty
> void function.
>
> But why the move pattern is required is still not clear to me.

The compiler always requires a movMM pattern for every mode which can
appear in a register.  This is documented in the gcc internals manual.

    This class of patterns is special in several ways.  First of all,
    each of these names up to and including full word size _must_ be
    defined, because there is no other way to copy a datum from one
    place to another.  If there are patterns accepting operands in
    larger modes, movM must be defined for integer modes of those sizes.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Porting GCC on a new arch (cross-compilation)
  2009-02-25  8:41 Florent DEFAY
@ 2009-02-25  8:58 ` Meena
  2009-02-25 23:49   ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Meena @ 2009-02-25  8:58 UTC (permalink / raw)
  To: Florent DEFAY; +Cc: gcc-help

> Why is it running emit_move_... while the file is empty and there is
> nothing to compile ?
> 
> I did not include any move pattern in the md, I try to construct a
> minimal md like it is explained in IITB tutorials, should I ?
> 
> Maybe macros in target.h file are not defined well ? Which macros are
> concerned with these calls ?
> 
> 

I am also working on building GCC-4.3.2 for cross compiler for CISC
processor. I also referred the IITB tutorials.

I have also faced the problem as mentioned by you. 

I have debugged the segmentation fault occurred while compiling empty
void function using ddd (data display debugger). Segmentation fault
occured in the method simplify_subreg defined in simplify-rtx.c file. On
backtracing, it was found that the segmentation fault is occuring for
emit_move_instruction() function. It indicates that for GCC 4.3.2, we
need to provide machine description for 'move' instruction as well
for successful compilation of empty void function.

To verify this, I have added the dummy machine description for 'move'
instruction in the .md file as shown below:

(define_expand "movsi"
  [(set (match_operand:SI 0 "general_operand" "")
        (match_operand:SI 1 "general_operand" ""))
  ]
  ""
  ""
)

The above added machine description for 'move' instruction results into
successful building of GCC i.e. cc1 executable is generated. The
generated cc1 executable successfully compiled the empty
void function.

But why the move pattern is required is still not clear to me.

Thanks

Meena


On Wed, 2009-02-25 at 09:41 +0100, Florent DEFAY wrote:
> Hi,
> 
> I have to port GCC on a new arch. I'm working on an i686-pc-linux-gnu
> machine so it is cross-compilation.
> 
> I read tutorials from IIT of Bombay. I read parts of GCC Internals.
> I'm working with gcc-4.3.3 sources. The binutils are already installed
> in /home/me/target/.
> 
> I am now debugging my cc1 with GDB. I try to compile an empty file this way :
> gdb /home/me/target/libexec/gcc/target/4.3.3/cc1 -x command.gdb
> ...
> run -quiet -v a.c -quiet -dumpbase a.c -da -auxbase a -version -o a.s
> 
> where a.c is an empty file.
> 
> The problem is that cc1 comes in an infinite call loop, here is the back trace :
> (gdb) bt
> #0  0x081f473c in simplify_subreg (outermode=HImode, op=0xb7c525d0,
> innermode=HImode, byte=0) at ../../gcc-4.3.3/gcc/simplify-rtx.c:4930
> #1  0x081f5968 in simplify_gen_subreg (outermode=HImode,
> op=0xb7c525d0, innermode=HImode, byte=0) at
> ../../gcc-4.3.3/gcc/simplify-rtx.c:5225
> #2  0x08121405 in emit_move_multi_word (mode=HImode, x=0xb7c525d0,
> y=0xb7c525c0) at ../../gcc-4.3.3/gcc/expr.c:3270
> #3  0x08120eca in emit_move_insn (x=0xb7c525d0, y=0xb7c525c0) at
> ../../gcc-4.3.3/gcc/expr.c:3417
> #4  0x081214b6 in emit_move_multi_word (mode=HImode, x=0xb7c525d0,
> y=0xb7c525c0) at ../../gcc-4.3.3/gcc/expr.c:3295
> #5  0x08120eca in emit_move_insn (x=0xb7c525d0, y=0xb7c525c0) at
> ../../gcc-4.3.3/gcc/expr.c:3417
> #6  0x081214b6 in emit_move_multi_word (mode=HImode, x=0xb7c525d0,
> y=0xb7c525c0) at ../../gcc-4.3.3/gcc/expr.c:3295
> #7  0x08120eca in emit_move_insn (x=0xb7c525d0, y=0xb7c525c0) at
> ../../gcc-4.3.3/gcc/expr.c:3417
> 
> Why is it running emit_move_... while the file is empty and there is
> nothing to compile ?
> 
> I did not include any move pattern in the md, I try to construct a
> minimal md like it is explained in IITB tutorials, should I ?
> 
> Maybe macros in target.h file are not defined well ? Which macros are
> concerned with these calls ?
> 
> Thank you.
> 
> Florent

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Porting GCC on a new arch (cross-compilation)
@ 2009-02-25  8:41 Florent DEFAY
  2009-02-25  8:58 ` Meena
  0 siblings, 1 reply; 5+ messages in thread
From: Florent DEFAY @ 2009-02-25  8:41 UTC (permalink / raw)
  To: gcc-help

Hi,

I have to port GCC on a new arch. I'm working on an i686-pc-linux-gnu
machine so it is cross-compilation.

I read tutorials from IIT of Bombay. I read parts of GCC Internals.
I'm working with gcc-4.3.3 sources. The binutils are already installed
in /home/me/target/.

I am now debugging my cc1 with GDB. I try to compile an empty file this way :
gdb /home/me/target/libexec/gcc/target/4.3.3/cc1 -x command.gdb
...
run -quiet -v a.c -quiet -dumpbase a.c -da -auxbase a -version -o a.s

where a.c is an empty file.

The problem is that cc1 comes in an infinite call loop, here is the back trace :
(gdb) bt
#0  0x081f473c in simplify_subreg (outermode=HImode, op=0xb7c525d0,
innermode=HImode, byte=0) at ../../gcc-4.3.3/gcc/simplify-rtx.c:4930
#1  0x081f5968 in simplify_gen_subreg (outermode=HImode,
op=0xb7c525d0, innermode=HImode, byte=0) at
../../gcc-4.3.3/gcc/simplify-rtx.c:5225
#2  0x08121405 in emit_move_multi_word (mode=HImode, x=0xb7c525d0,
y=0xb7c525c0) at ../../gcc-4.3.3/gcc/expr.c:3270
#3  0x08120eca in emit_move_insn (x=0xb7c525d0, y=0xb7c525c0) at
../../gcc-4.3.3/gcc/expr.c:3417
#4  0x081214b6 in emit_move_multi_word (mode=HImode, x=0xb7c525d0,
y=0xb7c525c0) at ../../gcc-4.3.3/gcc/expr.c:3295
#5  0x08120eca in emit_move_insn (x=0xb7c525d0, y=0xb7c525c0) at
../../gcc-4.3.3/gcc/expr.c:3417
#6  0x081214b6 in emit_move_multi_word (mode=HImode, x=0xb7c525d0,
y=0xb7c525c0) at ../../gcc-4.3.3/gcc/expr.c:3295
#7  0x08120eca in emit_move_insn (x=0xb7c525d0, y=0xb7c525c0) at
../../gcc-4.3.3/gcc/expr.c:3417

Why is it running emit_move_... while the file is empty and there is
nothing to compile ?

I did not include any move pattern in the md, I try to construct a
minimal md like it is explained in IITB tutorials, should I ?

Maybe macros in target.h file are not defined well ? Which macros are
concerned with these calls ?

Thank you.

Florent

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-02-25 23:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-02-24 13:02 Porting GCC on a new arch (cross-compilation) Florent DEFAY
2009-02-24 13:12 ` Andrew Haley
2009-02-25  8:41 Florent DEFAY
2009-02-25  8:58 ` Meena
2009-02-25 23:49   ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).