microsoft / vcpkg

C++ Library Manager for Windows, Linux, and MacOS
MIT License
23.36k stars 6.46k forks source link

Fixup macOS libraries dependent path for dynamic libs #39890

Open aabellagm opened 4 months ago

aabellagm commented 4 months ago

Describe the bug From here: https://github.com/microsoft/vcpkg/pull/39313#discussion_r1665667124

It seems that the LC_LOAD_DYLIB paths should also be updated for dynamic libraries with dependencies. As an example, here the output after building FFmpeg:

% 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 there are references to libraries in the packages directory.

Environment

To Reproduce Steps to reproduce the behavior:

  1. /vcpkg install --triplet=arm64-osx-dynamic ffmpeg
  2. otool -L installed/arm64-osx-dynamic/lib/libavcodec.60.31.102.dylib

Expected behavior All paths pointing to other dynamic libraries showld also use @rpath.

Failure logs N/A

Additional context First changes to fix the rpath done here: https://github.com/microsoft/vcpkg/pull/39313

aabellagm commented 4 months ago

cc: @m-kuhn

m-kuhn commented 4 months ago

looks like https://github.com/microsoft/vcpkg/pull/39889 is tackling this. I also have some half baked work here.