Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Programming (http://www.chiefdelphi.com/forums/forumdisplay.php?f=51)
-   -   Alternate GCC Toolchain (http://www.chiefdelphi.com/forums/showthread.php?t=109385)

rbmj 04-11-2012 00:29

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 :D

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 :D

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...

Code:

# 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 https://github.com/mirrors/gcc/archive/master.zip
$ wget http://ftp.gnu.org/gnu/binutils/binutils-2.22.tar.bz2
$ wget ftp://ftp.ni.com/pub/devzone/tut/updated_vxworks63gccdist.zip
$ unzip gcc-master.zip
$ tar -jxf binutils-2.22.tar.bz2
$ unzip updated_vxworks63gccdist.zip
# 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

AND YOU'RE DONE!

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.

HOW TO BUILD:

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

https://github.com/rbmj/cmake_vxworks

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:

https://github.com/rbmj/wpilib

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!

[BUGS/TODO]:

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 :) 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!

ebarker 04-11-2012 10:29

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by rbmj (Post 1192704)
Lobby FIRST/WRS/NI to use a compiler that *isn't* ten years old!

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 !!

agartner01 04-11-2012 11:28

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by ebarker (Post 1192724)
Why ? Having a C compiler that is ten years old should be solid, reliable, and mature.

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

Andrew Schreiber 04-11-2012 11:52

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by agartner01 (Post 1192727)
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:

CodeYeti 04-11-2012 13:25

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by ebarker (Post 1192724)
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 !!

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

agartner01 04-11-2012 15:41

Re: Alternate GCC Toolchain
 
1 Attachment(s)
Yeah, I can't even get it to compile. It looks like it fails with:
Code:

/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?

rbmj 04-11-2012 22:26

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by ebarker (Post 1192724)
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 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...

ebarker 04-11-2012 22:44

Re: Alternate GCC Toolchain
 
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...

agartner01 04-11-2012 23:07

Re: Alternate GCC Toolchain
 
1 Attachment(s)
Checked it again. Still not able to compile. Heres what I get:
Code:

/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.

rbmj 04-11-2012 23:14

Re: Alternate GCC Toolchain
 
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).

rbmj 04-11-2012 23:25

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by agartner01 (Post 1192844)
Checked it again. Still not able to compile. Heres what I get:
Code:

/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.

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.

agartner01 04-11-2012 23:53

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by rbmj (Post 1192848)
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:
Code:

  /usr/lib/gcc/powerpc-wrs-vxworks/4.8.0/../../../../powerpc-wrs-vxworks/bin/ld:
  cannot find -lstdc++


rbmj 05-11-2012 08:08

Re: Alternate GCC Toolchain
 
Quote:

Originally Posted by agartner01 (Post 1192853)
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:
Code:

  /usr/lib/gcc/powerpc-wrs-vxworks/4.8.0/../../../../powerpc-wrs-vxworks/bin/ld:
  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...

agartner01 05-11-2012 09:22

Re: Alternate GCC Toolchain
 
Ok, now it get this:
Code:

/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/munch.sh powerpc-wrs-vxworks-nm
  cmTryCompileExec2792526235_ctdt.c
  cmTryCompileExec2792526235_PartialImage.out

  Error running link command: No such file or directory

Edit:
Quote:

Originally Posted by rbmj (Post 1161874)
The CMake Toolchain file should work with the standard "gccdist" toolchain. If you download this toolchain <1> then the cmake file should work fine (NOTE: It requires munch.sh and strip_syms.sh from the vxworks-gcc-patches repo to be installed in WIND_BASE - maybe should make these a separate package), just set TOOLCHAIN_IS_GCCDIST to true.

So I did that, now i get:
Code:

  /usr/lib/gcc/powerpc-wrs-vxworks/4.8.0/../../../../powerpc-wrs-vxworks/bin/ld:
  cannot open linker script file
  /usr/local/powerpc-wrs-vxworks/wind_base/target/h/tool/gnu/ldscripts/link.OUT:
  No such file or directory

  collect2: error: ld returned 1 exit status

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


rbmj 05-11-2012 11:46

Re: Alternate GCC Toolchain
 
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 :)


All times are GMT -5. The time now is 00:43.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi