Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use of alex-3.5.2.0 on GHC/compiler/Lexer.x leads to errors #266

Open
shayne-fletcher opened this issue Dec 31, 2024 · 3 comments
Open

use of alex-3.5.2.0 on GHC/compiler/Lexer.x leads to errors #266

shayne-fletcher opened this issue Dec 31, 2024 · 3 comments

Comments

@shayne-fletcher
Copy link

shayne-fletcher commented Dec 31, 2024

the generated Lexer.hs fails to compile with

compiler/GHC/Parser/Lexer.x:3471:12: error: [GHC-31744]
    Duplicate INLINE pragmas for ‘alexScanUser’
    at _build/stage0/compiler/build/GHC/Parser/Lexer.hs:1294:12-23
       compiler/GHC/Parser/Lexer.x:3471:12-23
     |
3471 | -- in this file, alexScanUser gets broken out into a separate function and
     |            ^^^^^^^^^^^^

to reproduce

git clone https://gitlab.haskell.org/ghc/ghc.git --recursive
cd ghc
./boot && ./configure
./hadrian/build --flavour=quickest -j
@shayne-fletcher shayne-fletcher changed the title use of alex-3.5.2.0 on GHC/compiler/Lexer.hs leads to errors use of alex-3.5.2.0 on GHC/compiler/Lexer.x leads to errors Dec 31, 2024
@andreasabel
Copy link
Member

Thanks for the report.

Duplicate INLINE pragmas for ‘alexScanUser’

GHC should not fail hard if someone passes the same information twice instead of just once.
(Haven't investigated if this has been reported as issue there already.)

I am open for discussion on whether the INLINE pragma now generated by Alex is a good or bad idea.
Apparently the GHC folks want it, and since Alex didn't do it by default they added it in.

CC: @brandonchinn178

@brandonchinn178
Copy link
Contributor

I figured it would be fairly uncontroversial; I can't imagine a situation where you wouldnt want to inline it. I didnt realize that GHC would fail if it's passed twice. I'm open to reverting it to avoid a breaking change, but IMO this is something that belongs in Alex, not user-code

@andreasabel
Copy link
Member

andreasabel commented Jan 4, 2025

@brandonchinn178 From looking at the GHC sources, it seems like you introduced the INLINE alexScanUser there.
(Their issue/PR 25158.)

-- 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 #-}

Would it be possible for you to place this pragma there under a suitable#if to reconcile it with alex-3.5.2.0?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants