Repository: mesonbuild/meson

Issue:
[possible regression in 0.55] New rpath must not be longer than the old one
Several projects fail to build with meson with the error from the subject.
For example devel/gnome-builder: http://package22.nyi.freebsd.org/data/113amd64-default-PR244008/2020-07-15_21h37m37s/logs/errors/gnome-builder-3.28.4_4.log
See the list here: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=247935#c2

Could you please comment on this? Why did these build before and not with 0.55?

FreeBSD 12.1

Thanks,
Yuri


Discussion:
I looked at the code, that particular error code has existed (Unchanged I think) since 2016. It's possible that we changed either the BUILD rpath code or the install RPATH code in 0.55.
This is probably because earlier we reserved the exact amount of space needed by install_rpath and nuked everything else. Now we preserve rpaths coming from external sources but don't account for them when calculating how much space to reserve.
This bug is a show-stopper since so many ports are failing with this error.
I tried to reproduce this locally but could not. I.e. eog builds and installs just fine and the rpath length calculation also works. This may be FreeBSD specific. Would it be possible for you to run one of the failing builds with the patch from #7565 applied to Meson?
Note: the next stable point release will happen in the next couple of days. This open issue / merge request is marked for the point release but will not block its release.
With meson-0.55.1 the failure looks like this:

```
New rpath must not be longer than the old one.
 Old: b'/usr/local/lib/dpdk/pmds-20.0'
 New: b'/usr/local/lib/dpdk/pmds-20.0:/usr/local/lib/dpdk/pmds-20.0'
FAILED: meson-install 
```

See the log: http://package22.nyi.freebsd.org/data/113amd64-default-PR244008/2020-08-18_07h28m26s/logs/errors/dpdk-19.11.3.log
Attaching here in case the build log upstream expires: [dpdk-19.11.3.log](https://github.com/mesonbuild/meson/files/5113307/dpdk-19.11.3.log)


Resolving patch:
diff --git a/mesonbuild/scripts/depfixer.py b/mesonbuild/scripts/depfixer.py
--- a/mesonbuild/scripts/depfixer.py
+++ b/mesonbuild/scripts/depfixer.py
@@ -307,17 +307,20 @@ def fix_rpathtype_entry(self, rpath_dirs_to_remove, new_rpath, entrynum):
         self.bf.seek(rp_off)
 
         old_rpath = self.read_str()
-        new_rpaths = []
+        # Some rpath entries may come from multiple sources.
+        # Only add each one once.
+        new_rpaths = OrderedSet()
         if new_rpath:
-            new_rpaths.append(new_rpath)
+            new_rpaths.add(new_rpath)
         if old_rpath:
             # Filter out build-only rpath entries
             # added by get_link_dep_subdirs() or
             # specified by user with build_rpath.
-            for dir in old_rpath.split(b':'):
-                if not (dir in rpath_dirs_to_remove or
-                        dir == (b'X' * len(dir))):
-                    new_rpaths.append(dir)
+            for rpath_dir in old_rpath.split(b':'):
+                if not (rpath_dir in rpath_dirs_to_remove or
+                        rpath_dir == (b'X' * len(rpath_dir))):
+                    if rpath_dir:
+                        new_rpaths.add(rpath_dir)
 
         # Prepend user-specified new entries while preserving the ones that came from pkgconfig etc.
         new_rpath = b':'.join(new_rpaths)


Test patch: