[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 3 commits: Fix a bug in anyInRnEnvR

Marge Bot (@marge-bot) gitlab at gitlab.haskell.org
Mon Aug 29 19:24:44 UTC 2022



Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
cbe51ac5 by Simon Peyton Jones at 2022-08-29T04:18:57-04:00
Fix a bug in anyInRnEnvR

This bug was a subtle error in anyInRnEnvR, introduced by

    commit d4d3fe6e02c0eb2117dbbc9df72ae394edf50f06
    Author: Andreas Klebinger <klebinger.andreas at gmx.at>
    Date:   Sat Jul 9 01:19:52 2022 +0200

    Rule matching: Don't compute the FVs if we don't look at them.

The net result was #22028, where a rewrite rule would wrongly
match on a lambda.

The fix to that function is easy.

- - - - -
131fc39f by sheaf at 2022-08-29T15:24:29-04:00
Various Hadrian bootstrapping fixes

  - Don't always produce a distribution archive (#21629)
  - Use correct executable names for ghc-pkg and hsc2hs on windows
    (we were missing the .exe file extension)
  - Fix a bug where we weren't using the right archive format on Windows
    when unpacking the bootstrap sources.

Fixes #21629

- - - - -
0daf2e89 by Matthew Pickering at 2022-08-29T15:24:31-04:00
ci: Attempt using normal submodule cloning strategy

We do not use any recursively cloned submodules, and this protects us
from flaky upstream remotes.

Fixes #22121

- - - - -


7 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- compiler/GHC/Types/Var/Env.hs
- hadrian/bootstrap/bootstrap.py
- + testsuite/tests/simplCore/should_compile/T22028.hs
- + testsuite/tests/simplCore/should_compile/T22028.stderr
- testsuite/tests/simplCore/should_compile/all.T


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -17,7 +17,7 @@ variables:
   # Overridden by individual jobs
   CONFIGURE_ARGS: ""
 
-  GIT_SUBMODULE_STRATEGY: "recursive"
+  GIT_SUBMODULE_STRATEGY: "normal"
 
   # Makes ci.sh isolate CABAL_DIR
   HERMETIC: "YES"


=====================================
.gitlab/ci.sh
=====================================
@@ -377,8 +377,8 @@ function cleanup_submodules() {
     # On Windows submodules can inexplicably get into funky states where git
     # believes that the submodule is initialized yet its associated repository
     # is not valid. Avoid failing in this case with the following insanity.
-    git submodule sync --recursive || git submodule deinit --force --all
-    git submodule update --init --recursive
+    git submodule sync || git submodule deinit --force --all
+    git submodule update --init
     git submodule foreach git clean -xdf
   else
     info "Not cleaning submodules, not in a git repo"


=====================================
compiler/GHC/Types/Var/Env.hs
=====================================
@@ -9,7 +9,7 @@ module GHC.Types.Var.Env (
 
         -- ** Manipulating these environments
         emptyVarEnv, unitVarEnv, mkVarEnv, mkVarEnv_Directly,
-        elemVarEnv, disjointVarEnv,
+        elemVarEnv, disjointVarEnv, anyVarEnv,
         extendVarEnv, extendVarEnv_C, extendVarEnv_Acc,
         extendVarEnvList,
         plusVarEnv, plusVarEnv_C, plusVarEnv_CD, plusMaybeVarEnv_C,
@@ -62,7 +62,8 @@ module GHC.Types.Var.Env (
 
         -- ** Operations on RnEnv2s
         mkRnEnv2, rnBndr2, rnBndrs2, rnBndr2_var,
-        rnOccL, rnOccR, inRnEnvL, inRnEnvR, rnOccL_maybe, rnOccR_maybe,
+        rnOccL, rnOccR, inRnEnvL, inRnEnvR,  anyInRnEnvR,
+        rnOccL_maybe, rnOccR_maybe,
         rnBndrL, rnBndrR, nukeRnEnvL, nukeRnEnvR, rnSwap,
         delBndrL, delBndrR, delBndrsL, delBndrsR,
         extendRnInScopeSetList,
@@ -72,7 +73,7 @@ module GHC.Types.Var.Env (
 
         -- * TidyEnv and its operation
         TidyEnv,
-        emptyTidyEnv, mkEmptyTidyEnv, delTidyEnvList, anyInRnEnvR
+        emptyTidyEnv, mkEmptyTidyEnv, delTidyEnvList
     ) where
 
 import GHC.Prelude
@@ -409,7 +410,7 @@ anyInRnEnvR :: RnEnv2 -> VarSet -> Bool
 anyInRnEnvR (RV2 { envR = env }) vs
   -- Avoid allocating the predicate if we deal with an empty env.
   | isEmptyVarEnv env = False
-  | otherwise = anyVarEnv (`elemVarSet` vs) env
+  | otherwise         = anyVarSet (`elemVarEnv` env) vs
 
 lookupRnInScope :: RnEnv2 -> Var -> Var
 lookupRnInScope env v = lookupInScope (in_scope env) v `orElse` v


=====================================
hadrian/bootstrap/bootstrap.py
=====================================
@@ -86,14 +86,17 @@ class Compiler:
 
         self.ghc_path = ghc_path.resolve()
 
+        exe = ''
+        if platform.system() == 'Windows': exe = '.exe'
+
         info = self._get_ghc_info()
         self.version = info['Project version']
         #self.lib_dir = Path(info['LibDir'])
         #self.ghc_pkg_path = (self.lib_dir / 'bin' / 'ghc-pkg').resolve()
-        self.ghc_pkg_path = (self.ghc_path.parent / 'ghc-pkg').resolve()
+        self.ghc_pkg_path = (self.ghc_path.parent / ('ghc-pkg' + exe)).resolve()
         if not self.ghc_pkg_path.is_file():
             raise TypeError(f'ghc-pkg {self.ghc_pkg_path} is not a file')
-        self.hsc2hs_path = (self.ghc_path.parent / 'hsc2hs').resolve()
+        self.hsc2hs_path = (self.ghc_path.parent / ('hsc2hs' + exe)).resolve()
         if not self.hsc2hs_path.is_file():
             raise TypeError(f'hsc2hs {self.hsc2hs_path} is not a file')
 
@@ -367,6 +370,11 @@ def main() -> None:
                         help='path to GHC')
     parser.add_argument('-s', '--bootstrap-sources', type=Path,
                         help='Path to prefetched bootstrap sources tarball')
+    parser.add_argument('--archive', dest='want_archive', action='store_true',
+                       help='produce a Hadrian distribution archive (default)')
+    parser.add_argument('--no-archive', dest='want_archive', action='store_false',
+                       help='do not produce a Hadrian distribution archive')
+    parser.set_defaults(want_archive=True)
 
     subparsers = parser.add_subparsers(dest="command")
 
@@ -381,6 +389,9 @@ def main() -> None:
 
     ghc = None
 
+    sources_fmt = 'gztar' # The archive format for the bootstrap sources archive.
+    if platform.system() == 'Windows': sources_fmt = 'zip'
+
     if args.deps is None:
       if args.bootstrap_sources is None:
         # find appropriate plan in the same directory as the script
@@ -390,7 +401,7 @@ def main() -> None:
       # We have a tarball with all the required information, unpack it and use for further
       elif args.bootstrap_sources is not None and args.command != 'list-sources':
         print(f'Unpacking {args.bootstrap_sources} to {TARBALLS}')
-        shutil.unpack_archive(args.bootstrap_sources.resolve(), TARBALLS, 'gztar')
+        shutil.unpack_archive(args.bootstrap_sources.resolve(), TARBALLS, sources_fmt)
         args.deps = TARBALLS / 'plan-bootstrap.json'
         print(f"using plan-bootstrap.json ({args.deps}) from {args.bootstrap_sources}")
       else:
@@ -428,10 +439,7 @@ def main() -> None:
 
         shutil.copyfile(args.deps, rootdir / 'plan-bootstrap.json')
 
-        fmt = 'gztar'
-        if platform.system() == 'Windows': fmt = 'zip'
-
-        archivename = shutil.make_archive(args.output, fmt, root_dir=rootdir)
+        archivename = shutil.make_archive(args.output, sources_fmt, root_dir=rootdir)
 
         print(f"""
 Bootstrap sources saved to {archivename}
@@ -475,21 +483,21 @@ Alternatively, you could use `bootstrap.py -w {ghc.ghc_path} -d {args.deps} fetc
         bootstrap(info, ghc)
         hadrian_path = (BINDIR / 'hadrian').resolve()
 
-        archive = make_archive(hadrian_path)
-
         print(dedent(f'''
             Bootstrapping finished!
 
             The resulting hadrian executable can be found at
 
                 {hadrian_path}
+        '''))
 
-            It has been archived for distribution in
-
-                {archive}
+        if args.want_archive:
+            dist_archive = make_archive(hadrian_path)
+            print(dedent(f'''
+                The Hadrian executable has been archived for distribution in
 
-            You can use this executable to build GHC.
-        '''))
+                    {dist_archive}
+            '''))
     else:
       print(f"No such command: {args.command}")
 


=====================================
testsuite/tests/simplCore/should_compile/T22028.hs
=====================================
@@ -0,0 +1,19 @@
+
+-- This one triggers the bug reported in #22028, which
+-- was in a test for #1092
+-- The problem is that the rule
+--      forall w. f (\v->w) = w
+-- erroneously matches the call
+--      f id
+-- And that caused an assertion error.
+
+module Foo where
+
+f :: (Int -> Int) -> Int
+{-# NOINLINE f #-}
+f g = g 4
+{-# RULES "f" forall w. f (\v->w) = w  #-}
+
+h1 = f (\v -> v)   -- Rule should not fire
+h2 = f id          -- Rule should not fire
+h3 = f (\v -> 3)   -- Rule should fire


=====================================
testsuite/tests/simplCore/should_compile/T22028.stderr
=====================================
@@ -0,0 +1 @@
+Rule fired: f (Foo)


=====================================
testsuite/tests/simplCore/should_compile/all.T
=====================================
@@ -427,3 +427,4 @@ test('T21960', [grep_errmsg(r'^ Arity=5') ], compile, ['-O2 -ddump-simpl'])
 test('T21948', [grep_errmsg(r'^ Arity=5') ], compile, ['-O -ddump-simpl'])
 test('T21763', only_ways(['optasm']), compile, ['-O2 -ddump-rules'])
 test('T21763a', only_ways(['optasm']), compile, ['-O2 -ddump-rules'])
+test('T22028', normal, compile, ['-O -ddump-rule-firings'])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23c0677d55d4c095c3ad6cf6b2aae5125a53d4f2...0daf2e89354fb98f2d405b82250dc58efa17e186

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/23c0677d55d4c095c3ad6cf6b2aae5125a53d4f2...0daf2e89354fb98f2d405b82250dc58efa17e186
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/20220829/a47f76e8/attachment-0001.html>


More information about the ghc-commits mailing list