summaryrefslogtreecommitdiff
path: root/compiler/GHC/Runtime/Linker.hs
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2020-05-14 08:18:31 +0800
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-06-07 08:46:42 -0400
commit6dae65484f9552239652f743e2303fa17aae953b (patch)
tree63d59e6b673c6c2cb66c9d29cba0cc1ddf2b2b64 /compiler/GHC/Runtime/Linker.hs
parentb022051a50d30e39d86ee21e565e899e7e98255f (diff)
downloadhaskell-6dae65484f9552239652f743e2303fa17aae953b.tar.gz
Disable DLL loading if without system linker
Some platforms (musl, aarch64) do not have a working dynamic linker implemented in the libc, even though we might see dlopen. It will ultimately just return that this is not supported. Hence we'll add a flag to the compiler to flat our disable loading dlls. This is needed as we will otherwise try to load the shared library even if this will subsequently fail. At that point we have given up looking for static options though.
Diffstat (limited to 'compiler/GHC/Runtime/Linker.hs')
-rw-r--r--compiler/GHC/Runtime/Linker.hs18
1 files changed, 15 insertions, 3 deletions
diff --git a/compiler/GHC/Runtime/Linker.hs b/compiler/GHC/Runtime/Linker.hs
index d6b916ff39..740e3a7a43 100644
--- a/compiler/GHC/Runtime/Linker.hs
+++ b/compiler/GHC/Runtime/Linker.hs
@@ -1328,6 +1328,7 @@ linkPackage hsc_env pkg
("Loading package " ++ unitPackageIdString pkg ++ " ... ")
-- See comments with partOfGHCi
+#if defined(CAN_LOAD_DLL)
when (unitPackageName pkg `notElem` partOfGHCi) $ do
loadFrameworks hsc_env platform pkg
-- See Note [Crash early load_dyn and locateLib]
@@ -1336,7 +1337,7 @@ linkPackage hsc_env pkg
-- For remaining `dlls` crash early only when there is surely
-- no package's DLL around ... (not is_dyn)
mapM_ (load_dyn hsc_env (not is_dyn) . mkSOName platform) dlls
-
+#endif
-- After loading all the DLLs, we can load the static objects.
-- Ordering isn't important here, because we do one final link
-- step to resolve everything.
@@ -1471,10 +1472,15 @@ locateLib hsc_env is_hs lib_dirs gcc_dirs lib
-- O(n). Loading an import library is also O(n) so in general we prefer
-- shared libraries because they are simpler and faster.
--
- = findDll user `orElse`
+ =
+#if defined(CAN_LOAD_DLL)
+ findDll user `orElse`
+#endif
tryImpLib user `orElse`
+#if defined(CAN_LOAD_DLL)
findDll gcc `orElse`
findSysDll `orElse`
+#endif
tryImpLib gcc `orElse`
findArchive `orElse`
tryGcc `orElse`
@@ -1539,7 +1545,13 @@ locateLib hsc_env is_hs lib_dirs gcc_dirs lib
full = dllpath $ search lib_so_name lib_dirs
gcc name = liftM (fmap Archive) $ search name lib_dirs
files = import_libs ++ arch_files
- in apply $ short : full : map gcc files
+ dlls = [short, full]
+ archives = map gcc files
+ in apply $
+#if defined(CAN_LOAD_DLL)
+ dlls ++
+#endif
+ archives
tryImpLib re = case os of
OSMinGW32 ->
let dirs' = if re == user then lib_dirs else gcc_dirs