Re: Building with meson on NixOS/nixpkgs

Lists: pgsql-hackers
From: Wolfgang Walther <walther(at)technowledgy(dot)de>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Building with meson on NixOS/nixpkgs
Date: 2024-03-16 11:48:31
Message-ID: ca8f37e1-a2c3-40e2-91f6-59c3d3652ad4@technowledgy.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

To build on NixOS/nixpkgs I came up with a few small patches to
meson.build. All of this works fine with Autoconf/Make already.

Attachment Content-Type Size
0001-Fallback-to-uuid-for-ossp-uuid-with-meson.patch text/x-patch 1.0 KB
0002-Fallback-to-clang-in-PATH-with-meson.patch text/x-patch 1021 bytes
0003-Support-absolute-bindir-libdir-in-regression-tests-w.patch text/x-patch 2.9 KB

From: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
To: Wolfgang Walther <walther(at)technowledgy(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-03-18 12:25:58
Message-ID: CAN55FZ20xWGdj1KnQJ20TsnXHy2Tgbxmp82Ci8RvHktOyJ_GSw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

Thank you for the patches!

On Sat, 16 Mar 2024 at 14:48, Wolfgang Walther <walther(at)technowledgy(dot)de> wrote:
>
> To build on NixOS/nixpkgs I came up with a few small patches to
> meson.build. All of this works fine with Autoconf/Make already.

I do not have NixOS but I confirm that patches cleanly apply to master
and do pass CI. I have a small feedback:

0001 & 0002: Adding code comments to explain why they have fallback
could be nice.
0003: Looks good to me.

--
Regards,
Nazir Bilal Yavuz
Microsoft


From: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
To: Wolfgang Walther <walther(at)technowledgy(dot)de>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-03-18 19:03:53
Message-ID: 202403181903.2wyoxgv5eduw@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 2024-Mar-16, Wolfgang Walther wrote:

> The upstream name for the ossp-uuid package / pkg-config file is "uuid". Many
> distributions change this to be "ossp-uuid" to not conflict with e2fsprogs.

I can confirm that this is true for Debian, at least; the packaging
rules have this in override_dh_install:

install -D -m 644 debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/pkgconfig/uuid.pc \
debian/libossp-uuid-dev/usr/lib/pkgconfig/ossp-uuid.pc

which matches the fact that Engelschall's official repository has the
file named simply uuid.pc:
https://github.com/rse/uuid/blob/master/uuid.pc.in

--
Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/


From: Wolfgang Walther <walther(at)technowledgy(dot)de>
To: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-03-21 20:44:16
Message-ID: 35a90846-17f3-43c4-a483-b7605e584c6e@technowledgy.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Nazir Bilal Yavuz:
> 0001 & 0002: Adding code comments to explain why they have fallback
> could be nice.
> 0003: Looks good to me.

Added some comments in the attached.

Best,

Wolfgang

Attachment Content-Type Size
v2-0001-Fallback-to-uuid-for-ossp-uuid-with-meson.patch text/x-patch 1.1 KB
v2-0002-Fallback-to-clang-in-PATH-with-meson.patch text/x-patch 1.1 KB
v2-0003-Support-absolute-bindir-libdir-in-regression-test.patch text/x-patch 2.9 KB

From: walther(at)technowledgy(dot)de
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-03-29 18:47:54
Message-ID: 5d6b6485-9eff-44a0-99ac-661fdeb72a21@technowledgy.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Wolfgang Walther:
> To build on NixOS/nixpkgs I came up with a few small patches to
> meson.build. All of this works fine with Autoconf/Make already.

In v3, I added another small patch for meson, this one about proper
handling of -Dlibedit_preferred when used together with -Dreadline=enabled.

Best,

Wolfgang

Attachment Content-Type Size
v3-0001-Fallback-to-uuid-for-ossp-uuid-with-meson.patch text/x-patch 1.1 KB
v3-0002-Fallback-to-clang-in-PATH-with-meson.patch text/x-patch 1.1 KB
v3-0003-Support-absolute-bindir-libdir-in-regression-test.patch text/x-patch 2.9 KB
v3-0004-Support-falling-back-to-non-preferred-readline-im.patch text/x-patch 2.4 KB

From: Nazir Bilal Yavuz <byavuz81(at)gmail(dot)com>
To: walther(at)technowledgy(dot)de
Cc: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-04-01 10:55:45
Message-ID: CAN55FZ2J=+bvMtzq18hsf=-FJdWzJo20gqLgO=nMLd3=W8Fudg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

From your prior reply:

On Thu, 21 Mar 2024 at 23:44, Wolfgang Walther <walther(at)technowledgy(dot)de> wrote:
>
> Nazir Bilal Yavuz:
> > 0001 & 0002: Adding code comments to explain why they have fallback
> > could be nice.
> > 0003: Looks good to me.
>
> Added some comments in the attached.

Comments look good, thanks.

On Fri, 29 Mar 2024 at 21:48, <walther(at)technowledgy(dot)de> wrote:
>
> In v3, I added another small patch for meson, this one about proper
> handling of -Dlibedit_preferred when used together with -Dreadline=enabled.

You are right. I confirm the bug and your proposed patch fixes this.

--
Regards,
Nazir Bilal Yavuz
Microsoft


From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: walther(at)technowledgy(dot)de, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-04-17 11:49:53
Message-ID: 1676dbf7-9182-4e2d-8793-752a3fbac990@eisentraut.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 29.03.24 19:47, walther(at)technowledgy(dot)de wrote:
> - uuid = dependency('ossp-uuid', required: true)
> + # upstream is called "uuid", but many distros change this to
"ossp-uuid"
> + uuid = dependency('ossp-uuid', 'uuid', required: true)

How would this behave if you have only uuid.pc from e2fsprogs installed
but choose -Duuid=ossp? Then it would pick up uuid.pc here, but fail to
compile later?


From: walther(at)technowledgy(dot)de
To: Peter Eisentraut <peter(at)eisentraut(dot)org>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-04-17 12:02:41
Message-ID: ab26849b-58bc-4a44-8383-db39072d857d@technowledgy.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Peter Eisentraut:
> On 29.03.24 19:47, walther(at)technowledgy(dot)de wrote:
> > -    uuid = dependency('ossp-uuid', required: true)
> > +    # upstream is called "uuid", but many distros change this to
> "ossp-uuid"
> > +    uuid = dependency('ossp-uuid', 'uuid', required: true)
>
> How would this behave if you have only uuid.pc from e2fsprogs installed
> but choose -Duuid=ossp?  Then it would pick up uuid.pc here, but fail to
> compile later?

It would still fail the meson setup step, because for e2fs we have:

uuidfunc = 'uuid_generate'
uuidheader = 'uuid/uuid.h'

while for ossp we have:

uuidfunc = 'uuid_export'
uuidheader = 'uuid.h'

and later we do:

if not cc.has_header_symbol(uuidheader, uuidfunc, args: test_c_args,
dependencies: uuid)
error('uuid library @0@ missing required function
@1@'.format(uuidopt, uuidfunc))
endif

Best,

Wolfgang


From: "Tristan Partin" <tristan(at)neon(dot)tech>
To: "Heikki Linnakangas" <hlinnaka(at)iki(dot)fi>, <walther(at)technowledgy(dot)de>
Cc: "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-07-26 20:01:14
Message-ID: D2ZQL6TH3KNS.BDVYQLEYP1BM@neon.tech
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Heikki asked me to take a look at this patchset for the commitfest.
Looks good to me.

Heikki, just be careful rebasing the first patch. You need to make sure
the newly set `required: false` gets carried forward.

--
Tristan Partin
Neon (https://neon.tech)


From: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
To: Tristan Partin <tristan(at)neon(dot)tech>, walther(at)technowledgy(dot)de
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-07-27 11:17:51
Message-ID: d7d2f1b7-481f-4055-a809-fb974a810631@iki.fi
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On 26/07/2024 23:01, Tristan Partin wrote:
> Heikki asked me to take a look at this patchset for the commitfest.
> Looks good to me.
>
> Heikki, just be careful rebasing the first patch. You need to make sure
> the newly set `required: false` gets carried forward.

Committed and backpatched to v16 and v17. Thanks for the good
explanations in the commit messages, Walther!

--
Heikki Linnakangas
Neon (https://neon.tech)


From: Andres Freund <andres(at)anarazel(dot)de>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: Tristan Partin <tristan(at)neon(dot)tech>, walther(at)technowledgy(dot)de, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-08-09 16:13:58
Message-ID: 3slhkdzxdrcflfk6cw3g77lauqjxua3osvkbw5puxsnlpt2avu@7y2isgyzkjk4
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Hi,

commit 4d8de281b5834c8f5e0be6ae21e884e69dffd4ce
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Date: 2024-07-27 13:53:11 +0300

Fallback to clang in PATH with meson

Some distributions put clang into a different path than the llvm
binary path.

For example, this is the case on NixOS / nixpkgs, which failed to find
clang with meson before this patch.

I think this is a bad change unfortunately - this way clang and llvm version
can mismatch. Yes, we've done it that way for autoconf, but back then LLVM
broke compatibility far less often.

commit a00fae9d43e5adabc56e64a4df6d332062666501
Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
Date: 2024-07-27 13:53:08 +0300

Fallback to uuid for ossp-uuid with meson

The upstream name for the ossp-uuid package / pkg-config file is
"uuid". Many distributions change this to be "ossp-uuid" to not
conflict with e2fsprogs.

This lookup fails on distributions which don't change this name, for
example NixOS / nixpkgs. Both "ossp-uuid" and "uuid" are also checked
in configure.ac.

Author: Wolfgang Walther
Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
Reviewed-by: Tristan Partin
Discussion: https://www.postgresql.org/message-id/ca8f37e1-a2c3-40e2-91f6-59c3d3652ad4@technowledgy.de
Backpatch: 16-, where meson support was added

I think this is a redundant change with

commit 2416fdb3ee30bdd2810408f93f14d47bff840fea
Author: Andres Freund <andres(at)anarazel(dot)de>
Date: 2024-07-20 13:51:08 -0700

meson: Add support for detecting ossp-uuid without pkg-config

This is necessary as ossp-uuid on windows installs neither a pkg-config nor a
cmake dependency information. Nor is there another supported uuid
implementation available on windows.

Reported-by: Dave Page <dpage(at)pgadmin(dot)org>
Reviewed-by: Tristan Partin <tristan(at)partin(dot)io>
Discussion: https://postgr.es/m/20240709065101.xhc74r3mdg2lmn4w@awork3.anarazel.de
Backpatch: 16-, where meson support was added

Greetings,

Andres Freund


From: "Tristan Partin" <tristan(at)partin(dot)io>
To: "Andres Freund" <andres(at)anarazel(dot)de>, "Heikki Linnakangas" <hlinnaka(at)iki(dot)fi>
Cc: <walther(at)technowledgy(dot)de>, "PostgreSQL Hackers" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-08-09 16:49:08
Message-ID: D3BJ9QJC7QZI.3BL9AW6QVCKJ5@partin.io
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

On Fri Aug 9, 2024 at 11:14 AM CDT, Andres Freund wrote:
> Hi,
>
>
> commit 4d8de281b5834c8f5e0be6ae21e884e69dffd4ce
> Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
> Date: 2024-07-27 13:53:11 +0300
>
> Fallback to clang in PATH with meson
>
> Some distributions put clang into a different path than the llvm
> binary path.
>
> For example, this is the case on NixOS / nixpkgs, which failed to find
> clang with meson before this patch.
>
>
> I think this is a bad change unfortunately - this way clang and llvm version
> can mismatch. Yes, we've done it that way for autoconf, but back then LLVM
> broke compatibility far less often.

See the attached patch on how we could make this situation better.

> commit a00fae9d43e5adabc56e64a4df6d332062666501
> Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
> Date: 2024-07-27 13:53:08 +0300
>
> Fallback to uuid for ossp-uuid with meson
>
> The upstream name for the ossp-uuid package / pkg-config file is
> "uuid". Many distributions change this to be "ossp-uuid" to not
> conflict with e2fsprogs.
>
> This lookup fails on distributions which don't change this name, for
> example NixOS / nixpkgs. Both "ossp-uuid" and "uuid" are also checked
> in configure.ac.
>
> Author: Wolfgang Walther
> Reviewed-by: Nazir Bilal Yavuz, Alvaro Herrera, Peter Eisentraut
> Reviewed-by: Tristan Partin
> Discussion: https://www.postgresql.org/message-id/ca8f37e1-a2c3-40e2-91f6-59c3d3652ad4@technowledgy.de
> Backpatch: 16-, where meson support was added
>
> I think this is a redundant change with
>
> commit 2416fdb3ee30bdd2810408f93f14d47bff840fea
> Author: Andres Freund <andres(at)anarazel(dot)de>
> Date: 2024-07-20 13:51:08 -0700
>
> meson: Add support for detecting ossp-uuid without pkg-config
>
> This is necessary as ossp-uuid on windows installs neither a pkg-config nor a
> cmake dependency information. Nor is there another supported uuid
> implementation available on windows.
>
> Reported-by: Dave Page <dpage(at)pgadmin(dot)org>
> Reviewed-by: Tristan Partin <tristan(at)partin(dot)io>
> Discussion: https://postgr.es/m/20240709065101.xhc74r3mdg2lmn4w@awork3.anarazel.de
> Backpatch: 16-, where meson support was added

I'm not sure I would call them redundant. It's cheaper (and better) to
do a pkg-config lookup than it is to do the various checks in your
patch. I think the two patches are complementary. Yours services Windows
plus anywhere else that doesn't have a pkg-config file, while Wolfgang's
services distros that install the pkg-config with a different name.

--
Tristan Partin
https://tristan.partin.io

Attachment Content-Type Size
v1-0001-Use-the-found-LLVM-version-when-finding-clang.patch text/x-patch 1.2 KB

From: Wolfgang Walther <walther(at)technowledgy(dot)de>
To: Tristan Partin <tristan(at)partin(dot)io>, Andres Freund <andres(at)anarazel(dot)de>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-08-17 21:24:43
Message-ID: a63ae81b-bb19-4dad-b787-7e5d6414ebfb@technowledgy.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Tristan Partin:
> On Fri Aug 9, 2024 at 11:14 AM CDT, Andres Freund wrote:
> [..]
>> commit a00fae9d43e5adabc56e64a4df6d332062666501
>> Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
>> Date:   2024-07-27 13:53:08 +0300
>>
>>     Fallback to uuid for ossp-uuid with meson
>> [..]
>>
>> I think this is a redundant change with
>>
>> commit 2416fdb3ee30bdd2810408f93f14d47bff840fea
>> Author: Andres Freund <andres(at)anarazel(dot)de>
>> Date:   2024-07-20 13:51:08 -0700
>>
>>     meson: Add support for detecting ossp-uuid without pkg-config
>> [..]
>
> I'm not sure I would call them redundant. It's cheaper (and better) to
> do a pkg-config lookup than it is to do the various checks in your
> patch. I think the two patches are complementary. Yours services Windows
> plus anywhere else that doesn't have a pkg-config file, while Wolfgang's
> services distros that install the pkg-config with a different name.

Agreed.

There is also a small difference in output for meson: When uuid is
queried via pkg-config, meson also detects the version, so I get this
output:

External libraries
[..]
uuid : YES 1.6.2

Without pkg-config:

External libraries
[..]
uuid : YES

Best,

Wolfgang


From: Wolfgang Walther <walther(at)technowledgy(dot)de>
To: Tristan Partin <tristan(at)partin(dot)io>, Andres Freund <andres(at)anarazel(dot)de>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Building with meson on NixOS/nixpkgs
Date: 2024-08-17 21:43:37
Message-ID: 97ba8976-9a08-45b3-ad2c-fe13bbc7d140@technowledgy.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Lists: pgsql-hackers

Tristan Partin:
> On Fri Aug 9, 2024 at 11:14 AM CDT, Andres Freund wrote:
>> commit 4d8de281b5834c8f5e0be6ae21e884e69dffd4ce
>> Author: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
>> Date:   2024-07-27 13:53:11 +0300
>>
>>     Fallback to clang in PATH with meson
>> [..]
>>
>> I think this is a bad change unfortunately - this way clang and llvm
>> version
>> can mismatch. Yes, we've done it that way for autoconf, but back then
>> LLVM
>> broke compatibility far less often.
>
> See the attached patch on how we could make this situation better.

Works great.

With the correct clang on path:

Program clang found: YES 18.1.8 18.1.8
(/nix/store/mr1y1rxkx59dr2bci2akmw2zkbbpmc15-clang-wrapper-18.1.8/bin/clang)

With a mismatching version on path:

Program
/nix/store/x4gwwwlw2ylv0d9vjmkx3dmlcb7gingd-llvm-18.1.8/bin/clang clang
found: NO found 16.0.6 but need: '18.1.8'
(/nix/store/r85xsa9z0s04n0y21xhrii47bh74g2a8-clang-wrapper-16.0.6/bin/clang)

Yes, the match is exact, also fails with a newer version:

Program
/nix/store/x4gwwwlw2ylv0d9vjmkx3dmlcb7gingd-llvm-18.1.8/bin/clang clang
found: NO found 19.1.0 but need: '18.1.8'
(/nix/store/rjsfx6sxjpkgd4f9hl9apm0n8dk7jd9w-clang-wrapper-19.1.0-rc2/bin/clang)

+1 for this patch.

Best,

Wolfgang