Mesa with LLVM on MacOS

Hi,

I have a MacBook Pro with an Intel Iris Plus Graphics 640, which gives maximum 4.1 OpenGL context. Thus, I would like to use Mesa as an alternative for getting higher contexes e.g. 4.5 or 4.6. I don’t care about performance in this phase.

I have built Mesa with LLVM (llvm-config… etc…) but even by placing the built libGL.dylib in the same folder with executable or setting DYLD_LIBRARY_PATH or DYLD_INSERT_LIBRARIES, I am not able to get the Mesa renderer.

Does Apple support this overriding of libGL with a custom one?

Any help/guidance would be really appreciated.

Thanks

Read man dyld. On macOS you need to have a matching library install name and rpath in the executable. For finding a library in the same directory as the executable set the library’s install name to @rpath/<library file name> and set the executable’s rpath to @executable_path. You can add additional elements to the rpath if you’d like the executable to search additional places for the library, e.g. /usr/local/lib. Both the library name and rpath are set by options to the linker when building the library and executable respectively and can also be set via Xcode build settings.

This install name tells dyld the the library is happy to be found anywhere along the application’s rpath. The rpath setting tells the application where to search.

Whether the library will work once your application finds it, I don’t know.

I did the following:

1st trial:

  • install_name_tool -add_rpath ..path-to-custom-libGL.dylib-built-from-mesa.. myapp

2nd trial:

  • link directly the app with libGL.dylib

but none of those two worked. After googling a bit, it seems that Apple never lets you replace their OpenGL.framework. Is that true?