LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Custom GCC Targets (https://www.linuxquestions.org/questions/programming-9/custom-gcc-targets-617609/)

pnh73 01-31-2008 04:36 AM

Custom GCC Targets
 
Hi,

I am trying to find out how I can get GCC to compile for a target with an assembly instruction set that I define. I was wondering if anyone can point me in the right direction as to how to begin writing/modifying a target definition for GCC - so that it either output binaries for my target platform or simply an Assembly file for which I have already written an assembler.

Have done the standard googling (probably not quite searching for the correct thing) and haven't stumbled on anything so far... There must be something out there!

Thanks,
Paul

jailbait 02-01-2008 02:45 PM

Quote:

Originally Posted by pnh73 (Post 3040888)
Hi,

I am trying to find out how I can get GCC to compile for a target with an assembly instruction set that I define. I was wondering if anyone can point me in the right direction as to how to begin writing/modifying a target definition for GCC - so that it either output binaries for my target platform or simply an Assembly file for which I have already written an assembler.

Have done the standard googling (probably not quite searching for the correct thing) and haven't stumbled on anything so far... There must be something out there!

Thanks,
Paul

I am a little unsure of what you are asking but this may be the answer:

http://gcc.gnu.org/onlinedocs/gcc/Ex...l#Extended-Asm

----------------------
Steve Stites

osor 02-01-2008 04:53 PM

Quote:

Originally Posted by pnh73 (Post 3040888)
I am trying to find out how I can get GCC to compile for a target with an assembly instruction set that I define.

Do you mean a brand new architecture (that you made up)? Or is this a common architecture that just happens to be different from the one your host machine is running?

If you’re talking about the latter case, you would create what’s caused a cross-toolchain. A toolchain is the combination of an assembler, a linker, a compiler, and (optionally) a C library. In the normal linux world, the first two come from binutils and the second comes from gcc. A cross-toolchain is one that “executes” on a host system, but compiles for a target system (which is presumably different from the host system). All the architectures here (and maybe more) are supported by the latest binutils.

There are all sorts of guides for creating a cross-toolchain. Some examples off the top of my head are CLFS and GNUARM build instructions. There are probably countless others.

pnh73 02-02-2008 04:32 AM

It is to compile software for a new architecture that I have built a simulator for. It is based on MIPS architecture - just has some of the instructions missing.

Thanks for the help so far but any further pointers?

osor 02-02-2008 12:28 PM

Quote:

Originally Posted by pnh73 (Post 3043412)
It is to compile software for a new architecture that I have built a simulator for. It is based on MIPS architecture - just has some of the instructions missing.

You will need to patch the gcc backend for your architecture. Depending on how much your new architecture is based on MIPS, you might just add a machine description file to $GCC_ROOT/gcc/config/mips. If you want to get a feel for what these are like, you should read some of the existing ones as examples. Afterwards, you will be able to use “-march=mynewmipsarch” and compile code the same way you normally would. If you need more help, I suggest posting to the gcc-dev mailing list or similar.

If your new architecture is not binary-compatible with an existing MIPS arch, you will also need to patch binutils if you want to output binaries.

Edit: Here’s a link. All files ending in .md are machine descriptions.


All times are GMT -5. The time now is 11:20 PM.