[Git][ghc/ghc][wip/torsten.schmits/oneshot-bytecode-pkgdeps] add direct package deps when not using bytecode

Torsten Schmits (@torsten.schmits) gitlab at gitlab.haskell.org
Mon Jul 8 21:51:59 UTC 2024



Torsten Schmits pushed to branch wip/torsten.schmits/oneshot-bytecode-pkgdeps at Glasgow Haskell Compiler / GHC


Commits:
e0f55a78 by Torsten Schmits at 2024-07-08T23:51:43+02:00
add direct package deps when not using bytecode

- - - - -


2 changed files:

- compiler/GHC/Linker/Deps.hs
- testsuite/tests/th/cross-package/Makefile


Changes:

=====================================
compiler/GHC/Linker/Deps.hs
=====================================
@@ -48,6 +48,9 @@ import GHC.Unit.Home
 import GHC.Data.Maybe
 
 import Control.Applicative
+import Control.Monad
+import Control.Monad.IO.Class (MonadIO (liftIO))
+import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE)
 
 import qualified Data.Set as Set
 import qualified Data.Map as M
@@ -57,8 +60,6 @@ import System.Directory
 import GHC.Driver.Env
 import {-# SOURCE #-} GHC.Driver.Main
 import Data.Time.Clock
-import Control.Monad.IO.Class (MonadIO (liftIO))
-import Control.Monad.Trans.Except (ExceptT, runExceptT, throwE)
 
 
 data LinkDepsOpts = LinkDepsOpts
@@ -372,13 +373,21 @@ oneshot_deps_loop opts (mod : mods) acc = do
     add_library = pure (addToUDFM acc mod_unit_id (LinkLibrary mod_unit_id), [])
 
     add_module iface lmod =
-      (alterUDFM (add_package_module lmod) acc mod_unit_id, new_deps iface)
+      (addListToUDFM with_mod (direct_pkgs iface), new_deps iface)
+      where
+        with_mod = alterUDFM (add_package_module lmod) acc mod_unit_id
 
     add_package_module lmod = \case
       Just (LinkLibrary u) -> Just (LinkLibrary u)
       Just (LinkModules old) -> Just (LinkModules (addToUDFM old mod_name lmod))
       Nothing -> Just (LinkModules (unitUDFM mod_name lmod))
 
+    direct_pkgs iface
+      | bytecode
+      = []
+      | otherwise
+      = [(u, LinkLibrary u) | u <- Set.toList (dep_direct_pkgs (mi_deps iface))]
+
     new_deps iface
       | bytecode
       -- TODO How can we better determine the external deps?


=====================================
testsuite/tests/th/cross-package/Makefile
=====================================
@@ -2,8 +2,8 @@ TOP=../../../..
 include $(TOP)/mk/boilerplate.mk
 include $(TOP)/mk/test.mk
 
-# TODO check error without -package obj (especially for ObjCode, it appears to fail at link time)
-BASIC := $(TEST_HC_OPTS) -this-unit-id=cross -package-db db -package dep -package obj -v0
+# TODO it works even without -package obj, but it should complain about the package not being exposed
+BASIC := $(TEST_HC_OPTS) -this-unit-id=cross -package-db db -package dep -v0
 ARGS := $(BASIC) -fprefer-byte-code -fbyte-code-and-object-code
 
 .PHONY: CrossPackageArchive



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0f55a7830f35d6fcd32c1612c28241bb231c4f0

-- 
This project does not include diff previews in email notifications.
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/e0f55a7830f35d6fcd32c1612c28241bb231c4f0
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20240708/8d745514/attachment-0001.html>


More information about the ghc-commits mailing list