Bug 240289

Summary: Need to add DYLD_LIBRARY_PATH for XPC services
Product: WebKit Reporter: Michael Saboff <msaboff>
Component: PlatformAssignee: Michael Saboff <msaboff>
Status: RESOLVED FIXED    
Severity: Normal CC: david_quesada, saam, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Speculative Fix
none
Updated patch after discussing with David Quesada offline
none
Updated Patch none

Description Michael Saboff 2022-05-10 13:57:11 PDT
In addition to frameworks, there can be dylibs in the secondary path.  Therefore in addition to updating DYLD_VERSIONED_FRAMEWORK_PATH, we need to update DYLD_VERSIONED_LIBRARY_PATH.
Comment 1 Michael Saboff 2022-05-10 13:57:32 PDT
<rdar://90858923>
Comment 2 Michael Saboff 2022-05-10 14:09:43 PDT
Created attachment 459133 [details]
Speculative Fix
Comment 3 Michael Saboff 2022-05-10 15:36:56 PDT
Created attachment 459137 [details]
Updated patch after discussing with David Quesada offline
Comment 4 David Quesada 2022-05-10 17:03:43 PDT
Comment on attachment 459137 [details]
Updated patch after discussing with David Quesada offline

View in context: https://bugs.webkit.org/attachment.cgi?id=459137&action=review

It's not 100% related (since it's not specific to the staging install path configuration), but along then theme of loading *libraries* in addition to frameworks, could you also update registerDaemonWithLaunchD() in WebPushToolMain.mm? That builds a dictionary of environment variables that currently includes DYLD_FRAMEWORK_PATH, but also needs to include DYLD_LIBRARY_PATH to make sure the whole stack loads all the right code.

> Source/WebKit/Configurations/BaseTarget.xcconfig:129
>  OTHER_LDFLAGS_VERSIONED_FRAMEWORK_PATH_YES[arch=arm64*][sdk=macosx11*] = -Wl,-dyld_env,DYLD_FRAMEWORK_PATH=$(WK_INSTALL_PATH_PREFIX)/System/Library/StagedFrameworks/Safari;

This should set DYLD_LIBRARY_PATH.
Comment 5 Michael Saboff 2022-05-11 09:37:42 PDT
Updated the bug for the setting of DYLD_LIBRARY_PATH and DLYD_VERSIONED_LIBRARY_PATH environment variables for XPC services.
Comment 6 Michael Saboff 2022-05-11 10:11:05 PDT
Created attachment 459171 [details]
Updated Patch
Comment 7 David Quesada 2022-05-11 11:56:40 PDT
Looks good to me.
Comment 8 Alexey Proskuryakov 2022-05-11 12:01:35 PDT
Comment on attachment 459171 [details]
Updated Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=459171&action=review

> Source/WebKit/Configurations/BaseTarget.xcconfig:129
> +OTHER_LDFLAGS_VERSIONED_FRAMEWORK_PATH_YES[arch=arm64*][sdk=macosx11*] = -Wl,-dyld_env,DYLD_FRAMEWORK_PATH=$(WK_INSTALL_PATH_PREFIX)/System/Library/StagedFrameworks/Safari,-dyld_env,DYLD_LIBRARY_PATH=$(WK_INSTALL_PATH_PREFIX)/System/Library/StagedFrameworks/Safari;

I don't know why there is a special case for macosx11 on Apple Silicon only, but that's preexisting code, no change.
Comment 9 EWS 2022-05-11 14:42:52 PDT
Committed r294072 (250470@main): <https://commits.webkit.org/250470@main>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 459171 [details].