From: walther@technowledgy.de
To: Andres Freund <andres@anarazel.de>
Cc: PostgreSQL-development <pgsql-hackers@postgresql.org>
Subject: Re: Building with musl in CI and the build farm
Date: Sun, 31 Mar 2024 15:34:23 +0200
Message-ID: <cfd3d974-d3e7-4adf-9574-0094044e91a4@technowledgy.de> (raw)
In-Reply-To: <0a48d551-50e1-4bd3-8d46-8421e3b1b724@technowledgy.de>
References: <4093813.1710899588@sss.pgh.pa.us>
<CA+hUKGKNK5V8XwwJJZm36s3EUy8V51xu4XiE8=26n=Wq3OGd4A@mail.gmail.com>
<4095435.1710900216@sss.pgh.pa.us>
<CA+hUKGK2cSx3dveMqBD+E9N=zJ0WawBcbk_jnPqmdWBM0DT_3Q@mail.gmail.com>
<477fa513-6bf0-456d-8d24-1e22a19df671@technowledgy.de>
<ZfrmN4WHuJgD95fw@momjian.us>
<CA+hUKGJzC4rr2Yr=QZyx9W83Wv=TVJHndKF1anjNLNXVUM7TqQ@mail.gmail.com>
<f98cd8de-1c66-491a-8409-e62c09932080@technowledgy.de>
<20240322001948.atp2eetusylgjyw2@awork3.anarazel.de>
<40543180-a0a2-495b-8d34-23b46c28f533@technowledgy.de>
<20240326001447.wcatfvx45tkmizji@awork3.anarazel.de>
<0a48d551-50e1-4bd3-8d46-8421e3b1b724@technowledgy.de>
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-dep...
[2]: https://cirrus-ci.com/task/5741892590108672Attachments:0001-Build-SanityCheck-against-musl.patch (text/x-patch, 1.1K) download
From 4a69d9851e7bbd7cd521d236847af9ebf5e6253b Mon Sep 17 00:00:00 2001
From: Wolfgang Walther <walther@technowledgy.de>
Date: Sun, 31 Mar 2024 15:17:43 +0200
Subject: [PATCH] Build SanityCheck against musl
---
.cirrus.tasks.yml | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/.cirrus.tasks.yml b/.cirrus.tasks.ymlindex 72f553e69f4..5815c51abbe 100644--- a/.cirrus.tasks.yml+++ b/.cirrus.tasks.yml@@ -69,6 +69,7 @@ task:
CCACHE_DIR: ${CIRRUS_WORKING_DIR}/ccache_dir
# no options enabled, should be small
CCACHE_MAXSIZE: "150M"
+ CC: ccache musl-gcc
# While containers would start up a bit quicker, building is a bit
# slower. This way we don't have to maintain a container image.
@@ -77,6 +78,14 @@ task:
ccache_cache:
folder: $CCACHE_DIR
+ setup_additional_packages_script: |+ apt-get update+ DEBIAN_FRONTEND=noninteractive apt-get -y install musl-tools+ ln -s -t /usr/include/x86_64-linux-musl/ \+ /usr/include/linux \+ /usr/include/asm-generic \+ /usr/include/x86_64-linux-gnu/asm+
create_user_script: |
useradd -m postgres
chown -R postgres:postgres .
--
2.44.0
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-bugs@postgresql.org
Cc: walther@technowledgy.de, andres@anarazel.de, pgsql-hackers@postgresql.org
Subject: Re: Building with musl in CI and the build farm
In-Reply-To: <cfd3d974-d3e7-4adf-9574-0094044e91a4@technowledgy.de>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox