Bug 224602

Summary: MacCatalyst ANGLE is linked with @loader_path/../../../libANGLE-shared.dylib
Product: WebKit Reporter: Kimmo Kinnunen <kkinnunen>
Component: ANGLEAssignee: Alex Christensen <achristensen>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, ap, dino, ews-watchlist, graouts, kkinnunen, kondapallykalyan, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Local Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=224785
Bug Depends on: 224603, 224605    
Bug Blocks:    
Attachments:
Description Flags
Patch
none
Patch none

Description Kimmo Kinnunen 2021-04-15 05:29:19 PDT
MacCatalyst ANGLE is linked with @loader_path/../../../libANGLE-shared.dylib 

The path may be wrong.
The use of @loader_path is probably wrong.
ld: warning: invalid -install_name (@loader_path/../../../libANGLE-shared.dylib) in dependent dylib (/Users/kkinnunen/Build/Debug-maccatalyst/libANGLE-shared.dylib). Dylibs/frameworks which might go in dyld shared cache cannot link with dylib that uses @rpath, @loader_path,
Comment 1 Kimmo Kinnunen 2021-04-15 05:30:07 PDT
<rdar://76602857>
Comment 2 Alex Christensen 2021-04-20 09:56:56 PDT
DYLIB_INSTALL_NAME_BASE is probably wrong when WK_ALTERNATE_FRAMEWORKS_DIR is used.
Comment 3 Alex Christensen 2021-04-20 09:59:44 PDT
I'm planning to fix this this afternoon.
Comment 4 Alex Christensen 2021-04-20 10:01:40 PDT
Created attachment 426562 [details]
Patch
Comment 5 EWS Watchlist 2021-04-20 10:02:32 PDT
Note that there are important steps to take when updating ANGLE. See https://trac.webkit.org/wiki/UpdatingANGLE
Comment 6 Kimmo Kinnunen 2021-04-20 11:05:38 PDT
Comment on attachment 426562 [details]
Patch

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

> Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig:28
>  DYLIB_INSTALL_NAME_BASE_WK_RELOCATABLE_FRAMEWORKS_YES = @loader_path/../../../;

Out of curiosity, in which this loader_path is correct?
Comment 7 Alex Christensen 2021-04-20 12:14:45 PDT
The use of @loader_path is necessary when we use WK_RELOCATABLE_FRAMEWORKS because we need to be able to relocate them and have dyld still find the dylib relative to the framework.
Comment 8 Alex Christensen 2021-04-20 13:32:21 PDT
Comment on attachment 426562 [details]
Patch

When building project ANGLE:
INSTALL_PATH\=/System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks
DYLIB_INSTALL_NAME_BASE\=/System/Library/Frameworks/WebKit.framework/Versions/A/Frameworks/WebCore.framework/Versions/A/Frameworks

When building project ANGLE_iosmac before this change:
INSTALL_PATH\=/System/iOSSupport//System/Library/PrivateFrameworks/WebCore.framework/Versions/A/Frameworks
DYLIB_INSTALL_NAME_BASE\=@loader_path/../../../

When building project ANGLE_iosmac after this change:
INSTALL_PATH\=/System/iOSSupport//System/Library/PrivateFrameworks/WebCore.framework/Versions/A/Frameworks
DYLIB_INSTALL_NAME_BASE\=/System/iOSSupport//System/Library/PrivateFrameworks/WebCore.framework/Versions/A/Frameworks

This leads me to believe this will fix the problem.
Comment 9 Alexey Proskuryakov 2021-04-20 14:09:30 PDT
Comment on attachment 426562 [details]
Patch

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

> Source/ThirdParty/ANGLE/Configurations/ANGLE-dynamic.xcconfig:26
> +DYLIB_INSTALL_NAME_BASE_USE_ALTERNATE_FRAMEWORKS_DIR_YES = @(INSTALL_PATH);

Looking at other projects, and even at the below line, we are using DYLIB_INSTALL_NAME_BASE for this case, not INSTALL_PATH.

There is probably no difference in practice, but let's use the same solution as elsewhere.
Comment 10 Alex Christensen 2021-04-20 14:15:58 PDT
I verified that does the same thing so I'll do it.

I also verified that when using relocatable frameworks, DYLIB_INSTALL_NAME_BASE is @loader_path/../../../ so there *should* be no problem there.
Comment 11 Alex Christensen 2021-04-20 14:18:40 PDT
Created attachment 426589 [details]
Patch
Comment 12 EWS 2021-04-20 14:45:29 PDT
Committed r276318 (236799@main): <https://commits.webkit.org/236799@main>

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