summaryrefslogtreecommitdiff
path: root/utils/ghc-pkg
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2017-11-17 15:04:50 +0800
committerMoritz Angermann <moritz.angermann@gmail.com>2017-11-18 11:12:24 +0800
commitbb11a2d976b933ad870a2888d665d98385dc55fd (patch)
tree6a6345e2133cf14e51e68529407ca61e63ff38e1 /utils/ghc-pkg
parent835d8ddbbfb11796ea8a03d1806b7cee38ba17a6 (diff)
downloadhaskell-bb11a2d976b933ad870a2888d665d98385dc55fd.tar.gz
Relocatable GHC
GHC and the binary distribution that's produced is not relocatable outside of Windows. This diff tries to address this for at least Linux and macOS. Reviewers: austin, hvr, bgamari, erikd, goldfire, Phyx Reviewed By: bgamari Subscribers: duog, rwbarton, thomie, erikd Differential Revision: https://phabricator.haskell.org/D4121
Diffstat (limited to 'utils/ghc-pkg')
-rw-r--r--utils/ghc-pkg/Main.hs11
1 files changed, 11 insertions, 0 deletions
diff --git a/utils/ghc-pkg/Main.hs b/utils/ghc-pkg/Main.hs
index 6420dd4f16..3dafffda96 100644
--- a/utils/ghc-pkg/Main.hs
+++ b/utils/ghc-pkg/Main.hs
@@ -2116,6 +2116,17 @@ getExecPath = try_size 2048 -- plenty, PATH_MAX is 512 under Win32.
foreign import WINDOWS_CCONV unsafe "windows.h GetModuleFileNameW"
c_GetModuleFileName :: Ptr () -> CWString -> Word32 -> IO Word32
+#elfi defined(darwin_HOST_OS) || defined(linux_HOST_OS)
+-- TODO: a) this is copy-pasta from SysTools.hs / getBaseDir. Why can't we reuse
+-- this here? and parameterise getBaseDir over the executable (for
+-- windows)?
+-- Answer: we can not, because if we share `getBaseDir` via `ghc-boot`,
+-- that would add `base` as a dependency for windows.
+-- b) why is the windows getBaseDir logic, not part of getExecutablePath?
+-- it would be much wider available then and we could drop all the
+-- custom logic?
+-- Answer: yes this should happen. No one has found the time just yet.
+getLibDir = Just . (\p -> p </> "lib") . takeDirectory . takeDirectory <$> getExecutablePath
#else
getLibDir :: IO (Maybe String)
getLibDir = return Nothing