[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Cross compilers for non-x86 hosts



Wookey <wookey@wookware.org> writes:

> On 2018-04-27 11:22 +0100, Alex Bennée wrote:
>>
>> Hi,
>>
>> I was pleasantly surprised to find the docker-ce in stretch was already
>> multi-arch aware so all the base Debian images where pulled down in
>> their aarch64 forms. However the images failed to build because the
>> compilers where not available in the aarch64 archive. For example:
>>
>>   https://packages.debian.org/sid/gcc-alpha-linux-gnu
>>
>> Only has binaries for amd64, i386 and an unofficial x32 build.
>>
>> So aside from the usual time and inclination is there anything in
>> particular stopping the cross compilers being built for the other
>> supported architectures?
>
> Obviously the full set of possible cross-compilers is large, and some
> will be very rarely used, so we choose a sensible subset to build in
> the archive. That is generally from fast/popular arches to
> slow/unpopular ones. It does probably now make sense to add more 'from
> arm64' cross compilers to the standard build list.
>
> But we will probably never have all combos in the archive.
>
> The fill-in for people needing cross-compilers which are not packaged
> is to use the cross-gcc-dev package, which will build you an arbitrary
> (set of) wrapper-package(s) which you can use to build cross-compilers
> using (essentially) the same mechanisms used in the standard
> packaging.
>
> This should be documented here:
> https://wiki.debian.org/CrossToolchains but that mostly hasn't been
> updated for 3 years so quite a lot is out of date, and I've failed to
> find a bit telling you how/when to use cross-gcc-dev.
>
> But I just tried it for alpha and it was a bit fafftastic and then
> didn't actually work due to some patch not applying.
>
> So a better plan is what you were trying to do:
>
>> I did download the gcc-defaults source package but I'm unsure what the
>> correct invocation is to build an individual set of packages for one
>> target. What would the correct dpkg-buildpkg invocation be to build the
>> alpha toolchain for example?
>
> gcc-defaults is the wrong package. gcc-7 or gcc-8 have the right machinery.
>
> DEB_BUILD_OPTIONS="nolang=d,go,java,objc,obj-c++,ada" unstripped_exe=no dpkg-buildpackage --target-arch alpha -d -T control; \
> DEB_BUILD_OPTIONS="nolang=d,go,java,objc,obj-c++,ada" unstripped_exe=no dpkg-buildpackage --target-arch alpha -B -d -uc -us;
>
> for the case noted you should be able to do:
> apt source gcc-7
> cd gcc-7-7.3.0
> DEB_BUILD_OPTIONS="nolang=d,go,java,objc,obj-c++,ada" unstripped_exe=no dpkg-buildpackage --target-arch alpha -d -T control
> DEB_BUILD_OPTIONS="nolang=d,go,java,objc,obj-c++,ada" unstripped_exe=no dpkg-buildpackage --target-arch alpha -B -d -uc -us
>
> You may need to build a version-matching linux-libc-dev:alpha first
> (because the one in the alpha ports repo is out of date (and thus
> multiarch sync) with the version in supported arches:

Hmmm something went wrong because after a long build I got:

root@93264eba3325:/build# /usr/bin/gcc-7 -dumpmachine
aarch64-linux-gnu

Just to be sure it wasn't confused about what was installed:

root@93264eba3325:/build# dpkg --contents gcc-7_7.3.0-16_arm64.deb
drwxr-xr-x root/root         0 2018-04-11 17:10 ./
drwxr-xr-x root/root         0 2018-04-11 17:10 ./usr/
drwxr-xr-x root/root         0 2018-04-11 17:10 ./usr/bin/
-rwxr-xr-x root/root    969608 2018-04-11 17:10 ./usr/bin/aarch64-linux-gnu-gcc-7
-rwxr-xr-x root/root     27104 2018-04-11 17:10 ./usr/bin/aarch64-linux-gnu-gcc-ar-7
-rwxr-xr-x root/root     27104 2018-04-11 17:10 ./usr/bin/aarch64-linux-gnu-gcc-nm-7
-rwxr-xr-x root/root     27104 2018-04-11 17:10 ./usr/bin/aarch64-linux-gnu-gcc-ranlib-7
-rwxr-xr-x root/root    581632 2018-04-11 17:10 ./usr/bin/aarch64-linux-gnu-gcov-7
-rwxr-xr-x root/root    454520 2018-04-11 17:10 ./usr/bin/aarch64-linux-gnu-gcov-dump-7
-rwxr-xr-x root/root    475072 2018-04-11 17:10 ./usr/bin/aarch64-linux-gnu-gcov-tool-7

My docker based recipe was:

RUN mkdir -p /build
WORKDIR /build
RUN dpkg --add-architecture alpha
RUN apt source linux
RUN cd linux-* && dpkg-buildpackage -Pstage1 -aalpha
RUN dpkg -i linux-libc-*alpha.deb
RUN apt source gcc-7
RUN cd gcc-7* && DEB_BUILD_OPTIONS="nolang=d,go,java,objc,obj-c++,ada" unstripped_exe=no dpkg-buildpackage --target-arch alpha -d -T control
RUN cd gcc-7* && DEB_BUILD_OPTIONS="nolang=d,go,java,objc,obj-c++,ada" unstripped_exe=no dpkg-buildpackage --target-arch alpha -B -d -uc -us
RUN ls -l

By the way is there a way to:

  - limit the total threads used (24 is too many for the DevBox)
  - skip the gcc test suite while building?

Also I guess I need to build a glibc?

-rw-r--r-- 1 root root  796K May  1 18:44 libgcc-7-dev_7.3.0-16_arm64.deb
-rw-r--r-- 1 root root  1.4M May  1 18:44 libstdc++-7-dev_7.3.0-16_arm64.deb
-rw-r--r-- 1 root root  5.3M May  1 18:45 libstdc++6-7-dbg_7.3.0-16_arm64.deb

got built but no libc

>
> apt source linux
> sudo apt-get -Pstage1 --only-source build-dep linux
> cd linux-*; dkpg-buildpackage -Pstage1 -aalpha
> sudo dpkg -i ../linux-libc-dev_4.15.17-1_alpha.deb
>
> This didn't complete for me but got a fair way (but I wasn't testing on arm64)
>
> Have a go.
>
> Wookey


--
Alex Bennée


Reply to: