LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-31-2008, 04:36 AM   #1
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Rep: Reputation: 30
Question 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
 
Old 02-01-2008, 02:45 PM   #2
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,531

Rep: Reputation: 178Reputation: 178
Quote:
Originally Posted by pnh73 View Post
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
 
Old 02-01-2008, 04:53 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by pnh73 View Post
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.
 
Old 02-02-2008, 04:32 AM   #4
pnh73
Member
 
Registered: Jul 2003
Location: Birmingham, UK
Distribution: Ubuntu,Debian
Posts: 381

Original Poster
Rep: Reputation: 30
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?
 
Old 02-02-2008, 12:28 PM   #5
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
Quote:
Originally Posted by pnh73 View Post
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.

Last edited by osor; 02-02-2008 at 12:30 PM. Reason: Add link
 
  


Reply

Tags
custom, development, gcc, target


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Passing gcc flags into custom kernel brodo Slackware 11 03-05-2012 10:09 AM
Creating custom headers to match a custom kernel utanja Debian 2 06-08-2007 03:15 PM
Custom kernel image on custom slack build using CUSS nykey Slackware 2 07-15-2006 03:05 AM
custom install cd base-config custom mithereal Debian 6 09-11-2005 03:48 PM
custom geforce video card--custom module? bandofmercy Linux - Hardware 3 10-14-2004 06:52 PM


All times are GMT -5. The time now is 05:49 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration