Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 642616

Summary: sys-devel/binutils-config: Extend ldwrapper to use -rpath on macOS
Product: Gentoo/Alt Reporter: Michael Weiser <michael>
Component: Prefix SupportAssignee: Gentoo Prefix <prefix>
Status: RESOLVED FIXED    
Severity: normal    
Priority: Normal    
Version: unspecified   
Hardware: All   
OS: OS X   
Whiteboard:
Package list:
Runtime testing required: ---
Bug Depends on:    
Bug Blocks: 642656    
Attachments: Add -rpath support to ldwrapper

Description Michael Weiser 2017-12-29 11:15:27 UTC
Since even libc++.dylib is now built with an @rpath install name by cmake by default, I propose to extend ldwrapper in binutils-config to use -rpath on macOS similar to other systems. This way prefix system dirs are unconditionally added to all binaries' rpath.

# otool -L usr/lib/libc++.dylib 
usr/lib/libc++.dylib:
	@rpath/libc++.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libc++abi.dylib (compatibility version 1.0.0, current version 400.7.0)
	@rpath/libc++abi.1.dylib (compatibility version 1.0.0, current version 1.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1252.0.0)

# otool -l usr/bin/cmake | grep LC_LOAD_DYLIB\\\|\ name\\\|LC_RPATH\\\|path
         name /usr/lib/dyld (offset 12)
          cmd LC_LOAD_DYLIB
         name /Users/michael/nobak/gentoo/usr/lib/libexpat.1.dylib (offset 24)
          cmd LC_LOAD_DYLIB
         name /Users/michael/nobak/gentoo/usr/lib/libz.1.dylib (offset 24)
          cmd LC_LOAD_DYLIB
         name /Users/michael/nobak/gentoo/usr/lib/libarchive.13.dylib (offset 24)
          cmd LC_LOAD_DYLIB
         name /Users/michael/nobak/gentoo/usr/lib/libcurl.4.dylib (offset 24)
          cmd LC_LOAD_DYLIB
         name /Users/michael/nobak/gentoo/usr/lib/libuv.1.dylib (offset 24)
          cmd LC_LOAD_DYLIB
         name /Users/michael/nobak/gentoo/usr/lib/librhash.0.dylib (offset 24)
          cmd LC_LOAD_DYLIB
         name /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (offset 24)
          cmd LC_LOAD_DYLIB
         name @rpath/libc++.1.dylib (offset 24)
          cmd LC_LOAD_DYLIB
         name /usr/lib/libSystem.B.dylib (offset 24)
          cmd LC_RPATH
         path /Users/michael/nobak/gentoo/usr/lib (offset 12)
          cmd LC_RPATH
         path /Users/michael/nobak/gentoo/lib (offset 12)


Reproducible: Always
Comment 1 Michael Weiser 2017-12-29 11:17:13 UTC
Created attachment 511956 [details]
Add -rpath support to ldwrapper

Extend ldwrapper to inject -rpath options into the linker command line
on darwin as well. Only do so if ld64 would not refuse to accept them.
This can happen if the output type doesn't support it (static, kext,
...) or the deployment target is unspecified or did not support -rpath
yet (< 10.5). The latter is not usually a problem since portage
(MACOSX_DEPLOYMENT_TARGET) and clang (-macosx_version_min) always set
the deployment target explicitly.
Comment 2 Larry the Git Cow gentoo-dev 2017-12-29 15:01:48 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/proj/prefix.git/commit/?id=5512e7b13a99aed764a069dc1ad7aa3059203b8d

commit 5512e7b13a99aed764a069dc1ad7aa3059203b8d
Author:     Fabian Groffen <grobian@gentoo.org>
AuthorDate: 2017-12-29 15:01:38 +0000
Commit:     Fabian Groffen <grobian@gentoo.org>
CommitDate: 2017-12-29 15:01:38 +0000

    sys-devel/binutils-config: revbump to enable -rpath on Darwin
    
    Closes: https://bugs.gentoo.org/642616
    Package-Manager: Portage-2.3.18-prefix, Repoman-2.3.6

 sys-devel/binutils-config/Manifest                 |  1 +
 .../binutils-config/binutils-config-5-r03.1.ebuild |  2 +-
 .../binutils-config/binutils-config-5-r03.2.ebuild |  2 +-
 .../binutils-config/binutils-config-5-r03.3.ebuild | 77 ++++++++++++++++++++++
 4 files changed, 80 insertions(+), 2 deletions(-)