[Git][ghc/ghc][wip/ghc-fat-interface] 2 commits: fix test

Matthew Pickering (@mpickering) gitlab at gitlab.haskell.org
Fri Aug 12 12:20:23 UTC 2022



Matthew Pickering pushed to branch wip/ghc-fat-interface at Glasgow Haskell Compiler / GHC


Commits:
348e764f by Matthew Pickering at 2022-08-12T12:54:30+01:00
fix test

- - - - -
c1911369 by Matthew Pickering at 2022-08-12T13:20:12+01:00
fixes

- - - - -


9 changed files:

- compiler/GHC/Driver/Main.hs
- compiler/GHC/Driver/Make.hs
- compiler/GHC/Driver/Pipeline/Execute.hs
- compiler/GHC/Iface/Syntax.hs
- compiler/GHC/Linker/Types.hs
- compiler/GHC/Unit/Home/ModInfo.hs
- testsuite/tests/driver/fat-iface/Makefile
- testsuite/tests/driver/fat-iface/fat001.stdout
- testsuite/tests/driver/fat-iface/fat006.stdout


Changes:

=====================================
compiler/GHC/Driver/Main.hs
=====================================
@@ -1105,10 +1105,10 @@ hscDesugarAndSimplify summary (FrontendTypecheck tc_result) tc_warnings mb_old_h
                            }
 
       Just desugared_guts | gopt Opt_WriteFatInterface dflags -> do
-          -- If -fno-code is enabled (hence we fall through to this case) then
-          -- -O0 is implied, so this simplifier pass will be quite gentle. Running
-          -- the simplifier once is necessary before doing byte code generation
-          -- in order to inline data con wrappers.
+          -- If -fno-code is enabled (hence we fall through to this case)
+          -- Running the simplifier once is necessary before doing byte code generation
+          -- in order to inline data con wrappers but we honour whatever level of simplificication the
+          -- user requested. See #22008 for some discussion.
           plugins <- liftIO $ readIORef (tcg_th_coreplugins tc_result)
           simplified_guts <- hscSimplify' plugins desugared_guts
           (cg_guts, _) <-


=====================================
compiler/GHC/Driver/Make.hs
=====================================
@@ -1799,14 +1799,19 @@ enableCodeGenWhen logger tmpfs staticLife dynLife unit_env mod_graph =
 
     bytecode_and_enable enable_spec ms =
       -- In the situation where we **would** need to enable dynamic-too
-      dynamic_too_enable enable_spec ms
+      -- IF we had decided we needed objects
+      dynamic_too_enable EnableObject ms
         -- but we prefer to use bytecode rather than objects
         && prefer_bytecode
         -- and we haven't already turned it on
         && not generate_both
       where
         lcl_dflags   = ms_hspp_opts ms
-        prefer_bytecode = EnableByteCodeAndObject == enable_spec
+        prefer_bytecode = case enable_spec of
+                            EnableByteCodeAndObject -> True
+                            EnableByteCode -> True
+                            EnableObject -> False
+
         generate_both   = gopt Opt_ByteCodeAndObjectCode lcl_dflags
 
     -- #8180 - when using TemplateHaskell, switch on -dynamic-too so


=====================================
compiler/GHC/Driver/Pipeline/Execute.hs
=====================================
@@ -572,22 +572,6 @@ runHscBackendPhase pipe_env hsc_env mod_name src_flavour location result = do
               bc <- generateFreshByteCode hsc_env mod_name (mkCgInteractiveGuts cgguts) mod_location
               return ([], final_iface, emptyHomeModInfoLinkable { homeMod_bytecode = Just bc } , panic "interpreter")
 
-{-
-              (hasStub, comp_bc, spt_entries) <- hscInteractive hsc_env cgguts mod_location
-
-              stub_o <- case hasStub of
-                        Nothing -> return []
-                        Just stub_c -> do
-                            stub_o <- compileStub hsc_env stub_c
-                            return [DotO stub_o]
-
-              let hs_unlinked = [BCOs comp_bc spt_entries]
-              unlinked_time <- getCurrentTime
-              let !linkable = LM unlinked_time (mkHomeModule (hsc_home_unit hsc_env) mod_name)
-                             (hs_unlinked ++ stub_o)
-              return ([], final_iface, Just linkable, panic "interpreter")
-              -}
-
 
 runUnlitPhase :: HscEnv -> FilePath -> FilePath -> IO FilePath
 runUnlitPhase hsc_env input_fn output_fn = do


=====================================
compiler/GHC/Iface/Syntax.hs
=====================================
@@ -596,6 +596,7 @@ data IfaceLetBndr = IfLetBndr IfLclName IfaceType IfaceIdInfo IfaceJoinInfo
 data IfaceTopBndrInfo = IfLclTopBndr IfLclName IfaceType IfaceIdInfo IfaceIdDetails
                       | IfGblTopBndr IfaceTopBndr
 
+-- See Note [Fat Interface: Sharing RHSs]
 data IfaceMaybeRhs = IfUseUnfoldingRhs | IfRhs IfaceExpr
 
 data IfaceJoinInfo = IfaceNotJoinPoint


=====================================
compiler/GHC/Linker/Types.hs
=====================================
@@ -158,6 +158,7 @@ data Unlinked
   | DotA FilePath      -- ^ Static archive file (.a)
   | DotDLL FilePath    -- ^ Dynamically linked library file (.so, .dll, .dylib)
   | FI FatIface        -- ^ Serialised core which we can turn into BCOs (or object files), or used by some other backend
+                       -- See Note [Fat Interface Files]
   | LoadedBCOs [Unlinked] -- ^ A list of BCOs, but hidden behind extra indirection to avoid
                           -- being too strict.
   | BCOs CompiledByteCode


=====================================
compiler/GHC/Unit/Home/ModInfo.hs
=====================================
@@ -104,7 +104,9 @@ bytecodeAndObjects bc o =
     (HomeModLinkable (Just bc) (Just o))
 
 
-{- Note [Home module build products]
+{-
+Note [Home module build products]
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
 When compiling a home module we can produce some combination of the following
 build products.


=====================================
testsuite/tests/driver/fat-iface/Makefile
=====================================
@@ -10,7 +10,7 @@ clean:
 fat001: clean
 	"$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -fwrite-fat-interface -dno-typeable-binds
 	test -f Fat.hi
-	"$(TEST_HC)" $(TEST_HC_OPTS) --show-iface Fat.hi | grep -A3 extra-decls
+	"$(TEST_HC)" $(TEST_HC_OPTS) --show-iface Fat.hi | grep -A3 "extra decls"
 
 # If -fbyte-code-and-object-code is set then we should generate bytecode as the Linkable.
 fat005: clean
@@ -25,7 +25,7 @@ fat007: clean
 fat006: clean
 	"$(TEST_HC)" $(TEST_HC_OPTS) -c Fat.hs -dno-typeable-binds -fno-code -fwrite-fat-interface
 	test -f Fat.hi
-	"$(TEST_HC)" $(TEST_HC_OPTS) --show-iface Fat.hi | grep -A3 extra-decls
+	"$(TEST_HC)" $(TEST_HC_OPTS) --show-iface Fat.hi | grep -A3 "extra decls"
 	test ! -f Fat.o
 
 fat006a: clean


=====================================
testsuite/tests/driver/fat-iface/fat001.stdout
=====================================
@@ -1,4 +1,4 @@
-extra-decls
+extra decls:
   a = GHC.Types.C# 'a'#
   f = GHC.Types.C# 'f'#
   t = GHC.Types.C# 't'#


=====================================
testsuite/tests/driver/fat-iface/fat006.stdout
=====================================
@@ -1,4 +1,4 @@
-extra-decls
+extra decls:
   a = GHC.Types.C# 'a'#
   f = GHC.Types.C# 'f'#
   t = GHC.Types.C# 't'#



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dec02917c0a6c57e5164b0f0b5f6fb1d9e5128d9...c1911369f41815bb243b110865d17c34225e2d9a

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/dec02917c0a6c57e5164b0f0b5f6fb1d9e5128d9...c1911369f41815bb243b110865d17c34225e2d9a
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/20220812/27a9eb33/attachment-0001.html>


More information about the ghc-commits mailing list