-
Notifications
You must be signed in to change notification settings - Fork 6.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixup Macho-O rpath for osx-dynamic #39313
Conversation
NOT
category:community-triplet
|
Thanks for this.
It breaks with the assumption that tools will always link to release libraries. Do I have to forget this assumption? Also, as far as I can see on the installed |
I'm afraid the test is right: Tools from the debug config must link the debug libs. That's why it is designed this way, running an executable from an installed (test) port which loads a shared lib.
It is not so easy: Binaries in In particular, the autotools helper functions redirect debug binaries to Everything else is left mostly undefined in vcpkg. #17607 |
If |
How much does |
Good thought. Minimal. It doesn't take any |
FTR: fixed |
@m-kuhn, thanks for continuing to work on this; much appreciated. Could the portfile variable documentation be updated simultaneously as well? I presume an entry |
@sharadhr Good idea! Do you want to open a PR directly? |
@m-kuhn Sure, I can do that! The documentation is in a different repository, so I'll have to link in this change too. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@data-queue @JavierMatosD I know you both use macOS a lot of the time, can you check that this behavior seems reasonable to you?
I'm marking this 'request changes' only because EXCLUDE REGEX "\\\.
seems wrong to me and my other comments are kinda nitpicks.
find_program( | ||
install_name_tool_cmd | ||
NAMES install_name_tool | ||
DOC "Absolute path of install_name_tool cmd" | ||
REQUIRED | ||
) | ||
|
||
find_program( | ||
otool_cmd | ||
NAMES otool | ||
DOC "Absolute path of otool cmd" | ||
REQUIRED | ||
) | ||
|
||
find_program( | ||
file_cmd | ||
NAMES file | ||
DOC "Absolute path of file cmd" | ||
REQUIRED | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are these and what does a user need to do if they aren't present?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tools to modify and change dynamic libraries (install_name tool and otool) or inspect files (file tool).
In my experience they come pre-installed on macos systems, so I don't think "not present" is a real world scenario to take into account.
"name": "vcpkg-fixup-macho-rpath", | ||
"version-date": "2024-06-15", | ||
"description": "Test port to check the string replacement in z_vcpkg_fixup_macho_rpath", | ||
"supports": "native & osx" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test just does string replacements; shouldn't it work on all platforms rather than only osx?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follows the pattern of the linux/elf equivalent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We might want to migrate this to unit-test-cmake
.
But it doesn't have to be done now.
Co-authored-by: Billy O'Neal <[email protected]>
Thank you for the review @BillyONeal I have incorporated the suggestions. |
|
||
foreach(rpath IN LISTS rpath_list) | ||
execute_process( | ||
COMMAND "${install_name_tool_cmd}" -delete_rpath "${rpath}" "${macho_file}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about the LC_LOAD_DYLIB
field? How come we don't use install_name_tool -change
here for dependent libraries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have tested this approach with a wide variety of ports (qt, qt5, even python via open-vcpkg) and it worked reliably.
Do you have a port which needs attention or do you want to provide a specific alternative implementation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it works reliably, great! No further questions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @m-kuhn
I've seen the PR merged and I give it a try.
I think it may be needed to take into account the LC_LOAD_DYLIB
when it is pointing to other VCPKG dynamic libraries.
Here the output of a just built ffmpeg library, which depends on other ffmpeg libraries:
% otool -L libavcodec.60.31.102.dylib
libavcodec.60.31.102.dylib (architecture arm64):
@rpath/libavcodec.60.31.102.dylib (compatibility version 60.0.0, current version 60.31.102)
/Users/megadev/aag/vcpkg/packages/ffmpeg_arm64-osx-dynamic/lib/libswresample.4.dylib (compatibility version 4.0.0, current version 4.12.100)
/Users/megadev/aag/vcpkg/packages/ffmpeg_arm64-osx-dynamic/lib/libavutil.58.dylib (compatibility version 58.0.0, current version 58.29.100)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1336.0.0)
/System/Library/Frameworks/AudioToolbox.framework/Versions/A/AudioToolbox (compatibility version 1.0.0, current version 1000.0.0)
/System/Library/Frameworks/VideoToolbox.framework/Versions/A/VideoToolbox (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 2048.1.255)
/System/Library/Frameworks/CoreMedia.framework/Versions/A/CoreMedia (compatibility version 1.0.0, current version 1.0.0)
/System/Library/Frameworks/CoreVideo.framework/Versions/A/CoreVideo (compatibility version 1.2.0, current version 1.5.0)
/System/Library/Frameworks/CoreServices.framework/Versions/A/CoreServices (compatibility version 1.0.0, current version 1226.0.0)
We can see that the dependencies of the library have a path to the packages directory. I guess the LC_LOAD_DYLIB
s should be @rpath/<lib>
.
Sadly I didn't have time before to test it before merging. So sorry.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the feedback, much appreciated. I can reproduce this here.
Can you open an issue, so it's not forgotten?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay. Done #39890
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@data-queue @JavierMatosD I know you both use macOS a lot of the time, can you check that this behavior seems reasonable to you?
@BillyONeal. Not a full review but this looks good to me. otool
and install_name_tool
should be available (or at least highly likely to be available) if either Xcode
or Command Line Tools
is installed.
I'm marking this 'request changes' only because EXCLUDE REGEX "\. seems wrong to me and my other comments are kinda nitpicks.
This is no longer in the PR :)
Seems like your feedback was addressed :)
Thanks for the new feature! |
Extending microsoft#39313 to fix issues such as microsoft#14785 with openssl where libssl wasn't pointing to the rpath fixed id of libcrypto.
#8) Extending microsoft#39313 to fix issues such as microsoft#14785 with openssl where libssl wasn't pointing to the rpath fixed id of libcrypto. Co-authored-by: Derek Cyrus-Chow <[email protected]>
This sets install name id and rpath on shared libraries and executables for macos using
*-osx-*
triplets.It is supposed to solve general problems like #31719, continuing on #31720, also referring #23035
Fixed ports also include:
vcpkg install proj:x64-osx-dynamic
, executes the (installed)sqlite3
tool during buildvcpkg install gdk-pixbuf:x64-osx-dynamic
, executes a helper tool within the build folderWhat it does:
@rpath
prefixlib
is added torpath
(ordebug/lib
for anything within the debug folder).Open question: is this a problem and should it be required to also lookup libraries in other folders (apart from system libraries)? If yes, for which port?
Supersedes #36556, follows the rpath style of linux as suggested in #36556 (comment) .
The fixup can be disabled by changing
set(VCPKG_FIXUP_MACHO_RPATH OFF)
in the triplet.