Skip to content

Commit

Permalink
depfixer: fix darwin regression when install rpaths are used
Browse files Browse the repository at this point in the history
Fixes regression in commit 78e9009.

new_rpath is only set when install_rpath appears in meson.build.

Before this commit, we treated new_rpath as a single string to pass to
-add_rpath. This worked as long as new_rpath had a single rpath in it,
though for ELF we explicitly supported multiple rpaths separated with
":" (as binutils ld is quite happy with that too).

install_name_tool does not support paths with colons in it:
```
21:12 <awilfox> Load command 19          cmd LC_RPATH      cmdsize 40         path /bar:/baz:/eli:/ldap (offset 12)
21:12 <awilfox> Load command 20          cmd LC_RPATH      cmdsize 24         path /foo (offset 12)
21:14 <awilfox> so the result is: do not use colons
```

After commit 78e9009, we simply ended
up with one load command for LC_RPATH per char in new_rpath, which was
wrong in every possible case.

What we actually need to do is pass every distinct rpath as a separate
`-add_rpath` argument, so we split it on the colons instead. We do the
same splitting to ensure proper diff'ability for ELF anyways...

Fixes mesonbuild#13355
  • Loading branch information
eli-schwartz committed Jun 27, 2024
1 parent ef83d94 commit 7b43a2e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mesonbuild/scripts/depfixer.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def fix_darwin(fname: str, rpath_dirs_to_remove: T.Set[bytes], new_rpath: str, f
return
new_rpaths: OrderedSet[str] = OrderedSet()
if new_rpath:
new_rpaths.update(new_rpath)
new_rpaths.update(new_rpath.split(':'))
# filter out build-only rpath entries, like in
# fix_rpathtype_entry
remove_rpaths = [x.decode('utf8') for x in rpath_dirs_to_remove]
Expand Down

0 comments on commit 7b43a2e

Please sign in to comment.