NetBSD Problem Report #56959

From www@netbsd.org  Sun Aug  7 23:33:10 2022
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D74831A921F
	for <gnats-bugs@gnats.NetBSD.org>; Sun,  7 Aug 2022 23:33:10 +0000 (UTC)
Message-Id: <20220807233309.330971A9239@mollari.NetBSD.org>
Date: Sun,  7 Aug 2022 23:33:09 +0000 (UTC)
From: andres@anarazel.de
Reply-To: andres@anarazel.de
To: gnats-bugs@NetBSD.org
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
>Organization:
>Environment:
NetBSD localhost 9.3 NetBSD 9.3 (GENERIC) #0: Thu Aug  4 15:30:37 UTC 2022  mkrepro@mkrepro.NetBSD.org:/usr/src/sys/arch/amd64/compile/GENERIC amd64

>Description:
A part of meson was patched to not edit rpaths during installation anymore. See https://github.com/NetBSD/pkgsrc/blob/trunk/devel/meson/patches/patch-mesonbuild_scripts_depfixer.py

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.
>How-To-Repeat:
$ cat meson.build
project('rpath', 'c')

subdir('lib')

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

$ cat lib/meson.build 
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/meson.py setup build-meson-upstream
$ python3.9 /home/andres/src/meson/meson.py 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]


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

>Release-Note:

>Audit-Trail:
From: Andres Freund <andres@anarazel.de>
To: gnats-bugs@netbsd.org
Cc: 
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
 https://github.com/NetBSD/pkgsrc/commit/8ead3d6cf5da4e34a30488cb1ae94b7f53b09a82

Responsible-Changed-From-To: pkg-manager->wiz
Responsible-Changed-By: tnn@NetBSD.org
Responsible-Changed-When: Mon, 08 Aug 2022 00:17:25 +0000
Responsible-Changed-Why:
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 <prlw1@talktalk.net>
To: gnats-bugs@netbsd.org
Cc: prlw1@cam.ac.uk
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-By: wiz@NetBSD.org
Responsible-Changed-When: Mon, 08 Aug 2022 09:24:39 +0000
Responsible-Changed-Why:
comments provided


From: Thomas Klausner <wiz@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: tnn@NetBSD.org
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

 https://github.com/NetBSD/pkgsrc/commit/3b0ad53a37edf1d9e2535ac368f7bf53b2202d61

 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

 https://github.com/mesonbuild/meson/issues/314

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

 Thanks,
  Thomas

>Unformatted:

NetBSD Home
NetBSD PR Database Search

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