Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GCC version not upgraded #81

Open
APokorny opened this issue Sep 5, 2017 · 59 comments
Open

GCC version not upgraded #81

APokorny opened this issue Sep 5, 2017 · 59 comments

Comments

@APokorny
Copy link

APokorny commented Sep 5, 2017

What is the purpose of this repository?
Is it supposed to provide a cross compiler that matches the gcc --version of the current raspbian image?
Will there be updates of any of the toolchains in the repository?

There is a growing number of projects that will no longer compile with gcc 4.8 and 4.9 support will see a similar fate. I am aware that there is an awkward C++ ABI change with gcc 5.0, but that step has to be made at some point.

@popcornmix
Copy link
Contributor

I have been testing a newer gcc but unfortunately it failed testing.
I'm using crosstool-ng with this configuration
I can build kernel and /opt/vc/lib libraries fine, but kodi seg-faults on launch.

@carlonluca
Copy link

If you want I built a cross toolchain gcc 6.3.0 for Stretch that seems to work for me for the moment. I built Qt, ffmpeg, omxplayer etc... I also tried kodi but I get an illegal instruction. It is built for armv7-a. I also built one identical for Mac OS. I uploaded the binaries here.

@robiwano
Copy link

@carlonluca How did you build it ? Did you use crosstool-ng ?

@crapp
Copy link

crapp commented Dec 1, 2017

@carlonluca please provide the build steps for your toolchain. I would like to build them myself

@carlonluca
Copy link

@robiwano no, crosstool-ng was giving me problems with the paths. I didn't investigate further.
@crapp there are many guides on the web, I think I followed something like this.

@MikeMitterer
Copy link

MikeMitterer commented Jan 17, 2018

Developer support is incredible bad!
gcc 4.8, gcc 4.9 - Guys, 2018!!!!! We need a modern compiler. Don't waste your time with crap like Rasperry PI Desktop.
Building a cross-compiler, specially on Mac, is not something every developer should have to do on his/her own. Even ESP32 (Espressif) has a x-compiler for every major OS. Raspberry-Org makes good money with their devices - it should be possible to provide us with a cross-compiler for Mac, Windows + Linux.

@JamesH65
Copy link

Wow, how rude.

All internal development at RPT is done using either the Pi itself, or desktop Linux with the supplied cross compiler. We don't have any experience in house in Windows or Mac cross compiling.

So I would suggest either doing dev work on RPI itself (using the RPI desktop, which is not crap BTW), or installing a VM with Linux and use the supplied cross compiler. It is old, but it works.

I'm sure that at some point we will release a newer x-compiler for Linux, but it requires a lot of work and even more testing (see comment above), and we are busy right now.

@robiwano
Copy link

robiwano commented Jan 17, 2018

But the thing is, it doesn't, does it? Raspbian Stretch (f.i.) is built with the GCC6.3.0 toolchain vs. GCC4.9.3 which is the one available. As the ABI changed somewhere around GCC5 (?) linking to OS provided shared objects might lead into a world of hurt, and hard to debug errors.

That said, I for one do appreciate all the work you are doing at RPT, and I was able to find a x-toolchain to use on Ubuntu and also the one provided with VisualGDB, which works fine on Windows.

@JamesH65
Copy link

Sorry, I was assuming people were wanting to cross compile kernel building, not 'app' building. I use the cross compiler for kernel builds all the time. However, for Pi app builds I use the Pi itself. Generally fast enough for the stuff I do - and the guy who does the dev work on the desktop uses the Pi for all of that as well, so clearly its fine for some fairly heavy lifting.

@APokorny
Copy link
Author

I think the solution here is to tell people to use the debian or ubuntu repositories for building applications and kernels i.e. use the cross compilation packages from stretch if your are a lucky linux user or have the resilience to run the linux subsystem for windows10. Or use a VM solution..

I only came across this repo because a user reported issues with running our binaries... which were built with a new compiler. He told me that here I would find the official ones..

@MikeMitterer
Copy link

@APokorny No - the solution is a cross-compiler for Windows and Mac! @JamesH65 I know that was rude - but as said: Raspberry Foundation made ~9M £ in 2015 (don't have the numbers for 2017), Expenses ~6.3M in 2015.
This whole thing is a business and not just a fun project.
Raspberry-Pi is 2 or 3 times more expensive than for example the Orange Pi.
For this price I expect things like a cross-compiler and not someone telling me that it's fast enough to develop on the Pi or that I should use Linux/Docker/VM...

@JamesH65
Copy link

JamesH65 commented Jan 17, 2018

For $35 you expect a cross compiler for Windows and Mac, two systems we don't support?

The RPF profits are pushed back straight in to education. There are limits to how much of the profits the trading arm can take of course. But TBH, the amount of profit made by the RPF is irrelevant to the decision on whether to spend a load of money building and supporting cross compilers for platforms we know nothing about. What more important is does that effort pay itself back? And the answer is, currently, no it doesn't. Lets say 1000 people want to work on a Mac, assuming profits per Pi of $3 (made up number), that's $3000 to build and support a cross compiler, ad infinitum. A completely inadequate amount of money for the effort involved. Now add the Windows version, perhaps 10000 people want to use the Windows cross compiler. We now have $30k to play with - STILL not enough. For example, we were just quoted $35k just to write a device driver for a USB wireless dongle. To do the cross compiler work, and SUPPORT it would be way more.

So, yes, we are running Raspberry Pi as a business!

I'd suggest using the Orange Pi cross compiler.

@WayneKeenan
Copy link

Microsoft makes a a hell of a lot more money and yet Visual Studio for Mac doesn't cross compile C/C++ apps for Windows, does that mean 'Developer support is incredible bad!' there too ?

The solution is to use a VM.

@MikeMitterer
Copy link

@WayneKeenan - MS ignored Mac and Linux because they were competitors, now they are loosing business to Mac and Linux and they have to support those systems...

@JamesH65 How much did you pay for Pixel??? A very conservative looking DE where everyone had XFCE, LXDE + Mate as an option - However...

33K for building a cross-compiler for Mac + Windows - are you kidding? If you pay 50$ per h than you have 660h - ~19 month!!!! to build a these two compilers.
ESP32 costs less than 5$ and they were able to provide their customers with an adequate compiler suite btw.

@jakemagee
Copy link

It seems that this thread has gotten way side tracked...

@MikeMitterer, please find another more appropriate forum to discuss your opinions. This thread is strictly for addressing technical issues regarding the cross toolchain.

I would suggest closing the issue since it appears that @APokorny has a workaround. However, it seems that there is still active effort in updating the cross toolchain.

@robiwano
Copy link

What? There's no workaround or solution, other than using carlonlucas binaries at the moment, unless I missed something? I mean, Raspbian Stretch was built with the 6.3.0 toolchain. Wouldn't it be possible to just provide that toolchain for running on Ubuntu f.i. ? I'm fine with running on a VM, as long as I have something to run. Right now I use the toolchain provided by SysProgs.

@jakemagee
Copy link

I never stated that the issue currently has a solution. And as for workarounds, I (possibly incorrectly) assumed you had a workaround based on your posts...

I was able to find a x-toolchain to use on Ubuntu and also the one provided with VisualGDB, which works fine on Windows.

other than using carlonlucas binaries at the moment

Right now I use the toolchain provided by SysProgs.

If, in fact, none of the above are useful to you (or anyone else) as a workaround then I'm sure we can find something else that can be until an updated toolchain is available.

@johnmanko
Copy link

@MikeMitterer Have you tried cygwin on Windows? Also, I've seen plenty of people using gcc on MacOS, so I'm sure you should be able to cross compile there as well.

@MikeMitterer
Copy link

@johnmanko Thanks - but I was able to compile an older version of the cross-compiler for Raspberry on my Mac but it's a hassle. Mac uses clang (not gcc) and the filesystem is not case sensitive - these are the main problems. It's a very annoying, error prone and time consuming job.

What I don't get and what really f... me is that every developer on Mac has to do this by his own and that the Raspberry foundation doesn't provide these tools - gcc 4.9 is a joke - we need a modern compiler!!! like gcc 6.3)

@pelwell
Copy link
Contributor

pelwell commented Jan 21, 2018

A modern compiler won't solve the case-insensitivity problem, which is why we recommend using a virtual machine running Linux - I do.

@johnmanko
Copy link

I believe that the file system case sensitivity is optional, probably upon installation. You might be able to change it post installation.

@yoursunny
Copy link

I'm trying to build a large package on the Pi Zero running Raspbian Stretch, and I want to use distccd on a amd64 architecture Linux machine to help with the compilation. Having gcc 6.3.0 cross compiler would be incredibly useful.

@omegacoleman
Copy link

This is definately an awful situation for many trying to modify the source of the firmware, but for 90% of the above you came to the wrong place.

If you are cross compiling apps for pi, you could just use the newest compiler you want, even gcc7 is okay. BUT WITH STATIC LINKING AND AN INDEPENDENTLY BUILT GCC. Like the one you built with --without-headers before compiling glibc(in the toolchain build). This is the best way almost, as the firmware of embedded systems update much slower even than the cpp standard, let alone the compiler.

You are mislead here because Debian packager knows nothing about this. The official debian arm-linux-gcc package is a stage two gcc, depending on a debian built glibc. It is limited to debian arm systems, and only works with the latest raspbian(with latest glibc).

Fedora is clearly smarter, so it shipped with the good gcc I described above.

Another thing is Debian has a clumsy multiarch dir structure, and it patches gcc to let it search different folders. If you find someting should be in /usr/lib end up in /usr/lib/arm-linux-gmueabihf, just copy it to where it should be, its okay.

@crapp
Copy link

crapp commented Mar 21, 2018

@omegacoleman is right. It is really easy to build your own toolchain. If you link your application correct it will run without problems on the raspberry pi.

@APokorny
Copy link
Author

APokorny commented Mar 21, 2018

So if you came here because deployment on a armhf platform is your focus - and not a specific distribution (version) - you should look into building snaps with snapcraft.

If you build your application as a snap ABI troubles and finding the right compiler are no longer a problem. You basically build your software against a specific libc and libstdc++ ABI - but with a compiler of your choice - and you wont have further external dependencies that might not be available on the target system. On the target system the snap daemon will take care that the ABI is available - either through the underlying distribution or shipped with snapd.

A caveat: snapcraft by default does not cross compile. You usually assemble your application within a build container. But since 2017 cross compilation was added for many of the build plugins - autotools/make go rust.. CMake needs a workaround ). Alternatively you can let launchpad take care of building on armhf and arm64.

@ali1234
Copy link
Contributor

ali1234 commented Dec 21, 2018

@APokorny snap can't run on Pi Zero because Ubuntu does not support ARMv6. Neither does Launchpad, nor the arm cross compilers in Debian and Ubuntu They all require a minimum of ARMv7.

@ali1234
Copy link
Contributor

ali1234 commented Jan 2, 2019

Also abe configure should have asked you to install some things, at the very least you probably don't have git-new-workdir. I built on ubuntu 18.04 using only repo packages (git-new-workdir is packaged but has to be copied from /usr/share/doc to the path, the script tells you what to do iirc)

@popcornmix
Copy link
Contributor

I've tried building from a --recursive clone but no change in behaviour. Tried on two machines with the same result.

@ali1234
Copy link
Contributor

ali1234 commented Jan 2, 2019

This is definitely an issue of missing git-new-workdir. It looks like the configure script doesn't exit with an error code if it finds a missing tool, so the script just continues on. You never see the error and then the build fails much later. In this case what is happeneing is $NEWWORKDIR is unset so instead of running the command it tries to run the directory, leading to the error you see. You should be able to confirm this by looking at _build/hosts.conf, which should have a line like NEWWORKDIR=/home/al/.local/bin/git-new-workdir or wherever you copied it. I expect it will be missing or empty...

@ali1234
Copy link
Contributor

ali1234 commented Jan 2, 2019

Okay I fixed it. I forgot to sh -e, so untested errors were ignored.

@popcornmix
Copy link
Contributor

Thanks - build completes now.

I'm still not sure I trust the compiler though.

Basically all my attempts to bump to gcc 6 (and this also applies to this new build) fail to compile a usable kodi build.
Kodi crashes after a few seconds with what looks like heap corruption.
The 4.9 gcc doesn't have this problem.

Now it's possible there is a bug in kodi that somehow 4.9 doesn't trigger (and hasn't been observed on the many other platforms) but I went through the process of commenting out areas of code that were in the crashing callstack, and would always find another crash a bit later in unrelated code.

I've not seen an issue with building the kernel or userland libs with newer compilers, so far I've only seen the problem in kodi.

I wonder if there could be difference in libc or some brokenness in atomics that makes malloc/free not thread safe when building with newer gcc.

@ali1234
Copy link
Contributor

ali1234 commented Jan 3, 2019

Can you please describe how you're building and running Kodi wth both compilers? Because as far as I am concerned the 4.9 compiler isn't capable of producing binaries that can run on Raspbian at all... not even hello world should work, it shouldn't even finish compiling.

@popcornmix
Copy link
Contributor

4.9 compiler works just fine for raspbian stretch. We use it to build the userland libs and apps (e.g. raspicam).

@popcornmix
Copy link
Contributor

dom@dom-XPS-13-9370:/tmp$ arm-linux-gnueabihf-gcc --version
arm-linux-gnueabihf-gcc (crosstool-NG crosstool-ng-1.22.0-88-g8460611) 4.9.3
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

dom@dom-XPS-13-9370:/tmp$ arm-linux-gnueabihf-gcc hello.c 
dom@dom-XPS-13-9370:/tmp$ file a.out
a.out: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, not stripped

and a.out runs fine on raspbian stretch.

@ali1234
Copy link
Contributor

ali1234 commented Jan 4, 2019

Where is your sysroot? You are building against the libraries in the default toolchain sysroot. If they don't perfectly match Raspbian you will get segfaults. This works with glibc because it has a stable ABI but the same is not true for all Kodi dependencies.

In order to actually build against Raspbian you need to specify --sysroot /path/to/raspbian/root.

@popcornmix
Copy link
Contributor

Lets see if I get kodi to build with an explicit sysroot set.

The existing compiler has a sysroot directory: https://github.com/raspberrypi/tools/tree/master/arm-bcm2708/arm-rpi-4.9.3-linux-gnueabihf/arm-linux-gnueabihf/sysroot

I believe it should be possible to configure gcc build (--with-sysroot) to use raspbian's sysroot (i.e. include raspbian libs in the sysroot dir of toolchain), so explicitly using --sysroot on every compile isn't required. I didn't get this working - is that option something you are familiar with?

@ali1234
Copy link
Contributor

ali1234 commented Jan 4, 2019

The 4.9.3 compiler isn't compatible with Raspbian sysroots because it is built without --enable-multiarch. As such it won't find headers in the triplet prefixed directories that Debian and Raspbian use. It will refuse to compile even hello.c after it fails to find sys/cdefs.h.

ABE and ct-ng both claim to be able to build gcc against an existing sysroot which would mean you could build a toolchain on top of the real Raspbian glibc, however neither of them actually documents how to do this and I haven't managed to figure it out yet.

@popcornmix
Copy link
Contributor

But the 4.9.3 toolchain is the only toolchain that works for everything.
I use it to build raspbian kernel, raspian userland libs and apps and kodi and it just works.

Executables runs correctly on raspbian jessie and raspbian stretch.

I only have issues with newer versions of gcc.

@ali1234
Copy link
Contributor

ali1234 commented Jan 4, 2019

Well, you still haven't said how you're building Kodi. The cross compile instructions they have tell you to use 4.9.3 and their build system compiles every dependency from scratch. So you are not building it for Raspbian if you do it that way. You're effectively building a cross-distribution bundle. The instructions also currently don't work - it fails to build libudev with "R_ARM_TLS_LE32 relocation not permitted in shared object" with both 4.9.3 compiler and my own compiler.

The kernel of course doesn't care what userspace libraries are in your sysroot because it doesn't use any of them at all - you can build it with a arm-none-gnueabihf bare metal compiler.

@popcornmix
Copy link
Contributor

This is how I build kodi. It's working on current kodi master (on ubuntu 18.10 with all required native dependencies installed)

MYADDONS="pvr.hts"
PREFIX=/home/dom/xbmc_holder/xbmc/build/install

set -e
    cd ~/xbmc_holder/xbmc/ \
    && \
    cd tools/depends \
    && \
    ./bootstrap \
    && \
    ./configure --host=arm-linux-gnueabihf \
        --prefix=${PREFIX} \
        --with-firmware=/opt/bcm-rootfs \
        --with-toolchain=/opt/arm-linux-gnueabihf \
        --with-platform=raspberry-pi2 \
    && \
    nice ionice make -j$(getconf _NPROCESSORS_ONLN) \
    && \
    cd ../.. \
    && \
    make -C tools/depends/target/cmakebuildsys \
    && \
    mkdir -p build && cd build \
    && \
    nice ionice make -j$(getconf _NPROCESSORS_ONLN) \
    && \
    make binary-addons ADDON_SRC_PREFIX=/home/dom/xbmc_holder ADDONS=$MYADDONS \
    && \
    make install

/opt/bcm-rootfs contains pi rootfs (I believe only used for /opt/vc/lib libs)
/opt/arm-linux-gnueabihf is a symlink to current cross compiler (4.9.3 from tools repo)

@popcornmix
Copy link
Contributor

And the kodi executable isn't static - it's using libs from /usr/lib and /lib of raspbian

pi@domnfs:/opt/xbmc $ ldd kodi-rbpi
	linux-vdso.so.1 (0x7edbf000)
	libpthread.so.0 => /lib/arm-linux-gnueabihf/libpthread.so.0 (0x76ec1000)
	libEGL.so => /opt/vc/lib/libEGL.so (0x76e88000)
	libGLESv2.so => /opt/vc/lib/libGLESv2.so (0x76e63000)
	libbcm_host.so => /opt/vc/lib/libbcm_host.so (0x76e3c000)
	libvcos.so => /opt/vc/lib/libvcos.so (0x76e22000)
	libvchiq_arm.so => /opt/vc/lib/libvchiq_arm.so (0x76e0c000)
	libasound.so.2 => /usr/lib/arm-linux-gnueabihf/libasound.so.2 (0x76d1f000)
	libbluray.so.2 => not found
	libcec.so => not found
	libdbus-1.so.3 => /lib/arm-linux-gnueabihf/libdbus-1.so.3 (0x76ccc000)
	librt.so.1 => /lib/arm-linux-gnueabihf/librt.so.1 (0x76cb5000)
	libdl.so.2 => /lib/arm-linux-gnueabihf/libdl.so.2 (0x76ca2000)
	libutil.so.1 => /lib/arm-linux-gnueabihf/libutil.so.1 (0x76c8f000)
	libsmbclient.so.0 => /usr/lib/arm-linux-gnueabihf/libsmbclient.so.0 (0x76c5e000)
	libass.so.5 => /usr/lib/arm-linux-gnueabihf/libass.so.5 (0x76c29000)
	libm.so.6 => /lib/arm-linux-gnueabihf/libm.so.6 (0x76baa000)
	libbrcmGLESv2.so => /opt/vc/lib/libbrcmGLESv2.so (0x76b85000)
	libbrcmEGL.so => /opt/vc/lib/libbrcmEGL.so (0x76b4c000)
	libmmal.so => /opt/vc/lib/libmmal.so (0x76b39000)
	libmmal_core.so => /opt/vc/lib/libmmal_core.so (0x76b1b000)
	libmmal_util.so => /opt/vc/lib/libmmal_util.so (0x76afb000)
	libmmal_vc_client.so => /opt/vc/lib/libmmal_vc_client.so (0x76ae0000)
	libmmal_components.so => /opt/vc/lib/libmmal_components.so (0x76ac5000)
	libvcsm.so => /opt/vc/lib/libvcsm.so (0x76ab0000)
	libcontainers.so => /opt/vc/lib/libcontainers.so (0x76a8f000)
	libinput.so.10 => /usr/lib/arm-linux-gnueabihf/libinput.so.10 (0x76a57000)
	libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0x76918000)
	/lib/ld-linux-armhf.so.3 (0x76f00000)
	libstdc++.so.6 => /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 (0x767d0000)
	libgcc_s.so.1 => /lib/arm-linux-gnueabihf/libgcc_s.so.1 (0x767a3000)
	libsystemd.so.0 => /lib/arm-linux-gnueabihf/libsystemd.so.0 (0x76729000)
	libsamba-util.so.0 => /usr/lib/arm-linux-gnueabihf/libsamba-util.so.0 (0x766ad000)
	libtalloc-report.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libtalloc-report.so.0 (0x7669a000)
	libtevent-util.so.0 => /usr/lib/arm-linux-gnueabihf/libtevent-util.so.0 (0x76687000)
	liblibsmb.so.0 => /usr/lib/arm-linux-gnueabihf/samba/liblibsmb.so.0 (0x7661f000)
	libmsrpc3.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libmsrpc3.so.0 (0x765f3000)
	libsamba-errors.so.1 => /usr/lib/arm-linux-gnueabihf/libsamba-errors.so.1 (0x764f7000)
	liblibcli-lsa3.so.0 => /usr/lib/arm-linux-gnueabihf/samba/liblibcli-lsa3.so.0 (0x764e3000)
	libsamba-security.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsamba-security.so.0 (0x764bb000)
	libsmbconf.so.0 => /usr/lib/arm-linux-gnueabihf/libsmbconf.so.0 (0x76444000)
	libsamba3-util.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsamba3-util.so.0 (0x7642c000)
	libndr.so.0 => /usr/lib/arm-linux-gnueabihf/libndr.so.0 (0x7640a000)
	libsamba-debug.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsamba-debug.so.0 (0x763f5000)
	libcli-smb-common.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libcli-smb-common.so.0 (0x763c1000)
	libgse.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libgse.so.0 (0x7638e000)
	libutil-cmdline.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libutil-cmdline.so.0 (0x7637b000)
	libndr-standard.so.0 => /usr/lib/arm-linux-gnueabihf/libndr-standard.so.0 (0x760a5000)
	libdcerpc-samba.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libdcerpc-samba.so.0 (0x75f54000)
	libsmbregistry.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsmbregistry.so.0 (0x75f2b000)
	libsecrets3.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsecrets3.so.0 (0x75f12000)
	libbsd.so.0 => /lib/arm-linux-gnueabihf/libbsd.so.0 (0x75ee9000)
	libtalloc.so.2 => /usr/lib/arm-linux-gnueabihf/libtalloc.so.2 (0x75ec7000)
	libtevent.so.0 => /usr/lib/arm-linux-gnueabihf/libtevent.so.0 (0x75eaa000)
	libfribidi.so.0 => /usr/lib/arm-linux-gnueabihf/libfribidi.so.0 (0x75e83000)
	libfontconfig.so.1 => /usr/lib/arm-linux-gnueabihf/libfontconfig.so.1 (0x75e40000)
	libfreetype.so.6 => /usr/lib/arm-linux-gnueabihf/libfreetype.so.6 (0x75da5000)
	libharfbuzz.so.0 => /usr/lib/arm-linux-gnueabihf/libharfbuzz.so.0 (0x75d0e000)
	libmtdev.so.1 => /usr/lib/arm-linux-gnueabihf/libmtdev.so.1 (0x75d01000)
	libudev.so.1 => /lib/arm-linux-gnueabihf/libudev.so.1 (0x75ce4000)
	libevdev.so.2 => /usr/lib/arm-linux-gnueabihf/libevdev.so.2 (0x75cc4000)
	libwacom.so.2 => /usr/lib/arm-linux-gnueabihf/libwacom.so.2 (0x75cab000)
	libselinux.so.1 => /lib/arm-linux-gnueabihf/libselinux.so.1 (0x75c78000)
	liblzma.so.5 => /lib/arm-linux-gnueabihf/liblzma.so.5 (0x75c47000)
	liblz4.so.1 => /usr/lib/arm-linux-gnueabihf/liblz4.so.1 (0x75c26000)
	libgcrypt.so.20 => /lib/arm-linux-gnueabihf/libgcrypt.so.20 (0x75b53000)
	libtime-basic.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libtime-basic.so.0 (0x75b41000)
	libsocket-blocking.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsocket-blocking.so.0 (0x75b2f000)
	libgenrand.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libgenrand.so.0 (0x75b1d000)
	libkrb5samba.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libkrb5samba.so.0 (0x75b02000)
	libcli-cldap.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libcli-cldap.so.0 (0x75aeb000)
	libcliauth.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libcliauth.so.0 (0x75acb000)
	libsys-rw.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsys-rw.so.0 (0x75ab8000)
	libgensec.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libgensec.so.0 (0x75a85000)
	libcom_err-samba4.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libcom_err-samba4.so.0 (0x75a72000)
	libasn1util.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libasn1util.so.0 (0x75a5b000)
	libndr-nbt.so.0 => /usr/lib/arm-linux-gnueabihf/libndr-nbt.so.0 (0x75a38000)
	libsamba-hostconfig.so.0 => /usr/lib/arm-linux-gnueabihf/libsamba-hostconfig.so.0 (0x75a0a000)
	libsmb-transport.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsmb-transport.so.0 (0x759f5000)
	libsamba-credentials.so.0 => /usr/lib/arm-linux-gnueabihf/libsamba-credentials.so.0 (0x759d6000)
	libCHARSET3.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libCHARSET3.so.0 (0x759c3000)
	libndr-samba.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libndr-samba.so.0 (0x758a7000)
	libdbwrap.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libdbwrap.so.0 (0x7588e000)
	libdcerpc-binding.so.0 => /usr/lib/arm-linux-gnueabihf/libdcerpc-binding.so.0 (0x75865000)
	libutil-tdb.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libutil-tdb.so.0 (0x75852000)
	libsamba-sockets.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsamba-sockets.so.0 (0x7582d000)
	libinterfaces.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libinterfaces.so.0 (0x7581a000)
	libmessages-dgm.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libmessages-dgm.so.0 (0x75802000)
	libserver-id-db.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libserver-id-db.so.0 (0x757ef000)
	libiov-buf.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libiov-buf.so.0 (0x757dd000)
	libutil-reg.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libutil-reg.so.0 (0x757cb000)
	libmessages-util.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libmessages-util.so.0 (0x757b9000)
	libsmbd-shim.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsmbd-shim.so.0 (0x757a7000)
	libutil-setid.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libutil-setid.so.0 (0x75795000)
	libtdb-wrap.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libtdb-wrap.so.0 (0x75782000)
	libserver-role.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libserver-role.so.0 (0x7576e000)
	libnsl.so.1 => /lib/arm-linux-gnueabihf/libnsl.so.1 (0x7574a000)
	libtdb.so.1 => /usr/lib/arm-linux-gnueabihf/libtdb.so.1 (0x75727000)
	libcap.so.2 => /lib/arm-linux-gnueabihf/libcap.so.2 (0x75712000)
	liblber-2.4.so.2 => /usr/lib/arm-linux-gnueabihf/liblber-2.4.so.2 (0x756f6000)
	libldap_r-2.4.so.2 => /usr/lib/arm-linux-gnueabihf/libldap_r-2.4.so.2 (0x756a1000)
	libkrb5-samba4.so.26 => /usr/lib/arm-linux-gnueabihf/samba/libkrb5-samba4.so.26 (0x7563e000)
	libaddns.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libaddns.so.0 (0x75625000)
	libgssapi-samba4.so.2 => /usr/lib/arm-linux-gnueabihf/samba/libgssapi-samba4.so.2 (0x755f0000)
	libauthkrb5.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libauthkrb5.so.0 (0x755c9000)
	libcli-nbt.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libcli-nbt.so.0 (0x755ae000)
	libmsghdr.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libmsghdr.so.0 (0x7559c000)
	libexpat.so.1 => /lib/arm-linux-gnueabihf/libexpat.so.1 (0x7556a000)
	libz.so.1 => /lib/arm-linux-gnueabihf/libz.so.1 (0x75543000)
	libpng16.so.16 => /usr/lib/arm-linux-gnueabihf/libpng16.so.16 (0x75509000)
	libglib-2.0.so.0 => /lib/arm-linux-gnueabihf/libglib-2.0.so.0 (0x75401000)
	libgraphite2.so.3 => /usr/lib/arm-linux-gnueabihf/libgraphite2.so.3 (0x753ce000)
	libgudev-1.0.so.0 => /usr/lib/arm-linux-gnueabihf/libgudev-1.0.so.0 (0x753b6000)
	libgobject-2.0.so.0 => /usr/lib/arm-linux-gnueabihf/libgobject-2.0.so.0 (0x7535c000)
	libpcre.so.3 => /lib/arm-linux-gnueabihf/libpcre.so.3 (0x752e1000)
	libgpg-error.so.0 => /lib/arm-linux-gnueabihf/libgpg-error.so.0 (0x752c1000)
	libasn1-samba4.so.8 => /usr/lib/arm-linux-gnueabihf/samba/libasn1-samba4.so.8 (0x75256000)
	libcli-ldap-common.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libcli-ldap-common.so.0 (0x7523f000)
	libwinbind-client.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libwinbind-client.so.0 (0x7522c000)
	libldb.so.1 => /usr/lib/arm-linux-gnueabihf/libldb.so.1 (0x751f5000)
	libwbclient.so.0 => /usr/lib/arm-linux-gnueabihf/libwbclient.so.0 (0x751d9000)
	libsamba-modules.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsamba-modules.so.0 (0x751c6000)
	libsamdb.so.0 => /usr/lib/arm-linux-gnueabihf/libsamdb.so.0 (0x751a1000)
	libsamdb-common.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libsamdb-common.so.0 (0x75169000)
	libldbsamba.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libldbsamba.so.0 (0x75135000)
	libresolv.so.2 => /lib/arm-linux-gnueabihf/libresolv.so.2 (0x75110000)
	libsasl2.so.2 => /usr/lib/arm-linux-gnueabihf/libsasl2.so.2 (0x750e9000)
	libgnutls.so.30 => /usr/lib/arm-linux-gnueabihf/libgnutls.so.30 (0x74f5c000)
	libheimbase-samba4.so.1 => /usr/lib/arm-linux-gnueabihf/samba/libheimbase-samba4.so.1 (0x74f49000)
	libhx509-samba4.so.5 => /usr/lib/arm-linux-gnueabihf/samba/libhx509-samba4.so.5 (0x74f05000)
	libhcrypto-samba4.so.5 => /usr/lib/arm-linux-gnueabihf/samba/libhcrypto-samba4.so.5 (0x74eca000)
	libroken-samba4.so.19 => /usr/lib/arm-linux-gnueabihf/samba/libroken-samba4.so.19 (0x74eaf000)
	libwind-samba4.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libwind-samba4.so.0 (0x74e75000)
	libndr-krb5pac.so.0 => /usr/lib/arm-linux-gnueabihf/libndr-krb5pac.so.0 (0x74e5a000)
	libauth-sam-reply.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libauth-sam-reply.so.0 (0x74e46000)
	libgio-2.0.so.0 => /usr/lib/arm-linux-gnueabihf/libgio-2.0.so.0 (0x74ce2000)
	libffi.so.6 => /usr/lib/arm-linux-gnueabihf/libffi.so.6 (0x74cca000)
	libflag-mapping.so.0 => /usr/lib/arm-linux-gnueabihf/samba/libflag-mapping.so.0 (0x74cb8000)
	libp11-kit.so.0 => /usr/lib/arm-linux-gnueabihf/libp11-kit.so.0 (0x74c5a000)
	libidn.so.11 => /lib/arm-linux-gnueabihf/libidn.so.11 (0x74c19000)
	libtasn1.so.6 => /usr/lib/arm-linux-gnueabihf/libtasn1.so.6 (0x74bf7000)
	libnettle.so.6 => /usr/lib/arm-linux-gnueabihf/libnettle.so.6 (0x74bb0000)
	libhogweed.so.4 => /usr/lib/arm-linux-gnueabihf/libhogweed.so.4 (0x74b73000)
	libgmp.so.10 => /usr/lib/arm-linux-gnueabihf/libgmp.so.10 (0x74b00000)
	libgmodule-2.0.so.0 => /usr/lib/arm-linux-gnueabihf/libgmodule-2.0.so.0 (0x74aec000)
	libmount.so.1 => /lib/arm-linux-gnueabihf/libmount.so.1 (0x74a99000)
	libblkid.so.1 => /lib/arm-linux-gnueabihf/libblkid.so.1 (0x74a4c000)
	libuuid.so.1 => /lib/arm-linux-gnueabihf/libuuid.so.1 (0x74a38000)

@ali1234
Copy link
Contributor

ali1234 commented Jan 4, 2019

Yes, this is the cause of all your problems. Your build script is the same as the upstream instructions. The first time you run make it is to build all the dependencies of Kodi from source. The next steps then build Kodi against those libraries. Then you run it against the Raspbian system libraries, which are different. If this works at all, it's because of luck.

If you get segfaults and memory corruption it is because the library ABIs do not match. You should set up the library path to make Kodi use the libraries it was built against, then it will work. Alternatively build it against a real Raspbian sysroot - but this is not possible with the 4.9.3 compiler.

@popcornmix
Copy link
Contributor

But most of these libs aren't built by kodi depends. Kodi doesn't attempt to build libc/libm/librt/libdl/libpthread. Won't this be an issue when the compiler doesn't know what versions of these are being used at runtime?

@ali1234
Copy link
Contributor

ali1234 commented Jan 4, 2019

Yes, it is a problem. To be really sure it works you also have to install the compiler default runtime since that it what you built against. The Linaro toolchains are split into three packages for this reason: gcc, sysroot, and runtime. The sysroot is the development headers and the runtime is just what you need when running programs.

You can normally get away with using slightly different versions of core libraries like glibc/pthreads because that stuff is really stable and they put loads of work into being backwards compatible. But the further you get from the core platform, the less likely it is to work.

@jslauthor
Copy link

jslauthor commented Jan 31, 2019

@ali1234 I really can't thank you enough. I've been struggling to cross-compile Qt 5.12.0 with EGLFS for longer than I care to admit 😅 but using your build script to compile the newer GCC finally got me to the finish line. I'm in awe watching my app on a 7" LCD hum along, running shaders at 60fps without X11. 🙇

@ghost
Copy link

ghost commented Apr 17, 2019

@jslauthor might you share some details? I'm still trying to cross-compile Qt5.13 with EGLFS for Rpi3B+vc4 using the newer linaro-gcc toolchain suggested by @ali1234. I have a fresh Raspbian Lite environment (still in a loop device) where I downloaded dependencies (build-dep qt5-default, libssl1.0-dev libudev-dev libinput-dev libdbus-1-dev libglib2.0-dev libts-dev libx11-dev libx11-xcb-dev libxi-dev libasound2-dev fonts-dejavu gdbserver gdb-python2), sync-ed the sysroot with the out provided by the linaro toolchain.

But the configure tool of Qt5 doesn't find any EGLFS/OpenGL library:

Checking for OpenGL ES 2.0... 
Trying source 0 (type pkgConfig) of library opengl_es2 ...
+ PKG_CONFIG_SYSROOT_DIR=/home/mark/opt/sysroot PKG_CONFIG_LIBDIR=/home/mark/opt/sysroot/usr/lib/pkgconfig:/home/mark/opt/sysroot/usr/share/pkgconfig:/home/mark/opt/sysroot/usr/lib/arm-linux-gnueabihf/pkgconfig /usr/bin/pkg-config --exists --silence-errors glesv2
pkg-config did not find package.
  => source produced no result.
Trying source 1 (type makeSpec) of library opengl_es2 ...
header entry 'config.qtbase_gui.libraries.opengl_es2.headers.0' passed condition.
GLES2/gl2.h not found in [] and global paths.
  => source produced no result.
test config.qtbase_gui.libraries.opengl_es2 FAILED

I've copied the /opt/vc/ libraries to /home/mark/opt/sysroot/usr/.

@ali1234
Copy link
Contributor

ali1234 commented Apr 17, 2019

@Mark-81 Qt won't find the pkg-config files because of complicated reasons. I ended up writing a custom build tool (https://github.com/ali1234/pydo/) to manage all the ever growing list of workarounds in https://github.com/ali1234/rpi-ramdisk. In addition to the final ramdisk target it produces tgz files with the runtime libraries which you can just unpack on regular raspbian and add to the ld config. It constructs the sysroot directly from debs using multistrap and then applies all the workarounds. It downloads my abe toolchain binary releases from github. Then it builds the kernel (twice) and all the selected packages (eg Qt, gstreamer etc). You also get a qt-host directory that you can use for cross compiling outside rpi-ramdisk. qmake from that dir will set up the environment to compile against the rpi-ramdisk sysroot. It does produce Qt EGLFS executables that run on Pi Zero, but they are a bit slow compared to Pi 3.

@ghost
Copy link

ghost commented Apr 18, 2019

@ali1234 thanks for your explanation and your effort! I'm not interested in Pi Zero, but I just want to have a decent performance (using GPU) for RPi3B+ without X and with QML enabled, at least Qt5.12. I give it a try to your pydo to see if I can then drop the binaries to my already customized Raspbian Lite.

@ghost ghost mentioned this issue Apr 18, 2019
@jslauthor
Copy link

jslauthor commented Apr 22, 2019

@Mark-81 hopefully @ali1234's advice helped. I couldn't get 5.13 to compile. 🙁I compiled 5.12.0 successfully. Would love to know if you are successful with 5.13, however, since Lottie integration is an awesome new feature!

@ghost
Copy link

ghost commented Apr 23, 2019

@jslauthor unfortunately not:

ali1234/rpi-ramdisk#14
ali1234/rpi-ramdisk#15

I spent too much time and for now I'm stuck with the old Qt 5.9.
It seem weird to me why it's so complex and it's not so repeatable. I mean, it should be reliable 100% once given:

  • the target, i.e. RPi3B+ and Qt 5.x
  • the host environment, say Debian 9 or Ubuntu 19.04
  • the prerequisites: lists of packages needed
  • the commands to issue (i.e. configure arguments)

At least we should have a working configuration. I understand that cannot cover all the needs for everyone, but there would be one reliable scenario to start with.

@ali1234
Copy link
Contributor

ali1234 commented Oct 13, 2019

I have updated my toolchain to include the binutils multiarch patch (see #102 (comment)). In order to do this I had to go back to using crosstool-ng.

Adding multiarch support to binutils allowed me to remove the -Wl,---Wl,--unresolved-symbols=ignore-in-shared-libraries hack, which turns out to invalidate some of the work I did on raspberrypi/firmware#1013 - although there is still some overlinking, there is not as much as I thought.

It also lead me to rediscover a bug in Debian libtool from 2005 that prevents cross-compiling some projects. I set the crosstool-ng to put a vanilla libtool in the toolchain. It will avoid the bug, but causes some overlinking. This isn't a really problem unless you are building inter-dependent debs. Either way, this is something that Debian needs to fix, but probably never will.

I think this is the best recipe yet - having proper multiarch support is something that even the original Linaro compiler never had as far as I can tell. I also made the scripts so it can be built inside Docker, although in the process I ran in to moby/moby#13451 (but this doesn't prevent the build from working, it just prevents cleaning up the container afterwards.)

Toolchain is here: https://github.com/ali1234/rpi-toolchain

@Pro
Copy link

Pro commented Oct 28, 2019

I created a new repository which contains an updated toolchain with ARMv6 support.

Tested it on a Raspberry PI Zero with Raspbian Buster, and it works perfectly.

See:
https://stackoverflow.com/a/58559140/869402

And the repo:
https://github.com/Pro/raspi-toolchain

I'm happy for any feedback.

@ali1234
Copy link
Contributor

ali1234 commented Oct 28, 2019

@Pro your toolchain has no multiarch support so it will not correctly link against Raspbian libraries. Configure gcc with multiarch support and apply the binutils patch from my repository to fix this.

To make it relocatable, built the dependencies static and configure everything with sysroot support.

@ali1234
Copy link
Contributor

ali1234 commented Oct 28, 2019

I also recommend stripping everything and removing unnecessary files as it will save over a gigabyte of space.

@ali1234
Copy link
Contributor

ali1234 commented Oct 28, 2019

Attached, my notes on how Linaro ABE configures each component to achieve a relocatable system:

configure-rel.txt

I've switched away from ABE back to crosstool-ng now because it was too hard to get ABE to apply the binutils patch (mainly because Linaro deleted all the public documentation about ABE.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests