[debian-mysql] Galera-4 cross-building advice
Helmut Grohne
helmut at subdivi.de
Mon Nov 2 04:50:52 GMT 2020
Hi Otto,
On Sun, Nov 01, 2020 at 10:46:15PM +0200, Otto Kekäläinen wrote:
> However on Salsa-CI at
> https://salsa.debian.org/mariadb-team/galera-4/-/jobs/1126604 it fails
> with:
>
> Host: linux x86_64 32bit
> Signature: version: 4.6, revision: 323e509
> Using C compiler executable: gcc
> C compiler version is: b'gcc (Debian 10.2.0-16) 10.2.0'
> Using C++ compiler executable: g++
> C++ compiler version is: b'g++ (Debian 10.2.0-16) 10.2.0'
> Checking for C library pthread... no
> Error: pthread library not found
>
> The Salsa-CI seems to run some kind of cross-build on amd64 -> i386.
This is not a cross build. When you see that the compiler executable is
"gcc" without a triplet prefix, it is not a cross build. You also note
that the dumped variables DEB_BUILD_ARCH and DEB_HOST_ARCH equal as they
always do for native builds.
> What do you suggest I change in Galera-4 sources to make it
> cross-build and the Salsa-CI pass?
This is two distinct questions. I suppose you're more interested in
making the native salsa-ci build pass. I can tell you what happens here.
You build with scons. scons runs uname and figures that you are running
a 64bit kernel. Then it notices that your compiler outputs 32bit code.
It concludes that if you have a 64bit kernel and 32bit code, then you
must be compiling for x32 and it inserts a -mx32. This is not using
cross toolchains, but the older multilib instead.
The root cause is using os.uname() to base any decisions on. It breaks
cross building, but it also breaks your native i386 build here. Don't do
that. So here goes my advice.
* Don't use scons. It's one of the few build systems that has very
little support for cross building. All you can do here is set
environment variables and hope for the best.
* Don't call uname to detect anything. If you must do, use
battle-tested code such as autoconf's config.guess.
* If you must know the host architecture, make a flag to allow a user
replacing it. That would have saved you here as you could have simply
passed the right architecture bypassing the uname check.
* Don't add -mx32/-m32/-m64 to the compiler flags ever. If they're
needed, it is the responsibility of the builder.
* If you still need to detect the architecture and you don't want to
switch away from scons, detect the architecture from $CC -dumpmachine
instead of uname. It is way more reliable.
So now you have five options to fix. Any of them would have avoided the
failure.
This leads us to cross building galera-4. galera-4 currently cannot be
cross built, because it Buid-Depends on scons and scons is not marked
Multi-Arch: foreign, because it does not supprot cross building in any
sane way. So my first recommendation for making galera-4 cross buildable
is not using scons.
Beyond scons, there are little issues with build dependencies. I've
attempted a build that pretends scsons was M-A:foreign. For telling
scons about the compiler, you need to export CC and friends. This is
easily done via including this snippet into your debian/rules:
DPKG_EXPORT_BUILDTOOLS=1
-include /usr/share/dpkg/buildtools.mk
Doing these would get us quite far until it would pass -msse4.2
somewhere to a (e.g. ppc64el) compiler. This - again - is a consequence
of using uname. I guess that using the -dumpmachine approach together
with exporting CC/CXX and marking scons Multi-Arch: foreign might
actually go quite far.
Helmut
More information about the pkg-mysql-maint
mailing list