NetBSD Problem Report #56959

From  Sun Aug  7 23:33:10 2022
Return-Path: <>
Received: from ( [])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "", Issuer " CA" (not verified))
	by (Postfix) with ESMTPS id D74831A921F
	for <>; Sun,  7 Aug 2022 23:33:10 +0000 (UTC)
Message-Id: <>
Date: Sun,  7 Aug 2022 23:33:09 +0000 (UTC)
Subject: meson patch breaks meson functionality
X-Send-Pr-Version: www-1.0

>Number:         56959
>Category:       pkg
>Synopsis:       meson patch breaks meson functionality
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Aug 07 23:35:00 +0000 2022
>Last-Modified:  Mon Aug 08 09:25:02 +0000 2022
>Originator:     Andres Freund
>Release:        9.3
NetBSD localhost 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022 amd64

A part of meson was patched to not edit rpaths during installation anymore. See

Unfortunately this leads to broken rpaths if the build spec uses either build_rpath / install_rpath. And even if it does not explicitly, meson automatically adds build rpaths between binaries and libraries in the build dir, which now don't get removed anymore.

Unfortunately the commit history does not provide any detail about why this patch was added.  Possibly because older versions of meson had a bug that overzelously removed rpaths specified via CFLAGS?

Postgres is working on porting the buildsystem to meson. This breaks postgres' tests.
$ cat
project('rpath', 'c')


executable('rpathtest', 'rpathtest.c', link_with: mylib, build_rpath: 'build_rpath_foo', install_rpath: 'install_rpath_foo', install: true)

$ cat lib/ 
mylib = shared_library('mylib', 'mylib.c')
andres@netbsd9.1:[/home/andres/src/repro]$ cat rpathtest.c 
int main(void)
  return 0;
$ cat lib/mylib.c 
$ readelf -d build/test_install/usr/local/bin/rpathtest |grep RPATH
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/lib:build_rpath_foo]
$ readelf -d build/rpathtest |grep RPATH
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/lib:build_rpath_foo]

note the presence of $ORIGIN/lib (automatically added by meson) and build_rpath_foo in both binaries.

This does not happen with upstream meson:
$ python3.9 /home/andres/src/meson/ setup build-meson-upstream
$ python3.9 /home/andres/src/meson/ install --destdir test_install -C build-meson-upstream
$ readelf -d build-meson-upstream/rpathtest |grep RPATH
 0x000000000000000f (RPATH)              Library rpath: [$ORIGIN/lib:build_rpath_foo]
$ readelf -d build-meson-upstream/test_install/usr/local/bin/rpathtest |grep RPATH
 0x000000000000000f (RPATH)              Library rpath: [install_rpath_foo]

Remove the patch? But it's hard to say without understanding why this change was made.


From: Andres Freund <>
Subject: Re: pkg/56959: meson patch breaks meson functionality
Date: Sun, 7 Aug 2022 16:42:25 -0700

 The original commit adding that patch is actually older, hidden by originally
 introduced to py-meson and then copied. See

Responsible-Changed-From-To: pkg-manager->wiz
Responsible-Changed-When: Mon, 08 Aug 2022 00:17:25 +0000
Assign to author of patch.
We could make meson only apply pkgsrc fixups if os.getenv("PKGTOOLS_VERSION") is not None,
But it is not clear if/why the patch is still needed.

From: Patrick Welche <>
Subject: Re: pkg/56959: meson patch breaks meson functionality
Date: Mon, 8 Aug 2022 09:55:54 +0100

 Not sure if this is the problem, but I remember making these observations
 years ago: meson would add (correctly) rpaths to build directories, and
 then on install replace them with the install directories. In the editing
 part, (from vague memory), if the build directory was long, there would
 be a long number of bytes allocated in the binary executable into which
 the probably shorter install rpath was written. This meant that the
 builds didn't count as reproducible, even though the binary behaved in
 the same way. Meson then changed the build directory rpaths to use
 $ORIGIN, so the build directory path lengths would be reproducible.
 pkgsrc then removed all rpaths to remove $ORIGIN (AFAIR). (For some
 reason gobject-introspection got flack, as a meson using package that
 needs built libraries.)

Responsible-Changed-From-To: wiz->pkg-manager
Responsible-Changed-When: Mon, 08 Aug 2022 09:24:39 +0000
comments provided

From: Thomas Klausner <>
Subject: Re: pkg/56959 (meson patch breaks meson functionality)
Date: Mon, 8 Aug 2022 11:24:04 +0200

 IIRC, this patch was the replacement for

 which had the commit message:

 --- begin ---
 Remove the stripping (which might leave build rpaths inside installed binaries
 but at least gives us runnable binaries) until meson fixes this properly.
 --- end ---

 and linked to

 I'm not interested in working on meson. Please just check what the
 rpaths of the installed files are before/after removing the patch.



NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.46 2020/01/03 16:35:01 leot Exp $
$NetBSD:,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2020 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.