[Git][ghc/ghc][wip/T25623] Fix for alex-3.5.2.0 (#25623)

Brandon Chinn (@brandonchinn178) gitlab at gitlab.haskell.org
Fri Jan 24 16:49:12 UTC 2025



Brandon Chinn pushed to branch wip/T25623 at Glasgow Haskell Compiler / GHC


Commits:
02dc0751 by Brandon Chinn at 2025-01-24T08:49:01-08:00
Fix for alex-3.5.2.0 (#25623)

This INLINE pragma for alexScanUser was added in 9.12, but then I
ported the change to alex in 3.5.2.0
(https://github.com/haskell/alex/pull/262).

I didn't realize that GHC errors on duplicate INLINE pragmas, so
this ended up being a breaking change.

This change should be backported into 9.12

- - - - -


2 changed files:

- compiler/GHC/Parser/Lexer.x
- compiler/ghc.cabal.in


Changes:

=====================================
compiler/GHC/Parser/Lexer.x
=====================================
@@ -41,6 +41,7 @@
 -- Alex "Haskell code fragment top"
 
 {
+{-# LANGUAGE CPP #-}
 {-# LANGUAGE ViewPatterns #-}
 {-# LANGUAGE LambdaCase #-}
 {-# LANGUAGE MultiWayIf #-}
@@ -3467,10 +3468,12 @@ topNoLayoutContainsCommas [] = False
 topNoLayoutContainsCommas (ALRLayout _ _ : ls) = topNoLayoutContainsCommas ls
 topNoLayoutContainsCommas (ALRNoLayout b _ : _) = b
 
+#if !MIN_TOOL_VERSION_alex(3,5,2)
 -- If the generated alexScan/alexScanUser functions are called multiple times
 -- in this file, alexScanUser gets broken out into a separate function and
 -- increases memory usage. Make sure GHC inlines this function and optimizes it.
 {-# INLINE alexScanUser #-}
+#endif
 
 lexToken :: P (PsLocated Token)
 lexToken = do


=====================================
compiler/ghc.cabal.in
=====================================
@@ -101,8 +101,10 @@ Library
               ClosureTypes.h
               FunTypes.h
 
+    -- always include alex so we can use MIN_TOOL_VERSION_alex
+    build-tool-depends: alex:alex >= 3.2.6
     if flag(build-tool-depends)
-      build-tool-depends: alex:alex >= 3.2.6, happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants
+      build-tool-depends: happy:happy >= 1.20.0, genprimopcode:genprimopcode, deriveConstants:deriveConstants
 
     if flag(with-libzstd)
       if flag(static-libzstd)



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

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/02dc07516eefe29d5b9ac6fe39e310c05a6732fe
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/20250124/acd105f5/attachment-0001.html>


More information about the ghc-commits mailing list