Re: Building with musl in CI and the build farm

From: walther(at)technowledgy(dot)de
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Building with musl in CI and the build farm
Date: 2024-03-31 13:34:23
Message-ID: cfd3d974-d3e7-4adf-9574-0094044e91a4@technowledgy.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

About building one of the CI tasks with musl:

Andres Freund:
> I'd rather adapt one of the existing tasks, to avoid increasing CI costs unduly.

I looked into this and I think the only task that could be changed is
the SanityCheck. This is because this builds without any additional
features enabled. I guess that makes sense, because otherwise those
dependencies would first have to be built with musl-gcc as well.

> FWIW, except for one small issue, building postgres against musl works on debian and the tests pass if I install first.

After the fix for LD_LIBRARY_PATH this now works as expected without
installing first. I confirmed it works on debian with CC=musl-gcc.

> The small problem mentioned above is that on debian linux/fs.h isn't available
> when building with musl, which in turn causes src/bin/pg_upgrade/file.c to
> fail to compile.

According to [1], this can be worked around by linking some folders:

ln -s /usr/include/linux /usr/include/x86_64-linux-musl/
ln -s /usr/include/asm-generic /usr/include/x86_64-linux-musl/
ln -s /usr/include/x86_64-linux-gnu/asm /usr/include/x86_64-linux-musl/

Please find a patch to use musl-gcc in SanityCheck attached. Logs from
the CI run are in [2]. It has this in the configure phase:

[13:19:52.712] Using 'CC' from environment with value: 'ccache musl-gcc'
[13:19:52.712] C compiler for the host machine: ccache musl-gcc (gcc
10.2.1 "cc (Debian 10.2.1-6) 10.2.1 20210110")
[13:19:52.712] C linker for the host machine: musl-gcc ld.bfd 2.35.2
[13:19:52.712] Using 'CC' from environment with value: 'ccache musl-gcc'

So meson picks up musl-gcc properly. I also double checked that without
the links above, the build does indeed fail with the linux/fs.h error.

I assume the installation of musl-tools should be done in the
pg-vm-images repo instead of the additional script here?

Best,

Wolfgang

[1]:
https://debian-bugs-dist.debian.narkive.com/VlFkLigg/bug-789789-musl-fails-to-compile-stuff-that-depends-on-kernel-headers
[2]: https://cirrus-ci.com/task/5741892590108672

Attachment Content-Type Size
0001-Build-SanityCheck-against-musl.patch text/x-patch 1.1 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message 2024-04-01 00:22:53 RE: BUG #18416: Confirmation of Issue with PostgreSQL ODBC Driver for Windows
Previous Message Robert Haas 2024-03-30 17:35:54 Re: relfrozenxid may disagree with row XIDs after 1ccc1e05ae

Browse pgsql-hackers by date

  From Date Subject
Next Message Yugo NAGATA 2024-03-31 13:59:31 Re: Incremental View Maintenance, take 2
Previous Message Yugo NAGATA 2024-03-31 13:25:02 Re: pgbnech: allow to cancel queries during benchmark