agrafix / elm-bridge

Haskell: Derive Elm types from Haskell types
BSD 3-Clause "New" or "Revised" License
100 stars 27 forks source link

Strange linking error on OS X #20

Closed dunnl closed 6 years ago

dunnl commented 7 years ago

I'm having an issue using this elm-bridge and hlibsass. I have built a testing repo here https://github.com/dunnl/elm-bridge-iss20. It has something to do with the TemplateHaskell. The code looks like this:

{-# language TemplateHaskell #-}
{-# language DeriveGeneric     #-}
{-# language RecordWildCards   #-}

module Main where

import Bindings.Libsass
import Elm.Derive
import GHC.Generics

data Test = Test { content :: String, number :: Int}
  deriving (Generic)

deriveBoth defaultOptions ''Test

main :: IO ()
main = print "Test"

stack build gives me errors like this:

ghc: 
lookupSymbol failed in relocateSection (RELOC_GOT)
/Users/dunnl/.stack/snapshots/x86_64-osx/lts-9.5/8.0.2/lib/x86_64-osx-ghc-8.0.2/hlibsass-0.1.6.1-5YgnetLqItEKQRTonDV5HP/libsass.a: unknown symbol `___dso_handle'
ghc: Could not on-demand load symbol 
'__ZN4Sass10VectorizedINS_10SharedImplINS_15Simple_SelectorEEEE20adjust_after_pushingES3_'

ghc: 
lookupSymbol failed in relocateSection (relocate external)
/Users/dunnl/.stack/snapshots/x86_64-osx/lts-9.5/8.0.2/lib/x86_64-osx-ghc-8.0.2/hlibsass-0.1.6.1-5YgnetLqItEKQRTonDV5HP/libsass.a: unknown symbol `__ZN4Sass15read_css_stringERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE'
ghc: Could not on-demand load symbol '__ZN4Sass15String_ConstantC2ENS_11ParserStateEPKc'

The problem does not go away after nuking .stack-work/ and even after deleting stack's snapshots in my home folder. I am not sure if the problem is unique to hlibsass, but it has given people problems on OS X before. I'm also not sure that the problem is unique to elm-bridge either, but I can't reproduce the error with simple TH expressions. Removing either deriveBoth or import Bindings.Libsass (and removing the dep. from the cabal file) fixes the problem. I cannot reproduce the issue on my Arch linux box.

Possibly related: GHC #11617, hlibsass #5

This sounds like it's not elm-bridge's "fault", but I don't know enough about template haskell to understand the problem. I guess TH changes the parameters of the linking stage?

bartavelle commented 7 years ago

I do not own a mac, and I really have no clue at what your problem might be. TH loads modules during compilation, so that certainly could be related to TH. Other than that, I don't know how to help you!

agrafix commented 6 years ago

Closing due to inactiveness.