haskell / haskell/cabal

Paths_XYZ exposed in one library can't be used in another of multiple libraries.

Open
#7,523 2 comments 0 reactions 0 assignees View on GitHub
blocked: decision-needed type: bug
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**

In the following reproduction branch https://github.com/LambdaHack/LambdaHack/tree/multilib-paths-bug the Paths_LambdaHack module (both its `exposed` and `autogen` mentions) is moved from anonymous library to library `definition` (as seen in the last commit on that branch). Before that last commit, it compiled and linked fine, now I have the following warnings (which indicate this may be a GHC bug or we fool GHC somehow) and errors:

```
cabal build .
[...]
Building library 'this-game-content' for LambdaHack-0.10.2.0..
: warning: [-Wmissing-home-modules]
These modules are needed for compilation but not listed in your .cabal file's other-modules:
Paths_LambdaHack
Configuring library 'this-game-src' for LambdaHack-0.10.2.0..
[...]
Building executable 'LambdaHack' for LambdaHack-0.10.2.0..
Linking /home/mikolaj/r/LambdaHack/dist-newstyle/build/x86_64-linux/ghc-8.10.4/LambdaHack-0.10.2.0/x/LambdaHack/noopt/build/LambdaHack/LambdaHack ...
/home/mikolaj/r/LambdaHack/dist-newstyle/build/x86_64-linux/ghc-8.10.4/LambdaHack-0.10.2.0/noopt/build/libHSLambdaHack-0.10.2.0-inplace.a(Commandline.o)(.text+0xa4ef): error: undefined reference to 'LambdaHackzm0zi10zi2zi0zminplace_PathszuLambdaHack_version_closure'
/home/mikolaj/r/LambdaHack/dist-newstyle/build/x86_64-linux/ghc-8.10.4/LambdaHack-0.10.2.0/noopt/build/libHSLambdaHack-0.10.2.0-inplace.a(Commandline.o)(.data+0xc38): error: undefined reference to 'LambdaHackzm0zi10zi2zi0zminplace_PathszuLambdaHack_version_closure'
/home/mikolaj/r/LambdaHack/dist-newstyle/build/x86_64-linux/ghc-8.10.4/LambdaHack-0.10.2.0/noopt/build/libHSLambdaHack-0.10.2.0-inplace.a(MonadServer.o)(.text+0x2df9): error: undefined reference to 'LambdaHackzm0zi10zi2zi0zminplace_PathszuLambdaHack_version_closure'
/home/mikolaj/r/LambdaHack/dist-newstyle/build/x86_64-linux/ghc-8.10.4/LambdaHack-0.10.2.0/noopt/build/libHSLambdaHack-0.10.2.0-inplace.a(MonadServer.o)(.text+0x4d1e): error: undefined reference to 'LambdaHackzm0zi10zi2zi0zminplace_PathszuLambdaHack_version_closure'
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
```

**To Reproduce**

As above.

**Expected behavior**

Should compile and link fine.

**System information**

Linux, cabal 3.6, GHC 8.10.4, no custom setup, multilib.

**Additional context**

May be distantly related to #7522 or may even be a workaround (unlikely).

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue from the multilib-paths-bug branch with cabal build, using the reported Cabal and GHC versions. Inspect the library definitions and the generated Paths_LambdaHack module references; done means both libraries compile and the LambdaHack executable links without missing-home-modules warnings or undefined references.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.