Skip to content

ghc-lib-parser 9.12.2 fails to build with ghc-9.8.4 and ghc-lib-parser-9.10.1 fails to build with ghc-9.6.7 #595

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

Closed
GuillaumedeVolpiano opened this issue Apr 7, 2025 · 37 comments · Fixed by #596

Comments

@GuillaumedeVolpiano
Copy link
Contributor

Probably related to this https://gitlab.haskell.org/ghc/ghc/-/merge_requests/10568
(patch here https://gitlab.haskell.org/ghc/ghc/-/commit/e421ec3c8fc9688b3f7ee08c0d1baaf1cb7aa750)
Linking /root/github/stylish-haskell/dist-newstyle/build/x86_64-linux/ghc-9.8.4/stylish-haskell-0.14.6.0/t/stylish-haskell-tests/build/stylish-haskell-tests/stylish-haskell-tests /usr/lib/gcc/x86_64-pc-linux-gnu/14/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/ghc-9.8.4/lib/../lib/x86_64-linux-ghc-9.8.4/rts-1.0.2/libHSrts-1.0.2.a(Globals.o):(.bss+0x0): multiple definition of ghc_unique_counter64'; /root/.local/state/cabal/store/ghc-9.8.4/ghc-lib-parser-9.12.2.20250320-48b5863d60855e9cdc5daef7f57fb49458d3bd0c527dd8950e22b0a76fe73a30/lib/libHSghc-lib-parser-9.12.2.20250320-48b5863d60855e9cdc5daef7f57fb49458d3bd0c527dd8950e22b0a76fe73a30.a(genSym.o):(.bss+0x0): first defined here`

@GuillaumedeVolpiano GuillaumedeVolpiano changed the title ghc-lib-parser 9.12.2 fails to build with ghc-9.8.4 ghc-lib-parser 9.12.2 fails to build with ghc-9.8.4 and ghc-lib-parser-9.10.1 fails to build with ghc-9.6.7 Apr 15, 2025
@GuillaumedeVolpiano
Copy link
Contributor Author

Actually the issue is here. It seems related to this #581

@GuillaumedeVolpiano
Copy link
Contributor Author

@shayne-fletcher
Copy link
Contributor

i'm not sure you want to close this? i can't reproduce a failure but i don't like the contents of genSym.c in that version of ghc-lib for 9.8.4 -- looks wrong. lmk!

@GuillaumedeVolpiano
Copy link
Contributor Author

Well, I didn't want to clutter. The issue is that I don't have ghc-9.6.7 on my local machine to test just yet. I assumed that your commit fixed it, but if your happy with it, I'll investigate!

@jhrcek
Copy link

jhrcek commented Apr 16, 2025

@GuillaumedeVolpiano can you try installing ghc 9.6.7 using ghcup (should support installation to gentoo afaik) and test it that way?

@jhrcek
Copy link

jhrcek commented Apr 16, 2025

Indeed, I was able to reproduce the issue locally (getting the same build error when building stylish-haskell with ghc 9.6.7).
Alas I'm not really sure how to test, whether this issue is fixed on ghc-lib's master. It will probably require following instructions in the readme to obtain local checkout of ghc-lib-parser library + using stylish-haskell's cabal.project pointing to that? @shayne-fletcher do you have some suggestions how this could be done? Or alternatively would you be willing to release a new version of ghc-lib-parser with the latest fixes?

@GuillaumedeVolpiano
Copy link
Contributor Author

GuillaumedeVolpiano commented Apr 16, 2025

OK, sorry for the noob question, but when running

cabal run exe:ghc-lib-build-tool -- --ghc-flavor=ghc-9.12.2

in my ghc-9.8.4 sandbox, I get the following error message…

config.status: creating ghcautoconf.h.autoconf
configure: WARNING: unrecognized options: --with-compiler, --with-cc
| Run DeriveConstants: none => ghc-lib/stage0/rts/build/include/DerivedConstants.h (and 1 more)
Build completed in 52.97s

ghc-lib-gen: Failed when running system command: cabal -v0 path --store-dir

Same thing in my ghc-9.6.6 sandbox.

ghc-9.6.7 sandbox in construction. I'm also creating an Ubuntu container to see what gives there.

@GuillaumedeVolpiano
Copy link
Contributor Author

GuillaumedeVolpiano commented Apr 16, 2025

Just confirming that I hit the same issue with ghc-9.6.7/ghc-lib-parser-9.10 and ghc-9.8.4/ghc-lib-parser-9.12.2 on clean ubuntu based sandboxes. No such issue with ghc-9.8.4/ghc-lib-parser-9.10.1

@shayne-fletcher
Copy link
Contributor

shayne-fletcher commented Apr 16, 2025

can you post me a full log please? what does running that command in the console say? also, i don't know what a "sandbox" is 😉

@shayne-fletcher
Copy link
Contributor

i think the easiest and fastest way forward here is if i repro this myself and work out the fix. would you be able to post me instructions for that?

@shayne-fletcher
Copy link
Contributor

Just confirming that I hit the same issue with ghc-9.6.7/ghc-lib-parser-9.10 and ghc-9.8.4/ghc-lib-parser-9.12.2 on clean ubuntu based sandboxes. No such issue with ghc-9.8.4/ghc-lib-parser-9.10.1

what issue? the link error?

@GuillaumedeVolpiano
Copy link
Contributor Author

GuillaumedeVolpiano commented Apr 16, 2025

Sorry, by sandbox I meant an incus container. Basically a virtual machine with less overhead as it shares the kernel with the host.

Full build logs here

Gentoo:

cabal run exe:ghc-lib-build-tool -- --ghc-flavor=9.10.1 with ghc-9.6.6 https://bpa.st/B3QA
cabal run exe:ghc-lib-build-tool -- --ghc-flavor=9.12.2 with ghc-9.8.4 https://bpa.st/7ESQ

Ubuntu

cabal run exe:ghc-lib-build-tool -- --ghc-flavor=9.10.1 with ghc-9.6.7 https://bpa.st/2QKQ
cabal run exe:ghc-lib-build-tool -- --ghc-flavor=9.12.2 with ghc-9.8.4 https://bpa.st/YHAA

(Interestingly enough, I can't build on either side, but I don't get the same error)

As for your other questions:

  • The issue I was mentionning was the link error

  • To reproduce :

with ghc-9.6.7, just try the head of the main repo of stylish-haskell

git clone https://github.com/haskell/stylish-haskell
cd stylish-haskell
cabal build

with ghc-9.8.4, you need my ghc9.12 branch

git clone https://github.com/GuillaumedeVolpiano/stylish-haskell.git
cd stylish-haskell
git checkout ghc9.12
cabal build

Do tell me how else I can help

@shayne-fletcher
Copy link
Contributor

awesome. i'll put this on my stack and get back to you.

out of interest, in one of your sandboxes that exhibits the ghc-lib build error, what does cabal path --store-dir print?

@GuillaumedeVolpiano
Copy link
Contributor Author

Ubuntu
/root/.cabal/store
Gentoo
9.6.6 Error: cabal: unrecognised command: path (try --help)
9.8.4 Error: cabal: unrecognised command: path (try --help)

Interesting. I'll try to understand why we don't get the path command in Gentoo

@shayne-fletcher
Copy link
Contributor

hmmm.

with ghc-9.6.7, just try the head of the main repo of stylish-haskell

git clone https://github.com/haskell/stylish-haskell
cd stylish-haskell
cabal build

builds & test pass here

@shayne-fletcher
Copy link
Contributor

Ubuntu /root/.cabal/store Gentoo 9.6.6 Error: cabal: unrecognised command: path (try --help) 9.8.4 Error: cabal: unrecognised command: path (try --help)

Interesting. I'll try to understand why we don't get the path command in Gentoo

do you need an upgrade?

❯ cabal --version
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library 

@shayne-fletcher
Copy link
Contributor

hmmm.

with ghc-9.6.7, just try the head of the main repo of stylish-haskell

git clone https://github.com/haskell/stylish-haskell
cd stylish-haskell
cabal build

builds & test pass here

however, i'm on darwin. good chance that i need to be on linux to make this exhibit. will let you know.

@GuillaumedeVolpiano
Copy link
Contributor Author

Oh yes, on the stylish-haskell ci, tests pass on darwin

@GuillaumedeVolpiano
Copy link
Contributor Author

Ubuntu /root/.cabal/store Gentoo 9.6.6 Error: cabal: unrecognised command: path (try --help) 9.8.4 Error: cabal: unrecognised command: path (try --help)
Interesting. I'll try to understand why we don't get the path command in Gentoo

do you need an upgrade?

❯ cabal --version
cabal-install version 3.12.1.0
compiled using version 3.12.1.0 of the Cabal library 

Oh duh. On gentoo, we have the bundled version, so it's Cabal 3.10.3.0…

@jhrcek
Copy link

jhrcek commented Apr 16, 2025

FYI here's the (failing build) output of building stylish-haskell, main branch, with ghc 9.6.7, building with cabal 3.14.2.0.
I'm on Fedora linux:

~/Devel/github.com/haskell/stylish-haskell> cabal build
Configuration is affected by the following files:
- cabal.project
Resolving dependencies...
Build profile: -w ghc-9.6.7 -O1
In order, the following will be built (use -v for more details):
 - Cabal-syntax-3.14.2.0 (lib) (requires build)
 - optparse-applicative-0.18.1.0 (lib) (requires build)
 - Cabal-3.14.2.0 (lib) (requires build)
 - stylish-haskell-0.15.0.0 (lib) (configuration changed)
 - stylish-haskell-0.15.0.0 (test:stylish-haskell-tests) (configuration changed)
 - stylish-haskell-0.15.0.0 (exe:stylish-haskell) (first run)
Starting     optparse-applicative-0.18.1.0 (lib)
Starting     Cabal-syntax-3.14.2.0 (lib)
Building     optparse-applicative-0.18.1.0 (lib)
Building     Cabal-syntax-3.14.2.0 (lib)
Installing   optparse-applicative-0.18.1.0 (lib)
Completed    optparse-applicative-0.18.1.0 (lib)
Installing   Cabal-syntax-3.14.2.0 (lib)
Completed    Cabal-syntax-3.14.2.0 (lib)
Starting     Cabal-3.14.2.0 (lib)
Building     Cabal-3.14.2.0 (lib)
Installing   Cabal-3.14.2.0 (lib)
Completed    Cabal-3.14.2.0 (lib)
Configuring library for stylish-haskell-0.15.0.0...
Preprocessing library for stylish-haskell-0.15.0.0...
Building library for stylish-haskell-0.15.0.0...
[23 of 26] Compiling Language.Haskell.Stylish.Config.Cabal ( lib/Language/Haskell/Stylish/Config/Cabal.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Language/Haskell/Stylish/Config/Cabal.o, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Language/Haskell/Stylish/Config/Cabal.dyn_o ) [Source file changed]
[24 of 26] Compiling Language.Haskell.Stylish.Config ( lib/Language/Haskell/Stylish/Config.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Language/Haskell/Stylish/Config.o, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Language/Haskell/Stylish/Config.dyn_o ) [Language.Haskell.Stylish.Config.Cabal changed]
[25 of 26] Compiling Paths_stylish_haskell ( dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/autogen/Paths_stylish_haskell.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Paths_stylish_haskell.o, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Paths_stylish_haskell.dyn_o ) [dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/autogen/cabal_macros.h changed]
[26 of 26] Compiling Language.Haskell.Stylish ( lib/Language/Haskell/Stylish.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Language/Haskell/Stylish.o, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/build/Language/Haskell/Stylish.dyn_o ) [Language.Haskell.Stylish.Config changed]
Configuring test suite 'stylish-haskell-tests' for stylish-haskell-0.15.0.0...
Configuring executable 'stylish-haskell' for stylish-haskell-0.15.0.0...
Preprocessing test suite 'stylish-haskell-tests' for stylish-haskell-0.15.0.0...
Building test suite 'stylish-haskell-tests' for stylish-haskell-0.15.0.0...
Preprocessing executable 'stylish-haskell' for stylish-haskell-0.15.0.0...
Building executable 'stylish-haskell' for stylish-haskell-0.15.0.0...
[1 of 1] Compiling Main             ( src/Main.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/x/stylish-haskell/build/stylish-haskell/stylish-haskell-tmp/Main.o )
[ 3 of 16] Compiling Language.Haskell.Stylish.Tests ( tests/Language/Haskell/Stylish/Tests.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/t/stylish-haskell-tests/build/stylish-haskell-tests/stylish-haskell-tests-tmp/Language/Haskell/Stylish/Tests.o ) [Language.Haskell.Stylish changed]
[15 of 16] Compiling Language.Haskell.Stylish.Config.Tests ( tests/Language/Haskell/Stylish/Config/Tests.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/t/stylish-haskell-tests/build/stylish-haskell-tests/stylish-haskell-tests-tmp/Language/Haskell/Stylish/Config/Tests.o ) [Language.Haskell.Stylish.Config changed]
[2 of 2] Linking dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/x/stylish-haskell/build/stylish-haskell/stylish-haskell
[16 of 16] Compiling Main             ( tests/TestSuite.hs, dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/t/stylish-haskell-tests/build/stylish-haskell-tests/stylish-haskell-tests-tmp/Main.o ) [Language.Haskell.Stylish.Config.Tests changed]
[17 of 17] Linking dist-newstyle/build/x86_64-linux/ghc-9.6.7/stylish-haskell-0.15.0.0/t/stylish-haskell-tests/build/stylish-haskell-tests/stylish-haskell-tests
/usr/bin/ld.gold: error: /home/jhrcek/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/x86_64-linux-ghc-9.6.7/rts-1.0.2/libHSrts-1.0.2.a(Globals.o): multiple definition of 'ghc_unique_counter64'
/usr/bin/ld.gold: /home/jhrcek/.cabal/store/ghc-9.6.7/ghc-lib-parser-9.10.1.20250103-6822c1bb167729f4c6ea71be204d04266e852a68038c599260f1664e7c2cb181/lib/libHSghc-lib-parser-9.10.1.20250103-6822c1bb167729f4c6ea71be204d04266e852a68038c599260f1664e7c2cb181.a(genSym.o): previous definition here
/usr/bin/ld.gold: error: /home/jhrcek/.ghcup/ghc/9.6.7/lib/ghc-9.6.7/lib/../lib/x86_64-linux-ghc-9.6.7/rts-1.0.2/libHSrts-1.0.2.a(Globals.o): multiple definition of 'ghc_unique_counter64'
/usr/bin/ld.gold: /home/jhrcek/.cabal/store/ghc-9.6.7/ghc-lib-parser-9.10.1.20250103-6822c1bb167729f4c6ea71be204d04266e852a68038c599260f1664e7c2cb181/lib/libHSghc-lib-parser-9.10.1.20250103-6822c1bb167729f4c6ea71be204d04266e852a68038c599260f1664e7c2cb181.a(genSym.o): previous definition here
collect2: error: ld returned 1 exit status
ghc-9.6.7: `gcc' failed in phase `Linker'. (Exit code: 1)
collect2: error: ld returned 1 exit status
ghc-9.6.7: `gcc' failed in phase `Linker'. (Exit code: 1)
Error: [Cabal-7125]
Failed to build exe:stylish-haskell from stylish-haskell-0.15.0.0.
Failed to build test:stylish-haskell-tests from stylish-haskell-0.15.0.0.
  

@GuillaumedeVolpiano
Copy link
Contributor Author

For ghc-9.8.4/ghc-lib-parser-9.12.2, my two cents at the moment is that line 966 of Ghclibgen.hs need to be updated from

when (ghcFlavor <= Ghc9121) $

to

when (ghcFlavor <= Ghc9122) $

Still hitting snags building ghc-lib-parsers, so can't test.

@GuillaumedeVolpiano
Copy link
Contributor Author

FWIW, on Gentoo with ghc-9.10 (and thus Cabal 3.12), I get the same kind of ambiguous module name issue as on Ubuntu, albeit on a different module.

https://bpa.st/IIVA

@shayne-fletcher
Copy link
Contributor

shayne-fletcher commented Apr 16, 2025

FWIW, on Gentoo with ghc-9.10 (and thus Cabal 3.12), I get the same kind of ambiguous module name issue as on Ubuntu, albeit on a different module.

https://bpa.st/IIVA

my read of that is there are two versions of unix with different hashes installed at cabal path --store. delete the contents of that dir and it might come good. don't get hung up though. i can get back to you with a fix if you can wait a few days

@GuillaumedeVolpiano
Copy link
Contributor Author

Indeed, it worked.

@GuillaumedeVolpiano
Copy link
Contributor Author

Just to confirm that
1 - The linking error still happens with current ghc-lib-parser
2 - My intuition above was wrong. My question is rather now whether line 969 is doing anything. I'm not finding !MIN_VERSION_ghc(9,8,4,0) in any version of genSym.c

@shayne-fletcher
Copy link
Contributor

shayne-fletcher commented Apr 16, 2025

exactly. create a branch, try this hack in Ghclibgen.hs

    let file = "compiler/cbits/genSym.c"
    in writeFile file
       . replace "#if !MIN_VERSION_GLASGOW_HASKELL(9,9,1,0)" "#if !MIN_VERSION_GLASGOW_HASKELL(9,6,7,0)"
       . replace "#if !MIN_VERSION_GLASGOW_HASKELL(9,8,4,0)" "#if !MIN_VERSION_GLASGOW_HASKELL(9,6,7,0)"
       =<< readFile' file

check it in (to prevent the build system from checking it out and overwriting your changes).

it will probably fix the problem.

if not, after the build (cabal run exe:ghc-lib-build-tool -- --ghc-flavor ghc-9.12.2 or whatever) there will be a ghc-lib/ghc-lib-parser dir. inspect ghc-lib-parser/GHC/cbits/genSym.c. this should prevent this variable from being defined for all compilers in the range 9.6.7..9.13.0.

@shayne-fletcher
Copy link
Contributor

Just to confirm that 1 - The linking error still happens with current ghc-lib-parser 2 - My intuition above was wrong. My question is rather now whether line 969 is doing anything. I'm not finding !MIN_VERSION_ghc(9,8,4,0) in any version of genSym.c

there has been so much churn in genSym.c regarding this. i think the condition for that definition has changed multiple times over the course of the last year or so invalidating released (ghc-lib-parser) packages. hopefully when we fix this, it is behind us for good.

@GuillaumedeVolpiano
Copy link
Contributor Author

And we're good

@GuillaumedeVolpiano
Copy link
Contributor Author

No pressure, but once we get this fixed, do you mind making a release so that we can get stylish-haskell go forward and then hls-stylish-haskell-plugin? ;)

@shayne-fletcher
Copy link
Contributor

No pressure, but once we get this fixed, do you mind making a release so that we can get stylish-haskell go forward and then hls-stylish-haskell-plugin? ;)

we'll do that.

@shayne-fletcher
Copy link
Contributor

No pressure, but once we get this fixed, do you mind making a release so that we can get stylish-haskell go forward and then hls-stylish-haskell-plugin? ;)

assuming we land #596 what flavors do we need new releases for? ghc-9.10.1, ghc-9.12.2?

@GuillaumedeVolpiano
Copy link
Contributor Author

Both if you don't mind

@GuillaumedeVolpiano
Copy link
Contributor Author

Question: with ghc-9.10.2-rc1 being released today and the final release scheduled for week after next, do we want to wait for it to make the release?

@shayne-fletcher
Copy link
Contributor

i would say it's not a big deal to push packages so we'll just do what we can when we can. i think the likely order will be, the fix is landed we push new packages for 9.10.1, 9.12.2, put up a diff for 9.10.2 support and push 9.10.2 after landing that.

@GuillaumedeVolpiano
Copy link
Contributor Author

All right !

@shayne-fletcher
Copy link
Contributor

packages tagged 20250421 pushed

@GuillaumedeVolpiano
Copy link
Contributor Author

Thanks

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

Successfully merging a pull request may close this issue.

3 participants