GHC.Linker.MacOS

ghc-9.14.0.20251028: The GHC API

Safe Haskell | None
Language | GHC2021

GHC.Linker.MacOS

Synopsis

- runInjectRPaths :: Logger -> ToolSettings -> [FilePath] -> FilePath -> IO ()
- getUnitFrameworkOpts :: UnitEnv -> [UnitId] -> IO [String]
- getFrameworkOpts :: FrameworkOpts -> Platform -> [String]
- loadFramework :: Interp -> [FilePath] -> FilePath -> IO (Maybe String)

# Documentation

runInjectRPaths :: Logger -> ToolSettings -> [FilePath] -> FilePath -> IO () Source #

On macOS we rely on the linkers `-dead_strip_dylibs` flag to remove unused libraries from the dynamic library. We do this to reduce the number of load commands that end up in the dylib, and has been limited to 32K (32768) since macOS Sierra (10.14).

`-dead_strip_dylibs` does not dead strip `-rpath` entries, as such passing `-l` and `-rpath` to the linker will result in the unnecessary libraries not being included in the load commands, however the `-rpath` entries are all forced to be included. This can lead to 100s of `-rpath` entries being included when only a handful of libraries end up being truly linked.

Thus after building the library, we run a fixup phase where we inject the `-rpath` for each found library (in the given library search paths) into the dynamic library through `-add_rpath`.

See Note [Dynamic linking on macOS]

getUnitFrameworkOpts :: UnitEnv -> [UnitId] -> IO [String] Source #

getFrameworkOpts :: FrameworkOpts -> Platform -> [String] Source #

loadFramework :: Interp -> [FilePath] -> FilePath -> IO (Maybe String) Source #