Paludis/AVR Crossdev

Note
I suggest using crossdev as intended for crossdev environments. Paludis seems to somewhat cope with it, i.e. it doesn’t conflict with it so one can just install stuff using it. There is no alternative script for it and maintaining this stuff by hand is PITA. Paludis specific fixes seems to still apply, though. Or maybe they even are not paludis specific, but who knows, that’s Gentoo for you.

End of note
This is a small HOWTO for installing an AVR toolchain with Paludis.

AVR is a 8-bit microcontroller.  You can compile programs for it with avr-gcc.

Paludis doesn't have a crossdev-like tool, but it is simple to make toolchains through.

Cross repository
First you need to create new repo for cross packages.

Next make directory /usr/local/cross-overlay and there cross-avr, make symlinks for needed packages and create profiles/repo_name and profiles/categories.

bashrc
You need to add this to /etc/paludis/bashrc:

if "${CATEGORY}" == "cross-avr" then if "${PN}" != "gcc" && "${PN}" != "binutils" then CBUILD=${CHOST} CHOST=avr CFLAGS="-Os" fi fi

Install packages
Now you need to install cross-avr/binutils, cross-avr/gcc and cross-avr/avr-libc.

Post-install
The ebuild for binutils does not properly create a required symlink. Try this command:

If you are affected by this bug, you will see the following error: output of previous command

To correct it, we need to create a symlink to the ldscripts directory.

For a 32-bit system:

For a 64-bit system:

Another command that was previously mention is as follows (for a 64-bit system). (Note, that this did NOT work for me with binutils-2.20 and gcc-4.3.4.)

Problems you might face
There seems to be some problems when having libmudflap enabled.

If you run into this error, just disable the use-flag with

Also, if you accidentally tried to install binutils with crossdev, there might be some cruft left which is not overwritten. What I did was look for leftover directories named avr* and deleted them. Then installing worked.

If you get errors like "Error: illegal opcode movw for mcu avr3" when building GCC, then you need to install cross-avr/binutils newer than 2.18.50.

Disabling nptl may also be necessary to avoid compile errors.

If you get "Link tests are not allowed after GCC_NO_EXECUTABLES while checking for symbol versioning support" while checking for symbol versioning support try to disable the fortran use flag.