This is the mail archive of the crossgcc@sourceware.cygnus.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more infromation.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Hi there, Here's a first draft of a document I'm writing about cross compiling using gnu tools, it's far from being complete and it might contains errors. I've taken the example of generating a cross compiler for m68k on a intel (i586) machine. But a lot of these might also be applied to any target/host configuration, so one might want to look at it before posting on the mailing list! For any suggestions, improvements corrections or comments you can contact me, I'll try to answer questions to the best of my knowledge and find the most accurate information possible but please be aware that I'm not an expert, I'm just trying to group the knowledge available together in the hope that it will help people. Thanks <<gccm68k.txt>>
The following describe the build of binutils, gcc, and newlib for m68k architecture. 1.0 What you need: - binutils 2.9.1 - newlib 1.8.2 - gcc 2.95.2 2.0 How to do it The following is based on my own experience with the help of several people on the cross gcc mailing list in the hope it will help you. We will build a C & C++ cross compiler for a m68k architecture on the "bare metal" which means no OS and for ELF object format. 2.1 Directory structure I'll assume that your directory structure is as following, it is not really important but I need a starting point /usr/local/src --------------gcc-2.95-2 --------------binutils-2.9.1 --------------newlib-1.8.2 you'll have to create --------------m68kbinutils --------------m68kgcc --------------m68knewlib 2.1 Binutils Here are the steps for building binutils: - go to the m68kbinutils directory - type the following: ../binutils-2.9.1/configure --target=m68k-elf - make - make install (probably as root!) Generally binutils is the simplest package to install and configure. Personnally I never had difficulties with this one. 2.2 gcc Here's a bit of explanation: In order to build a cross compiler, gcc needs the TARGET header files. There are several ways to provide them but I'll describe that I used to, and it works for me. go into the /usr/local/m68k-elf directory (if you didn't use any other compilation switch during building of binutils you should see this directory with the following contents) bin lib you'll need to create a symlink like this (in the /usr/local/m68k-elf directory) ln -s /usr/local/src/newlib-1.8.2/newlib/libc/include include so just to make things clear you sould see something like /usr/local/m68k-elf -------------------lib -------------------include -------------------lib in order to do that you'll probably need to be root - go to the m68kgcc directory - ../gcc-2.95-2/configure --target=m68k-elf --enable-languages=c,c++ - make It will compile up to a certain point where it will spit out some errors about not finding some atexit symbol don't worry its totally normal. Here's the explanation for this: At this point, the cross compiler is actually working, so if all you need is a c and c++ compiler you already have it, congratulation. But be if you need the STL keep reading. In order to build, libiberty, libio and libstdc++ you need a WORKING compiler. The configure script definition of a working compiler is one that can build executable. And in order to build executable you must have some startup files (crt0.o and the like). How to get those? You're lucky our friends at Cygnus manage to build something which is called libgloss. This is a collection of startup files and board support libraries. As you might have guess reading the previous lines we'll need to build newlib but before that there's a couple of operation to do. as root (probably) make install in the m68kgcc directory don't worry about errors at this point go to the /usr/local/m68k-elf/ and remove the symlink we've put earlier. now in the /usr/local/bin directory you should see plenty of m68k- files including gcc g++ c++ and the rest. 2.3 newlib newlib is pretty straightforward to build and install cd m68knewlib ../newlib-1.8.2/configure --target=m68k-elf make (as root) make install 2.4 going back to gcc... cd m68kgcc you'll have two files to edit gcc/specs and ../gcc-2.95.2/gcc/libgcc1-test.c 2.4.1 modify the spec file Browse through the file to find the link section and modify it to look like this one. BE VERY CAREFUL about not changing the indentation of number of new lines, the layout expected for this file is very strict ------ snip ---------- *link: -m m68kelf -T bcc.ld%s *lib: -lc -lbcc -lc *libgcc: -lgcc *startfile: ------ snip ---------- the startfile section should be empty or you'll get doubly defined symbol (which is quite annoying, trust me...) For those interested in the bcc.ld and lbcc. The former is a linker script which you can find in /usr/local/m68k-elf/lib and the ladder is a kind of a board support library in the same directory. 2.4.2 ../gcc-2.95.2/gcc/libgcc1-test.c Toward the end of the file you must modify the file to look like this (yes yes modify gcc source...) ------ snip ---------- /* Provide functions that might be needed by soft-float emulation routines. */ void memcpy() {} #if 0 void start() {} void _start() {} void __start() {} void mainCRTStartup() {} #else main(void) { main_without__main (); } #endif ------ snip ---------- Once this is done you're almost there... don't get discouraged go back to the m68kgcc directory and type make you shouldn't get anymore errors and go til the end of the compilation process at which point you'll be able to type make install 3.0 If it fails... again! 1) Don't panic 2) If you're getting a no target error... go to this directory and look at the config.log file 3) If .h files not found either the newlib is not installed or the symlink has not been created properly 4) If you're experiencing errors make sure you're using the right specs file you can use the -v switch to gcc (xgcc) to know about that 5) RTFM on the 2.96 manual can help you a lot otherwise it is very instructive 6) There's plenty of knowledgeable people to ask on the crossgcc mailing list if you're still stuck! 4.0 Many thanks To Kai Ruottu and Dave Moore and to all of those who're trying to help people with the cross developpement environnement!!!
------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sourceware.cygnus.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |