System frameworks cannot be loaded on macOS Big Sur
When running on macOS Big Sur, attempting to load a system framework at runtime fails with a
not found error.
Steps to reproduce
Create a file called
Main.hs with the following content:
module Main where main = putStrLn "Hi."
Run it with
-framework OpenGL to GHC:
runghc --ghc-arg="-framework OpenGL" Main.hs
The program should run and say hi.
- GHC version used: 8.10.1
- Operating System: macOS 10.16 Big Sur (20A4300b)
- System Architecture: x86_64
Merge request !3689 (closed) is a proposed fix.
This is presumably due to the following change in macOS Big Sur:
New in macOS Big Sur 11 beta, the system ships with a built-in dynamic linker cache of all system-provided libraries. As part of this change, copies of dynamic libraries are no longer present on the filesystem. Code that attempts to check for dynamic library presence by looking for a file at a path or enumerating a directory will fail. Instead, check for library presence by attempting to dlopen() the path, which will correctly check for the library in the cache. (62986286)
The fix proposed above implements the behavior suggested there.