Package imports can cause linker errors
Summary
My project depends on servant-checked-exceptions
and there is a similar package servant-checked-exceptions-core
.
Both export a similar module structure, and servant-checked-exceptions
depends on servant-checked-exceptions-core
through PackageImports
. These interact in funny ways and can cause linker errors
Steps to reproduce
Please provide a set of concrete steps to reproduce the issue.
git clone https://github.com/arianvp/wire-servant-playground
cabal new-build
- open the cabal file and change
servant-checked-exceptions
toservant-checked-exceptions-core
. cabal new-build
- GHC will crash with a linker error
- delete
dist-newstyle
cabal new-build
- GHC will report a type error
Expected behavior
GHC should have said:
src/Server.hs:9:12: error:
• Couldn't match type ‘ServerT
(Throws NotFound
Servant.API.Sub.:> (Throws Unauthorized
Servant.API.Sub.:> Servant.API.Verbs.Get
'[Servant.API.ContentTypes.JSON]
String))
Handler’
with ‘m0 (Envelope es0 [Char])’
Expected type: AsServer
Servant.API.Generic.:- (Servant.API.Capture.Capture "id" Int
Servant.API.Sub.:> (Throws NotFound
Servant.API.Sub.:> (Throws
Unauthorized
Servant.API.Sub.:> Servant.API.Verbs.Get
'[Servant.API.ContentTypes.JSON]
String)))
Actual type: Int -> m0 (Envelope es0 [Char])
The type variables ‘m0’, ‘es0’ are ambiguous
• In the ‘_get’ field of a record
In the expression:
Routes
{_get = const (pureSuccEnvelope "yo"), _put = const (return False)}
In an equation for ‘server’:
server
= Routes
{_get = const (pureSuccEnvelope "yo"), _put = const (return False)}
|
9 | { _get = const (pureSuccEnvelope "yo")
Actual behaviour
[nix-shell:~/Projects/wire/wire-servant-playground]$ cabal new-build
Resolving dependencies...
Build profile: -w ghc-8.6.5 -O1
In order, the following will be built (use -v for more details):
- wire-servant-playground-0.1.0.0 (lib) (configuration changed)
- wire-servant-playground-0.1.0.0 (exe:wire-servant-playground) (configuration changed)
Configuring library for wire-servant-playground-0.1.0.0..
Preprocessing library for wire-servant-playground-0.1.0.0..
Building library for wire-servant-playground-0.1.0.0..
Configuring executable 'wire-servant-playground' for wire-servant-playground-0.1.0.0..
Preprocessing executable 'wire-servant-playground' for wire-servant-playground-0.1.0.0..
Building executable 'wire-servant-playground' for wire-servant-playground-0.1.0.0..
Linking /home/arian/Projects/wire/wire-servant-playground/dist-newstyle/build/x86_64-linux/ghc-8.6.5/wire-servant-playground-0.1.0.0/x/wire-servant-playground/build/wire-servant-playground/wire-servant-playground ...
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin/ld: /home/arian/Projects/wire/wire-servant-playground/dist-newstyle/build/x86_64-linux/ghc-8.6.5/wire-servant-playground-0.1.0.0/build/libHSwire-servant-playground-0.1.0.0-inplace.a(Server.o): in function `rCBH_info':
(.text+0xf53): undefined reference to `servantzmcheckedzmexceptionszm2zi2zi0zi0zm9015e86b13ae59e8ab1cda70195e06cc7212c2b8bb56605eb25da61824ed8275_ServantziCheckedziExceptionsziInternalziServantziServer_zdwzdcroute_info'
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin/ld: /home/arian/Projects/wire/wire-servant-playground/dist-newstyle/build/x86_64-linux/ghc-8.6.5/wire-servant-playground-0.1.0.0/build/libHSwire-servant-playground-0.1.0.0-inplace.a(Server.o): in function `uCPf_srt':
(.data+0x4d0): undefined reference to `servantzmcheckedzmexceptionszm2zi2zi0zi0zm9015e86b13ae59e8ab1cda70195e06cc7212c2b8bb56605eb25da61824ed8275_ServantziCheckedziExceptionsziInternalziServantziServer_zdwzdcroute_closure'
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
Environment
- GHC version used: 8.6.5
Optional:
- Operating System:
- System Architecture: