haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 691 forks source link

Missing modules in `exposed-modules` and linker errors #8902

Open ffaf1 opened 1 year ago

ffaf1 commented 1 year ago

Describe the bug

Related: #1746

I recently have helped a user with a well know error, forgetting to put modules in exposed-modules (edit: actually, other-modules, but it is the same problem).

What we know:

The hint got probably overlooked because of the barrage of abuse by the linker

⁝
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.text+0x9406): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Syntax_zdWMapLiteral_info'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.text+0x9496): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Syntax_zdWIdentifier_info'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.text+0xaf16): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Syntax_zdWStringLiteral_info'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.text+0xb43e): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Syntax_zdWCharLiteral_info'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.text+0xbab0): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Lexer_boolean1_info'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.data+0xbd8): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Lexer_variable_closure'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.data+0xbe8): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Lexer_comma1_closure'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.data+0x11a0): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Lexer_boolean1_closure'
/tmp/aura_lang/dist-newstyle/build/x86_64-linux/ghc-9.2.1/aura-lang-0.1.0.0/build/libHSaura-lang-0.1.0.0-inplace.a(Parser.o)(.data+0x1458): error: undefined reference to 'aurazmlangzm0zi1zi0zi0zminplace_Lexer_arrow1_closure'
⁝

and the fact that warnings are not displayed again on a new cabal run.

Expected behavior

The user notices the error, is able to understand it and fix it by themselves.

I would not know precisely what to suggest though: upgrading the warning to error could be annoying to a number of developers. Redirecting linker output somewhere too could break some dev setups.

To reproduce

Create a lib/exe .cabal, forget to expose a module in the lib that is needed by the exe.

ffaf1 commented 10 months ago

See #9491 for similar problems.

ulysses4ever commented 10 months ago

Yes, I've got bitten by this and very much agree that there's a UX issue that can be solved to improve users' life.

ffaf1 commented 10 months ago

More users having problems with mising modules in .cabal.

I wonder if this could help (UX: user gets a barrage of abuse from the linker, but also a “0 errors, 1 warning” message at the end, gets curious, reads the message, adds the missing module).