This is the mail archive of the crossgcc@cygnus.com mailing list for the crossgcc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: can't find crt1.o. egcs powerpc-linux cross-compile problem.


My understanding, which could be wrong, is that selecting powerpc-linux sets up the
defaults in the specs file to target a Linux OS running on a PowerPC box. You are
expected to copy the header files and runtime support libraries from the Linux
system to your host.

I think that your best approach is to define your own target. This is not as
difficult as it seems. Take a look at egcs/gcc/configure.in. You will see:

 powerpc-*-eabi*)
  tm_file=rs6000/eabi.h

 powerpc-*-linux-gnu*)
  tm_file=rs6000/linux.h

 powerpc-*-rtems*)
  tm_file=rs6000/rtems.h

Both linux.h and eabi.h start by including rs6000/sysv4.h, but then linux.h
redefines a number of constants.

#undef LIB_DEFAULT_SPEC
#define LIB_DEFAULT_SPEC "%(lib_linux)"

#undef STARTFILE_DEFAULT_SPEC
#define STARTFILE_DEFAULT_SPEC "%(startfile_linux)"

#undef ENDFILE_DEFAULT_SPEC
#define ENDFILE_DEFAULT_SPEC "%(endfile_linux)"

lib_linux should be "%{mnewlib: --start-group -llinux -lc --end-group } %{!mnewlib:
-lc }"

startfile_linux should be %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s}
%{!p:crt1.o%s}}} \
%{mnewlib: ecrti.o%s} \
%{!mnewlib: crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"

endfile_linux should be %{mnewlib: ecrtn.o%s} \
%{!mnewlib: %{!shared:crtend.o%s} %{shared:crtendS.o%s} crtn.o%s}"

I assume that your crt1.o file came from STARTFILE_DEFAULT_SPEC defined in linux.h.
You can check your specs file and see what it contains.

The eabi.h file does not redefine as many symbols. I would assume that the specs
file would then contain the defaults, which are probably empty. This almost
certainly means that you will not be able to link any apps to pass the configure
test.

What you should do is

1. Copy rtems.h to some other name that reflects your target.

2. In your new config file, include eabi.h, and then redefine a few constants,
including STARTFILE_DEFAULT_SPEC. This one points to a dummy crt0.o that allows
configure to test the cross-compiler successfully. You can make it point to a real
crt file. Redefine the LINK_START_DEFAULT_SPEC to -Ttext <start_address>, and any
other appropriate constants to set up the default compile and link flags.

3. Add your target to egcs/gcc/configure.in.

And voila, you have an egcs compiler that generates code for your target.

Note that the powerpc-rtems compiler is not special. It leaves many defaults blank,
except for the start file, which is a dummy. You could use it for your target. You
then have to explicitly specify where to find header files and libraries when you
build executables.

Hope this makes sense. Good luck.




Brendan Simon wrote:

> Charles Gauthier wrote:
>
> > WARNING: I do not really know what I am talking about! But here is my guess:
> >
> > crt1.o is on your PowerPC Linux box ;-)
>
> > It's a binary that came with the OS. You were expected to copy it to your host
> > machine. Presummably, the source code is available in the Linux source
> > distribution (don't ask me which one.)
>
> I am compiling for an MPC860 embedded system.  I do not have access to any kind
> of PowerPC Linux box such as an Apple PowerMac, etc.
>
> > My guess is based on the idea that -target=powerpc-linux picked up
> > egcs/gcc/config/rs6000/linux.h, which includes egcs/gcc/config/rs6000/sysv4.h.
> > This latter header file has:
> >
> > #ifndef STARTFILE_LINUX_SPEC
> > #define STARTFILE_LINUX_SPEC "\
> > %{!shared: %{pg:gcrt1.o%s} %{!pg:%{p:gcrt1.o%s} %{!p:crt1.o%s}}} \
> > %{mnewlib: ecrti.o%s} \
> > %{!mnewlib: crti.o%s %{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}}"
> > #endif
> >
> > which is were the attemp to link with crt1.o comes from.
> >
> > Hope this helps.
> >
> > BTW, you might be able to provide a stub to satisfy the linker during
> > configuration. Look at newlib/newlib/libc/sys/rtems/crt0.c for an idea.
> >
>
> _______________________________________________
> New CrossGCC FAQ: http://www.objsw.com/CrossGCC
> _______________________________________________
> To remove yourself from the crossgcc list, send
> mail to crossgcc-request@cygnus.com with the
> text 'unsubscribe' (without the quotes) in the
> body of the message.

--
Charles-Antoine Gauthier
Research Officer
Software Engineering Group
Institute for Information Technology
National Research Council of Canada
Ottawa, ON, Canada
K1A 0R6


_______________________________________________
New CrossGCC FAQ: http://www.objsw.com/CrossGCC
_______________________________________________
To remove yourself from the crossgcc list, send
mail to crossgcc-request@cygnus.com with the
text 'unsubscribe' (without the quotes) in the
body of the message.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]