diff --git a/Cabal/src/Distribution/Simple/GHC.hs b/Cabal/src/Distribution/Simple/GHC.hs index 1d4d5f8a2663b8e7d1c7a9ae54f9cdc3bf6783c6..9a74ed5b459376d9cc5a9249f5e49d79319b3370 100644 --- a/Cabal/src/Distribution/Simple/GHC.hs +++ b/Cabal/src/Distribution/Simple/GHC.hs @@ -1726,7 +1726,19 @@ getRPaths lbi clbi | supportRPaths hostOS = do -- 'False', while those operating systems themselves do support RPATH. supportRPaths Linux  = True supportRPaths Windows = False - supportRPaths OSX  = True + -- While macOS fundamentally supports RPaths, this flag will produce + -- linker -rpath flags for each dependency and pass them to GHC which will + -- in turn pass them verbatim to ld64. This is not desirable as we need to + -- use dead_strip_dylibs on macOS to prevent the Load Commands to exceed the + -- Load Command Size Limit (32K) on macOS. In GHC this was reworked in + -- ghc/ghc:4ff93292 (https://gitlab.haskell.org/ghc/ghc/-/commit/4ff93292243888545da452ea4d4c1987f2343591) + -- to patch the -rpath's into the library *after* linking them + -- with dead_strip_dylib. This will be backported to GHC 8.8, 8.10, and + -- 9.0, as well as being part of GHC 9.2 onwards. + -- + -- We know the GHC in question supports this if it knows about + -- `install_name_tool` or `otool`. + supportRPaths OSX  = False supportRPaths FreeBSD  = case compid of CompilerId GHC ver | ver >= mkVersion [7,10,2] -> True