Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
GreaseMonkey

Making a GCC cross-compiler

Recommended Posts

There's a couple of custom OC architectures floating around that could benefit from this.

Really, we need people to write software and we don't have in-mod C compilers yet.

I'll give you my setup (with a few distro-specific things stripped out):

../binutils-2.25.1/configure --target=mipsel-none-elf --disable-multilib --disable-nls --enable-lto
../gcc-5.3.0/configure --target=mipsel-none-elf --disable-nls --enable-languages=c,c++ --enable-lto
../newlib-2.3.0.20160104/configure --target=mipsel-none-elf --enable-lto
For ARM I use arm-none-eabi as my target, but arm-none-elf might work better.

If you're on Windows, you'll probably want to use Cygwin to build this stuff. MSYS might also work if you prefer that.

If you're on Linux or BSD, you shouldn't need anything fancy.

Basically, you'll want binutils, gcc, and newlib. You build them all "out of tree".

Step 1: Binutils

Here's my setup. Version numbers and targets will likely be different, although number of make threads may be the same.

 

mkdir xbinutils-mips
cd xbinutils-mips
../binutils-2.25.1/configure --target=mipsel-none-elf --disable-multilib --disable-nls --enable-lto
make -j8
sudo make install
cd ..
With a fairly beefy system it should build in under a minute.

That's the easy bit.

Step 2: GCC, part 1

You only want to build part of this. Look closely at the make commands.

 

mkdir xgcc-mips
cd xgcc-mips
../gcc-5.3.0/configure --target=mipsel-none-elf --disable-nls --enable-languages=c,c++ --enable-lto
make -j8 all-gcc
sudo make install-gcc
cd ..
If you got that working, good job. If not, please give me the info I need to know.

Step 3: newlib

This is a libc implementation designed for embedded software.

The general idea is that you compile something, find out what syscalls are missing, then implement those syscalls.

Enough about how to use it, let's actually build it.

 

mkdir xnewlib-mips
cd xnewlib-mips
../newlib-2.3.0.20160104/configure --target=mipsel-none-elf --enable-lto
make -j8
sudo make install
cd ..
Step 4: GCC, part 2

Oh, you thought you were done? WRONK.

By the way, DO NOT RECONFIGURE YOUR COMPILER.. Just do this:

cd xgcc-mips
make -j8
sudo make install
cd ..
EDIT: If you have C++ enabled (as you would if you just use those config lines), libstdc++ whinges about it not being supported or something like that. Here's the fix:

In gcc-*.*.*/libstdc++-v3/configure, find this line and comment it out like so:

 

    #as_fn_error "No support for this host/target combination." "$LINENO" 5
I found this at line 78194 (GCC 6.1.0), so please please please use your search function.

Step 5: Compile things

If you got through those 4 steps without any errors, find or make some stuff to compile and compile it. Whee!

It depends on the architecture that you are using. Feel free to bug the maintainers of said architectures on how to write software for their things.

Also, knowing how to write GNU linker scripts helps... at least some of the time: https://sourceware.org/binutils/docs/ld/index.html

Have fun!

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.