![]() |
Custom C++ Toolchain - GCC 4.7.0!
Wanted to use C++ but chose Java instead because Eclipse is cross-platform?
Using C++ and wishing you could use a newer version of gcc, with performance and optimization improvements? Wanted a native gcc build on linux? Wishing you could use C++11 features in your robot code? Lambdas, rvalue references, standard library improvements, the whole 9 yards? After a lot of work by several people, I can say that there are working build scripts for a complete C++ toolchain using GCC 4.7.0. Thanks for the build script go to the following people: - Austin Schuh - Ross Light - Cody Schafer GCC Build Scripts can be found here: https://github.com/rbmj/vxworks-gcc-patches Static-Linked GCC Binaries are in the "Downloads" Section. The binaries I built *should* run on any modern amd64 linux machine, but I'm not sure, so please test! WPILib patched for new GCC is here: https://github.com/rbmj/wpilib The binaries in the downloads section should work on any linux machine. I don't have any windows binaries as I haven't ported the build script to windows, but if anyone wants to help with that, that would be REALLY COOL :) Finally, I have a toolchain file for CMake. This toolchain file is here: https://github.com/rbmj/cmake_vxworks You will need to use this toolchain file if you want to compile WPILib. TODO: Give WPILib a find_package/.config file! An example CMakeLists.txt file for a simple robot project: Code:
cmake_minimum_required(VERSION 2.8)Code:
$ cmake /path/to/repo/robot_test -DCMAKE_TOOLCHAIN_FILE=/path/to/toolchain/vxworks_toolchain.cmake TODO: - Do more extensive tests, including C++11 features - Make the build scripts nicer and less crufty - Get a working windows port |
Re: Custom C++ Toolchain - GCC 4.7.0!
Quote:
CMake is awesome... it is used in Open Scene Graph... it's a great way for the Visual Studio developers to interact with the GCC developers. |
Re: Custom C++ Toolchain
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.
The cmake toolchain file would work on windows if it weren't for the fact that I haven't bothered to create windows equivalents of munch.sh and strip_syms.sh. I don't know batch (or maybe it would have to be vbscript...) very well, so I wouldn't know how to substitute the cut and sed commands. If I can get the cmake scripts working on windows that opens up the possibility of teams using those dreamspark cards and developing the robot in visual studio, or codeblocks for FOSS purists like myself :D I don't know if the generators for VS or C::B support manual target rules though (CMAKE_C_COMPILE_OBJECT et al). Side note: I'm thinking in the future this can be four packages: vxworks-binutils vxworks-gcc (depends vxworks-binutils) vxworks-scripts (depends vxworks-binutils) vxworks-cmake-toolchain (depends vxworks-scripts, vxworks-gcc, vxworks-binutils) Maybe have a PPA... So question: Should I keep statically linking the binaries so they work on most linuxes, or should I use "proper" packaging? Also, if anyone gets a chance to test this with a machine other than my own, that would be cool :) maybe get it to work on win32? MSYS seems like the best option... 1. ftp://ftp.ni.com/pub/devzone/tut/updated_vxworks63gccdist.zip" |
Re: Custom C++ Toolchain
Great job! How hard would it be to get gfortran working? Fortran is the primary dependency I've been missing to get numpy ported to the cRIO.
|
Re: Custom C++ Toolchain
Quote:
If you're on windows, you might have to run the script through an MSYS shell. Right now the build script needs a basic set of bash commands, wget, sed, and realpath (IIRC). |
Re: Custom C++ Toolchain
OK. I'm looking for some advice:
Currently I have some statically linked binaries up. I'm worried, though, because those also include the system headers, which I don't have the right to redistribute. Should I take those binaries down and require everyone to use the build script? I couldn't find a contact at WindRiver for FRC, so I guess I'll have to email their generic inquiry account. Maybe this can be easily resolved. They also do some weird stuff with their include directories, that I'd ideally like to move around to simplify installation of GCC, as right now there's some hackish stuff I have to do to get GCC to build right :-( -------- Also, I forgot to post instructions for the build script. You need to call it like this: /path/to/build/script/build.bash PREFIX DLDIR SRCDIR BUILDDIR Where: PREFIX is where to install everything to (e.g. /usr/local) DLDIR is where to put the downloaded tarballs SRCDIR is where to extract the sources BUILDDIR is where to put the build trees. Note that these should be absolute paths. If you're in a clean directory, this should be sufficient: # ../build.bash /usr/local `pwd`/download `pwd`/src `pwd`/build It also needs to be run as root. If you have build problems let me know. |
Re: Custom C++ Toolchain
Quote:
|
Re: Custom C++ Toolchain
Quote:
Check wrn/coreip/ for the include as well. Since GCC doesn't support setting target-specific include directories without some really bad hacks, I had to put in some temporary stubs to redirect the includes. I'm thinking of restructuring the system headers so one no longer needs this cruft, but I'm pushing the boundaries of fair use as is :-( The other thing that is prone to break is stuff that has to do with the filesystem. Look at the patches for examples of how stuff had to be changed. Luckily, there were only a few files that screwed up for libstdc++. Hopefully libgfortran is similarly simple. And if you need any help you can post! |
Re: Custom C++ Toolchain
OK, finally got around to contacting Wind River. Confirmation Number 319, whatever that means.
Quote:
|
Re: Custom C++ Toolchain
3 Attachment(s)
Quote:
I have a series of patches, which I'll attach, but they're based off of the trunk. I'm working with the gcc devs to get them committed, so hopefully by gcc-4.8 vxworks will compile out of the box. There's also a series of patches which need to be applied to the C headers. Finally, there's a patch that needs to be applied while GCC builds and then reverted after the build. So, some build instructions. First, install the cross binutils from earlier- those will still work for building gcc. Then download all of the attachments to this post. Remove the .txt extension from the patch file: Code:
$ mv headers-build.patch{.txt,}Code:
$ tar -xf gcc-patches.tgzCode:
$ svn checkout svn://gcc.gnu.org/svn/gcc/trunk gccCode:
$ wget ftp://ftp.ni.com/pub/devzone/tut/updated_vxworks63gccdist.zipCode:
$ cat wrs-patches/*.patch | patch -p1 -l -d gccdist/WindRiver/vxworks-6.3/target/hCode:
$ patch -p1 -l -d gccdist/WindRiver/vxworks-6.3/target/h < headers-build.patchSince I made changes to configure.ac you'll need to regenerate that: Code:
$ autoconfCode:
dnl Ensure exactly this Autoconf version is usedCode:
dnl Ensure exactly this Autoconf version is usedOK, if you're still with me, now it's time to run configure. Switch out of the gcc directory (cd ..) and make a new directory called build (mkdir build), then switch into the build directory. Here's how to invoke configure: Code:
# ../gcc/configure \Now for the fun part. Hopefully, if you've done everything up to this point, you can just say [code] $ make -j4 [/code and everything will work just fine. Then just make install as root. Finally, clean up some of the unnecessary fixes: Code:
# patch -p1 -l -R -d /usr/powerpc-wrs-vxworks/sys-include < headers-build.patchThis will become much simpler once I update the build script, but in case any of you want to try this out and understand how to do it, I posted this. If you have any questions, let me know. Note that fortran support is untested as I have nothing to test it with. It would be nice if somebody could test this. Libgfortran's configure is acting funny too - gotta fix that. |
Re: Custom C++ Toolchain
I have installed the compiler binaries and wpilib on Xubuntu 12.04 through your .deb files. I then dumped the toolchain file and you sample CMakeLists.txt file into a directory. However, running CMake fails for me.
This appears to be the important part: Code:
powerpc-wrs-vxworks-c++: fatal error: environment variable 'WIND_BASE' notThank you, I'm really excited to get this working. |
Re: Custom C++ Toolchain
WIND_BASE doesn't matter anymore. It just needs to be defined to something. I just say export WIND_BASE='asdf'. If you want to be 'proper' about it, you can set WIND_BASE to /usr/local/powerpc-wrs-vxworks/wind_base
|
Re: Custom C++ Toolchain
Okay, then, I guess I got confused because when I tried setting it myself, I got a different error, which I interpreted to be because I had an incorrect setting for that variable :P
I have it working now (I think... I have yet to try it on the robot). However, I did have to make some symbolic links to make it work. In particular, I had to make the following links: Code:
lrwxrwxrwx 1 root root 15 May 26 12:49 /usr/local/powerpc-wrs-vxworks/host -> wind_base/host/ |
Re: Custom C++ Toolchain
This is awesome, and I hope I'll be programming on Linux come next season.
I'm trying to set up this toolchain on a 64-bit install of Archlinux, and I'm getting some errors after
Maybe this is something of note: while running Code:
cmake /home/azrathud/vxworks-c++-toolchain/project -DCMAKE_TOOLCHAIN_FILE=/home/I'm trying to compile last season's code which is in the src directory specified in the CMakeLists.txt From the errors, I think gcc cannot find the header files in /usr/local/powerpc-wrs-vxworks/sys-include Code:
In file included from /home/azrathud/vxworks-c++-toolchain/project/wpilib/ErrorBase.h:12:0,Code:
cmake_minimum_required(VERSION 2.8) |
Re: Custom C++ Toolchain
Quote:
Quote:
The final option is that that code worked on windows because windows is a non-case-sensitive filesystem. Check your capitalization (vxWorks.h maybe?) Quote:
|
| All times are GMT -5. The time now is 13:33. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi