Alternate GCC Toolchain

Hi all,

Just an update as everyone starts thinking about the 2013 FRC season, the patches that I and several others wrote have now been officially integrated into the GCC mainline.

Now, having undergone the sad ordeal of graduating from high school and FRC last year, I am faced with not being able to test anything beyond compile time. So, I leave it open to everyone else to test out :smiley:

Between college and working with the GCC devs I haven’t had time to update the whole buildsystem yet, but EXPECT TO SEE BINARY PACKAGES SOON :smiley:

For those of you who can’t wait, here’s how you can build GCC for vxworks on your very own:

NOTE: Lines starting with # must be run as root, and you need to have gcc, flex, bison, libmpfr-dev, libgmp-dev, libmpc-dev (or whatever the equivalents are for your distro) installed

NOTE2: If someone wants to mirror the snapshot of GCC that would be awesome as github has to dynamically regenerate it every time someone downloads it (though this is still faster than checking out on cvs…). I’d do it but my school doesn’t like people tunneling out of their network…

# mkdir -p /usr/powerpc-wrs-vxworks/wind_base
# mkdir -p /usr/powerpc-wrs-vxworks/include
# echo 'export WIND_BASE=/usr/powerpc-wrs-vxworks/wind_base' >> /etc/profile
$ source /etc/profile
$ wget
$ wget
$ wget
$ unzip
$ tar -jxf binutils-2.22.tar.bz2
$ unzip
# mkdir -p $WIND_BASE/target
# cp -r gccdist/WindRiver/vxworks-6.3/host/. $WIND_BASE/host
# ln -s /usr/powerpc-wrs-vxworks/sys-include $WIND_BASE/target/h
# cp -r gccdist/WindRiver/vxworks-6.3/target/h/. /usr/powerpc-wrs-vxworks/sys-include
# ln -s sys-include/wrn/coreip /usr/powerpc-wrs-vxworks/include
$ mkdir binutils-build
$ cd binutils-build
$ ../binutils-2.22/configure --prefix=/usr --target=powerpc-wrs-vxworks --disable-nls
$ make -j4
# make install
$ cd ..
$ mkdir gcc-build
$ cd gcc-build
$ ../gcc-master/configure --prefix=/usr --target=powerpc-wrs-vxworks --with-gnu-as --with-gnu-ld --with-headers --disable-shared --disable-libssp --disable-multilib --with-float=hard --enable-languages=c,c++ --enable-threads=vxworks --without-gconv --disable-libgomp --disable-nls --disable-libmudflap --with-cpu-PPC603 --disable-symvers
$ make -j4
# make install


That was a mouthful. This is why I will work to get those binaries out to you all soon :). Let me know if I made a typo. I haven’t tested this as rigorously as I usually do for my builds, and I haven’t rebuilt binutils in a while, but I wanted to get this out to you all early so that I could see if there’s any runtime issues people run into.


You can manually hack a UCPP makefile, OR, you can use cmake. Links:

and, to build a better WPILib (I mean, they had to make the compiler’s optimizations better since 3.x :D) and ensure there are no symbol/ABI conflicts, go here:

I submitted the necessary patches to firstforge at the end of last season, but they have a pretty closed development model… Also, I’m not sure how much they are into supporting unofficial toolchains, though technically all of the changes are necessary for standards compliance as old GCC accepts stuff it shouldn’t… but I digress.

Lobby FIRST/WRS/NI to use a compiler that isn’t ten years old!


Also, a very broken build of fortran can be made by using --enable-languages=c,c++,fortran. However, this misconfigures itself horribly, so you’ll need to go in and edit the config.h file by hand bleh. Go support is also in the works. However, at least for me, these are both lower priorities unless people here say they’re really interested in these, as they aren’t currently used by FRC. Also know, that the best way to get this done faster if you care is to do it yourself :slight_smile: Just share with everyone else too!

The entire C++11 standard library (as it is/will be known by GCC 4.8 - freeze should be this week, so no major changes) should work. There might be one minor bug in thread-specific data corner cases, but other than that, please test all of the new features you can think of! And then use them so we don’t have spaghetti code! TEST TEST TEST TEST PLEASE!

Why ? Having a C compiler that is ten years old should be solid, reliable, and mature.

Just like all those old mentors that volunteer for FIRST !!

Why doesn’t everyone just use 6 wheel tank drive, which is arguably more solid and reliable?

Same reason not everyone uses C for every task. :rolleyes:

  1. Support for other languages
  2. Native builds on different host OSs

Yeah, I can’t even get it to compile. It looks like it fails with:

/bin/bash: MULTIDIR: command not found

which I googled and found nothing conclusive. Is there a way to fix this?
Would it be possible to just zip the /usr/powerpc-wrs-vxworks folder so I wouldn’t have to worry about it?

make.txt (7.64 KB)

make.txt (7.64 KB)

Why do we even bother innovating anyway?

In all seriousness, because it runs natively on linux, supports c++11 and has much better compliance with c++03, has better optimizations, runs faster (AFAIK), and because IT’S SHINY AND NEW!

Also, WRT to the MULTIDIR thing, that’s not a fatal error. Double-check that /usr/powerpc-wrs-vxworks/include is a symlink to sys-include/wrn/coreip. Make sure that /usr/powerpc-wrs-vxworks/sys-include contains files that make sense (vxWorks.h, stdio.h, etc.)

I was typing those commands into a post box, not into a terminal, so it might have a typo…

Hey, I’m just asking. I like shiny and new too. I’m all for innovation.

What I’m curious in learning is why so much embedded C still uses the 3.4.4 version, not the 4.xx series of gcc. That said, what are the risks of using 4.x versus 3.4.4 in an embedded system.

I know there are substantial language compliance differences and I’m curious as to how that drills down the particular FRC application we deal with.

I’m all for innovation. I just want to know what the innovation is. That’s all.

And thanks, I’m glad to see the project…

Checked it again. Still not able to compile. Heres what I get:

/bin/bash: MULTIDIR: command not found
/bin/bash: MULTIDIR: command not found
/home/alex/gcc-build/./gcc/as: 87: exec: /usr/powerpc-wrs-vxworks/bin/as: not found
make[2]: *** [tramp_s.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/home/alex/gcc-build/./gcc/as: 87: exec: /usr/powerpc-wrs-vxworks/bin/as: not found
make[2]: *** [enable-execute-stack.o] Error 1
/home/alex/gcc-build/./gcc/as: 87: exec: /usr/powerpc-wrs-vxworks/bin/as: not found
make[2]: *** [eabi_s.o] Error 1
/home/alex/gcc-build/./gcc/as: 87: exec: /usr/powerpc-wrs-vxworks/bin/as: not found
make[2]: *** [unwind-dw2.o] Error 1
make[2]: Leaving directory `/home/alex/gcc-build/powerpc-wrs-vxworks/libgcc'
make[1]: *** [all-target-libgcc] Error 2
make[1]: Leaving directory `/home/alex/gcc-build'
make: *** [all] Error 2

Which makes sense because /usr/powerpc-wrs-vxworks/bin/as dosen’t exist… Not sure if it’s supposed to?
Also included an overview of the powerpc-wrs-vxworks folder.

powerpc-wrs-vxworks.txt (38.5 KB)

powerpc-wrs-vxworks.txt (38.5 KB)

I can’t answer for the risks associated with using a new GCC. However, I can say that some of the standard library and language compliance benefits are very interesting and useful, particularly C++11 features. Additionally, should one discover any issues, the developers are much more likely to help you with a modern, developed version.

It is to both VxWorks’ and GCC’s benefit to keep compatibility current and not let it bitrot.

Again, a major motivating factor is to be able to get a native linux version. IN MY EXPERIENCE, the whole development process is smoother on linux, and not using the giant hulking behemoth that eclipse (and thus workbench) is makes development go much more quickly. CMake also does a better job of dependency tracking than the Makefiles that are generated by workbench or UCPP (no offense of course to the people who have been working on UCPP, which is an awesome project).

It should exist. Did your build of binutils succeed, and did you make install successfully? That should have created a bunch of stuff in /usr/powerpc-wrs-vxworks/bin.

Alright, re-ran the binutils build and now it looks like it builds alright. I went ahead and installed too. I ran cmake on wpilib and get this error:

  cannot find -lstdc++

OK, I made a quick mistake. Re-run configure for GCC with the argument --enable-libstdcxx, then run make and make install again, and you should be good.

I can’t seem to edit my original post anymore, so please do this or you will get errors…

Ok, now it get this:

/usr/bin/powerpc-wrs-vxworks-c++ -nostdlib -r -Wl,-X -static
  CMakeFiles/cmTryCompileExec2792526235.dir/testCXXCompiler.cxx.obj -o
  cmTryCompileExec2792526235_PartialImage.out -lsupc++ -lstdc++ -lgcc

  /usr/local/powerpc-wrs-vxworks/ powerpc-wrs-vxworks-nm

  Error running link command: No such file or directory


So I did that, now i get:

  cannot open linker script file
  No such file or directory

  collect2: error: ld returned 1 exit status

  make[1]: *** [cmTryCompileExec1263306447] Error 1

That’s a known bug. Look in the old thread, make the symlinks described, and you should be good.

I haven’t been updating the toolchain file as I’ve been very busy working with the GCC devs to get everything working on VxWorks out-of-the-box. Again, this is still experimental until I get everything updated and get some binary packages out. I wanted to give the adventurous a chance to play around with it in advance though :slight_smile:

Alright! After a few more symlinks, cmake and make ran without incident. Build of wpilib succeeded. I’ll test it on our robot tomorrow and see if it works. Thanks for all the hard work!

Robot code build completes but gives this error:

alex@alex-U46SV:~/robot$ make
[100%] Built target FRC_UserProgram
alex@alex-U46SV:~/robot$ make clean
alex@alex-U46SV:~/robot$ make
[100%] Building CXX object CMakeFiles/FRC_UserProgram.dir/src/MyRobot.cpp.obj
Linking CXX executable bin/FRC_UserProgram.out
powerpc-wrs-vxworks-nm: '/usr/local/lib/gcc/powerpc-wrs-vxworks/4.7.2/libgcc.a': No such file
[100%] Built target FRC_UserProgram

When I deploy, I get nothing but “relocation value does not fit in 24 bits”

That’s probably due to the toolchain expecting a different version in GCC. Try and symlink /usr/local/lib/gcc/powerpc-wrs-vxworks/4.7.2 to 4.8.0 to get rid of the version conflict for now. Hopefully this fixes your “24 byte” issue. If that doesn’t work, I’d double check to make sure that the link script is functioning properly.

Sorry it’s been untested, but I literally posted this as soon as I got word that the patches had made it in. I was excited…

Also, past compile time I can’t help you unless someone happened to send me a cRIO :frowning: There’s several other good people on the forums who can help though. And google.

I also deployed code with a hacked gcc 4.7.1 last year and it worked flawlessly, so it is possible to get this working…

I’ll be testing this on the cRIO as soon as possible. Also, now that rbmj has pulled in my changes to the cmake toolchain, the symlinks should no longer be necessary. At least with the hacked version of 4.7.2, I was able to compile with no symlinks or anything. I didn’t get the libgcc error either.

Ok after looking over your post again, I found the issue. You’ve installed gcc with the prefix /usr, whereas the toolchain file for cmake is expecting you to have installed to /usr/local. Personally, I would reinstall gcc to /usr/local because that’s where you’re supposed to put things that you’ve installed from source, but you could also fix the problem by making the following edits to the vxworks_toolchain.cmake file.

-set(TOOLCHAIN_PREFIX "/usr/local/powerpc-wrs-vxworks")
+set(TOOLCHAIN_PREFIX "/usr/powerpc-wrs-vxworks")

-set(VXWORKS_LIBGCC "/usr/local/lib/gcc/powerpc-wrs-vxworks/${GCC_VERSION}/libgcc.a")

At least from what I’ve read of your problem, that should do the trick.