[Nix-dev] RTEMS cross compiler

Ben Franksen ben.franksen at online.de
Fri Jul 11 22:48:40 CEST 2014


Benjamin Franksen wrote:
> I want to package the tool chain for RTEMS 4.9. The sources are at
> ftp://www.rtems.org/pub/rtems/SOURCES/4.9. The gcc version is 4.3.2 plus a
> few RTEMS specific patches. I successfully packaged the corresponding
> binutils. I can also build and install the cross gcc. However, when using
> the resulting gcc as a "driver" e.g. to compile a single .c file to an
> executable, I get errors that suggest that it tries to call the 'as'
> (assembler, part of binutils) for the host system, not the cross version.
> Specifically,
> 
> franksen at tiber: ~/tmp > powerpc-rtems4.9-gcc -mcpu=603e -Dmpc603e
> -Dppc603e -O2 -g -mmultiple -mstring -mstrict-align conftest.c
> as: unrecognized option '-mppc'
> 
> I have been banging my head against this problem with no success, so now I
> am asking for help here, hoping that you guys have more experience with
> building gcc with nix and can give me a hint how to get this to work.

For the record: I found a solution. It seems that gcc insists on finding the 
binutils under its own prefix. This can be overridden on the command line 
with the -B option (I checked that this works), but there is no way to 
configure gcc to use a different path by default. So what I did was to link 
the directory under binutils that contains the tools (with their canonic 
names e.g. as, ld, ...) to where the running instance of gcc expects them:

  preConfigure = ''
    #...other stuff...
    mkdir -p $out/$target
    ln -s $targetArchBinutils/$target/bin $out/$target
  '';

(where target = "${targetArch}-${targetOs}")

I don't know if this is the 'idiomatic' way to solve such problems in Nix, 
but it seems to work.

Cheers
Ben
-- 
"Make it so they have to reboot after every typo." -- Scott Adams




More information about the nix-dev mailing list