6 ms·
Building GCC as a Cross Compiler for Raspberry Pi
- bcaa7f3a8bbc 8y agoOn Gentoo, crossdev -t armv7a-hardfloat-linux-gnueabi crossdev can create Gentoo ebuilds of a complete set of toolchain for any platforms. crossdev -t x86_64-w64-mingw32 would create a GCC cross-compiler for Windows. * https://wiki.gentoo.org/wiki/Crossdev https://wiki.gentoo.org/wiki/Crossdev * https://wiki.gentoo.org/wiki/Embedded_Handbook/General/Creating_a_cross-compiler https://wiki.gentoo.org/wiki/Embedded_Handbook/General/Creat... * https://wiki.gentoo.org/wiki/Raspberry_Pi#Crossdev https://wiki.gentoo.org/wiki/Raspberry_Pi#Crossdev * https://wiki.gentoo.org/wiki/Mingw https://wiki.gentoo.org/wiki/Mingw
- bdowling 8y agoCrossdev (or variants like crossdev-ng) may work, but only if you stick to the most well-tested build and target combinations. Otherwise, there are O(ludicrous) configurations, most of which are untested.
- bcaa7f3a8bbc 8y agoDefinitely, but Windows and Raspberry Pi are both well-tested I believe.
- megous 8y agoThere's also arch linux arm way, where you control the build/linking from the target device, but the compilation of object code is done by a cross-compiler over the network.
- blackflame7000 8y agoI really wish I had read this a year ago when I was struggling with cross-compiling Qt for the RaspberryPi and instead natively built it which took 3 days.
- any1 8y agoWell, I've actually spent 3 days trying to get Qt5 to cross-compile for a custom arm platform. It might be easier for something common like the raspberry pi, but still, you may have dodged a bullet there. ;) The worst thing about cross-compiling Qt is that I always run into different issues with new releases, and it's not even always consistent between builds. I ended up renting a 64 core VPS to build Qt so that I could iterate faster though build failures, but it's still at least half a day's work to get it to build properly.
- blackflame7000 8y agoI hear ya, especially with respect to upgrades. Like without fail MYSQL Plugin will always be missing, QtWebsockets won't build automatically, and even now on ubuntu 18.04 which ships with openssl1.1.0 I discovered all my applications can no longer use https properly until I downgraded libssl to 1.0.2 Also: I'm assuming the 64 core machine is ARM? Which provider do you use for that?
- any1 8y agoI'm cross-compiling, meaning I'm not compiling on ARM. ;) It might be helpful though for 64 bit ARM, but my target architecture is 32 bit and because I need webengine I suspect that it will not compile on a 32 bit platform. The problem is that the linker requires more memory than can be addressed in a 32 bit address space for linking chrome/webengine. I just used google cloud.
- voltagex_ 8y agoThere's also crosstool-ng and buildroot for this, as well as pre built compilers by Linaro and Bootlin (formerly Free-Electrons). Sorry for lack of links, extremely limited connection right now.
- vcdimension 8y agohttps://crosstool-ng.github.io/ https://crosstool-ng.github.io/
- voltagex_ 8y agoLinaro: https://www.linaro.org/downloads/ https://www.linaro.org/downloads/ Bootlin: https://toolchains.bootlin.com/ https://toolchains.bootlin.com/
- plaes 8y agoWhy bother? apt install gcc-arm-linux-gnueabihf # Debian / Ubuntu dnf install gcc-arm-linux-gnu # Fedora
- nightcracker 8y agoIf you need any configuration options different than the packages provide, or a version later than the packages provide.
- mmphosis 8y agoNow I need to install apt and whatever dnf is and whatever dependencies they have and so on...
- auscompgeek 8y agoUh, why would you install a system package manager when you already have one?
- mmphosis 8y agoExactly, why bother?
- fragmede 8y agoDo people still fight with dependencies? Apt or dnf or some other package manager (like yum or pacman) comes preconfigured and preinstalled on all but the most esoteric Linux distros, so unless you're doing some really esoteric stuff, if you're fighting with dependencies, I would assume something's gone wrong. Which is to say, it still certainly possible to fall into dependency hell in this day and age, but the parent response belies a certain level of fear of installing things on Linux because of dependencies. I hear Windows still has this problem, decades later, and while Linux has it's own share of foibles, installing pre-packaged software is generally not the exciting/frustrating part. (Which Docker has made even easier!)
- nikofeyn 8y ago
- stuaxo 8y agoWish I had this when I was building gstreamer for the raspberry pi, it took ages! I tried various solutions like Qemu, but the performance was about the same as a real Pi.
- yjftsjthsd-h 8y agoCould you at least use distcc and scale it out horizontally?
- voltagex_ 8y agoNot all software supports being cross compiled - I can't remember if the problems I had with gstreamer were due to it not being able to be cross compiled or because I was trying to build Raspbian-compatible .deb files.
- anonymous2k 8y agoBuilding a cross compiling toolchain is a good exercise, but if you need to have a suite of tools/libs, check out llnl's spack. Spack automates building compilers/toolchains/libs from source, has hundreds of package definitions, and supports cross compiling. Kinda like Gentoo, but usable on any Linux/Mac platform. http://spack.readthedocs.io/en/latest/basic_usage.html http://spack.readthedocs.io/en/latest/basic_usage.html
- ldng 8y agohttp://www.linuxfromscratch.org/ http://www.linuxfromscratch.org/
- ythn 8y agoLinaro has really good premade cross compilers for ARM
- znpy 8y agoI've built a gcc-based cross toolchain for m68k (m68k-linux-gnu iirc) and it was very easy with crosstool-ng (ct-ng). I would recommend building a cross-toolchain by hand just a couple of time to understand the whole process, but then just use ct-ng or something similar: it gets the job done and it's very configurable (abi, target architecture, libraries etc).
- fest 8y agoI found the approach taken by yocto quite powerful: it can be used not only to compile all kernel and all packages for the target system but also build a matching SDK (cross-compiler with matching libraries). The learning curve is quite steep though. For Raspberry Pi this is an excellent getting-started guide: http://jumpnowtek.com/rpi/Raspberry-Pi-Systems-with-Yocto.html http://jumpnowtek.com/rpi/Raspberry-Pi-Systems-with-Yocto.ht...
- qalmakka 8y agoDamn GCC, that you have to build for each single architecture and os combo. Clang, being intrinsically a cross-compiler, is much better and way less of a hassle.
- ndesaulniers 8y agoAgreed. I'm actively trying to replace GCC+binutils for llvm based tools in Android (and further, at Google). Currently working through some issues for the kernel, more so llvm's assembler and linker than Clang.