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
From 4a69d9851e7bbd7cd521d236847af9ebf5e6253b Mon Sep 17 00:00:00 2001
From: Wolfgang Walther <walt...@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.yml
index 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