Skip to content
This repository has been archived by the owner on Apr 25, 2020. It is now read-only.

Linker error with Nix, Stack and Template Haskell #915

Open
tomsmalley opened this issue Oct 25, 2017 · 5 comments
Open

Linker error with Nix, Stack and Template Haskell #915

tomsmalley opened this issue Oct 25, 2017 · 5 comments

Comments

@tomsmalley
Copy link

This only occurs when TH is enabled in the module I'm trying to check.
The project depends on wai-app-static but not optparse-applicative. This module does not import it. cabal new-repl works as expected.

[nix-shell:~/projects/semantic-reflex/semantic-reflex/src/Reflex/Dom/SemanticUI]$ ghc-mod check Lenses.hs --verbose debug
info: Found Stack project at: /etc/home/tom/projects/semantic-reflex/semantic-reflex
info: Using Stack project at: /etc/home/tom/projects/semantic-reflex/semantic-reflex
DEBUG: reading cache: /etc/home/tom/projects/semantic-reflex/semantic-reflex/.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup-config.ghc-mod.cabal-components
DEBUG: resolveEntrypoint:
       ["-i","-i.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build","-isrc","-i.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen","-I.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen","-I.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build","-optP-D_GHCJS_","-optP-DGHCJS_GC_INTERVAL=60000","-optP-DGHCJS_BROWSER","-optP-include","-optP.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen/cabal_macros.h"]
DEBUG: resolveEntrypoint:
       ["-i","-i.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/test/test-tmp","-itest","-i.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen","-I.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen","-I.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/test/test-tmp","-optP-include","-optP.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen/cabal_macros.h"]
DEBUG: resolveEntrypoint:
       ["-i","-i.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/bench/bench-tmp","-ibench","-i.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen","-I.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen","-I.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/bench/bench-tmp","-optP-include","-optP.stack-work/dist/x86_64-linux/Cabal-1.24.2.0/build/autogen/cabal_macros.h"]
DEBUG: resolveEntrypoint: []
DEBUG: making sure autogen files exist
DEBUG: reading cache: .stack-work/dist/x86_64-linux/Cabal-1.24.2.0/setup-config.ghc-mod.resolved-components
DEBUG: initSession: Session not initialized, creating new one
DEBUG: loadTargets: Loading: src/Reflex/Dom/SemanticUI/Lenses.hs
info: loadTargets:
      Target needs interpeter, switching to LinkInMemory/HscInterpreted. Perfectly normal if anything is using TemplateHaskell, QuasiQuotes or PatternSynonyms.
<command line>: can't load .so/.DLL for: /nix/store/vh2vpnc65r7cd2viip4fsad11mq7yj2l-wai-app-static-3.1.6.1/lib/ghc-8.0.2/x86_64-linux-ghc-8.0.2/libHSwai-app-static-3.1.6.1-JOHjWx1ETz87tV2XvseO6M-ghc8.0.2.so (/nix/store/vh2vpnc65r7cd2viip4fsad11mq7yj2l-wai-app-static-3.1.6.1/lib/ghc-8.0.2/x86_64-linux-ghc-8.0.2/libHSwai-app-static-3.1.6.1-JOHjWx1ETz87tV2XvseO6M-ghc8.0.2.so: undefined symbol: optparsezmapplicativezm0zi13zi2zi0zmEqIYOWOFTvf23sT5QTYn9U_OptionsziApplicativeziTypes_manyMzuzdcfmap_info)
@DanielG
Copy link
Owner

DanielG commented Oct 26, 2017

Sounds unlikely to be a ghc-mod problem TBH. Have you checked the referenced file actually exists and has proper permissions and whatnot?

Edit: Nevermind didn't see the linker error. I would just try to rebuild everything. Can you try to compile the same package with cabal sandboxes instead of nix maybe?

@tomsmalley
Copy link
Author

I think it is related to #905, just using a sandbox fixes it. nix-shell provides cabal-install 2.0.0.0 and gives the same error as in the linked issue.

@DanielG
Copy link
Owner

DanielG commented Nov 7, 2017

Actually looking at this issue again I seem to have missed you're using nix and stack together (dunno how, it says like right there ;) it seems strange to me that ghc would be complaining about linking a lib from nix when you're using stack. Does stack have some special support for nix where it uses packages from nix or something?

Either way could you tell me how to reproduce your nix environment on my machine? I don't actually use nix though but I happen to have it installed so be gentile :)

@DanielG DanielG changed the title Linker error with Template Haskell Linker error with Nix, Stack and Template Haskell Nov 8, 2017
@danbst
Copy link

danbst commented Mar 15, 2020

the problem occurs when system and Nix glibc versions mismatch. In particular, v2.26 system and v2.30 in Nix will cause this error on every template haskell usage.

@danbst
Copy link

danbst commented Mar 15, 2020

I've solved this issue by using

system-ghc: true
install-ghc: false
skip-ghc-check: true

in stack.yaml and running everything from within nix-shell.

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

No branches or pull requests

3 participants