Bug 209946

Summary: Do not link with OpenGL on Apple platforms
Product: WebKit Reporter: Keith Rollin <krollin>
Component: ANGLEAssignee: Keith Rollin <krollin>
Status: RESOLVED FIXED    
Severity: Normal CC: dino, ews-watchlist, fred.wang, graouts, kbr, kondapallykalyan, sam, simon.fraser, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
Bug Depends on:    
Bug Blocks: 209890    
Attachments:
Description Flags
Patch none

Description Keith Rollin 2020-04-02 19:12:59 PDT
OpenGL is not used in our build of ANGLE. Attempting to link with it causes warnings, which can turn to errors in some cases (in particular with building with Xcode's "new" build system).
Comment 1 Radar WebKit Bug Importer 2020-04-02 19:13:11 PDT
<rdar://problem/61237956>
Comment 2 Keith Rollin 2020-04-02 19:15:51 PDT
Created attachment 395337 [details]
Patch
Comment 3 EWS Watchlist 2020-04-02 19:16:37 PDT
Note that there are important steps to take when updating ANGLE. See http://trac.webkit.org/wiki/UpdatingANGLE
Comment 4 EWS 2020-04-03 11:00:38 PDT
Committed r259475: <https://trac.webkit.org/changeset/259475>

All reviewed patches have been landed. Closing bug and clearing flags on attachment 395337 [details].
Comment 5 Kenneth Russell 2020-04-03 13:05:27 PDT
How are references to functions like CGLCreateContext resolved after this patch?
Comment 6 Dean Jackson 2020-04-03 17:12:41 PDT
(In reply to Kenneth Russell from comment #5)
> How are references to functions like CGLCreateContext resolved after this
> patch?

Yeah. ANGLE only dynamically loads /System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib

All the CGL stuff is in /System/Library/Frameworks/OpenGL.framework/Versions/A/OpenGL

So how did this pass tests?
Comment 7 Dean Jackson 2020-04-03 17:19:58 PDT
Oh. It's because it is linked into WebCore which links OpenGL.
Comment 8 Dean Jackson 2020-04-03 17:20:55 PDT
However, this change shouldn't have been necessary. If the new build system can't link against OpenGL, it can't build WebCore or WebKit.
Comment 9 Dean Jackson 2020-04-03 17:23:12 PDT
Did you find out what was actually causing the compiler warning?

Because if it was unused functions when linking, then we also have a bunch of those in other projects.

e.g. 
ld: warning: linking with (/System/Library/Frameworks/CoreAudio.framework/CoreAudio) but not using any symbols from it
ld: warning: linking with (/System/Library/Frameworks/VideoToolbox.framework/VideoToolbox) but not using any symbols from it
ld: warning: linking with (/System/Library/Frameworks/CoreMedia.framework/CoreMedia) but not using any symbols from it
ld: warning: linking with (/System/Library/PrivateFrameworks/URLFormatting.framework/URLFormatting) but not using any symbols from it
ld: warning: linking with (/usr/lib/libAccessibility.dylib) but not using any symbols from it
Comment 10 Keith Rollin 2020-04-03 17:39:09 PDT
(In reply to Dean Jackson from comment #8)
> However, this change shouldn't have been necessary. If the new build system
> can't link against OpenGL, it can't build WebCore or WebKit.

It's not that it can't link against OpenGL. I'm pretty sure that it's because it can't link against an OpenGL that doesn't exist. OpenGL.framework is not in the iphonesimulator SDK. That's where the error was occurring.

WebCore is able to link because it only links against OpenGL on the macOS:

WebCore.xcconfig
108:WK_OPENGL_LDFLAGS_iphoneos = -framework OpenGLES;
109:WK_OPENGL_LDFLAGS_iphonesimulator = -framework OpenGLES;
114:WK_OPENGL_LDFLAGS_maccatalyst = -framework OpenGL;
115:WK_OPENGL_LDFLAGS_macosx = -framework OpenGL;

Thanks for clarifying all of this. I was going crazy today trying to figure out how macOS was linking!