macOS: Ensure GL symbols are resolved from the OpenGL framework

The app or its dependencies may link against X11's libGL.1.dylib from
XQuarz, to support GLX on macOS. Doing so may place libGL earlier in
the load order than Apple's OpenGL framework, which results in dlsym
picking symbols from libGL when using the RTLD_DEFAULT lookup strategy,
breaking Qt's OpenGL support in various ways:

  QOpenGLShaderProgram: could not create shader program
  Warning: "" failed to compile!

To fix this we use RTLD_NEXT, which looks up the symbol in
dependency order of the image that called dlsym, rather than
the global load order.

Change-Id: I1ec3055a4ab0bb96566c7e196d301b30785f2dc0
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
This commit is contained in:
Lucas Wang 2020-03-01 10:55:32 +08:00 committed by Tor Arne Vestbø
parent 91436e2409
commit 9287447a67

View File

@ -554,7 +554,7 @@ NSOpenGLContext *QCocoaGLContext::nativeContext() const
QFunctionPointer QCocoaGLContext::getProcAddress(const char *procName)
{
return (QFunctionPointer)dlsym(RTLD_DEFAULT, procName);
return (QFunctionPointer)dlsym(RTLD_NEXT, procName);
}
#ifndef QT_NO_DEBUG_STREAM