Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Shared libraries on OSX not linked with framework dependencies or custom ld flags #2715

Open
yiding opened this issue Jul 10, 2015 · 0 comments

Comments

@yiding
Copy link

yiding commented Jul 10, 2015

On OSX at least, shared libraries are not linked with frameworks, resulting in dylibs which do not declare dependencies correctly (and cannot be loaded unless the dependency is manually loaded). Additionally, ld-options are also ignored for these dylibs.

I think the issue might be

ghcSharedLinkArgs =
where ld options and frameworks are not specified when generating the dylib.

cabal-install version 1.22.0.0
using version 1.22.0.0 of the Cabal library

Example:

cabal file snippet

library
  exposed-modules:     Test
  -- other-modules:       
  other-extensions:    ForeignFunctionInterface
  build-depends:       base >=4.8 && <4.9
  -- hs-source-dirs:      
  default-language:    Haskell2010
  ld-options: wtf is this used for
  frameworks: CoreFoundation

and a Test.hs like this:

{-# LANGUAGE ForeignFunctionInterface #-}
module Test where
import Foreign

foreign import ccall "CFRelease" cfRelease :: Ptr a -> IO ()

releaseNull = cfRelease nullPtr

The dylib that gets generated turns out to be this:

~/t/ghc-framework-test ❯❯❯ otool -L dist/build/libHSghcfr_C05XexetHdH9tTr8o4CTUh-ghc7.10.1.dylib
dist/build/libHSghcfr_C05XexetHdH9tTr8o4CTUh-ghc7.10.1.dylib:
    @rpath/libHSghcfr_C05XexetHdH9tTr8o4CTUh-ghc7.10.1.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libHSbase-4.8.0.0-I5BErHzyOm07EBNpKBEeUv-ghc7.10.1.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libHSinteger-gmp-1.0.0.0-2aU3IZNMF9a7mQ0OzsZ0dS-ghc7.10.1.dylib (compatibility version 0.0.0, current version 0.0.0)
    @rpath/libHSghc-prim-0.4.0.0-8TmvWUcS1U1IKHT0levwg3-ghc7.10.1.dylib (compatibility version 0.0.0, current version 0.0.0)
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)

No mention of CoreFoundation anywhere.

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

No branches or pull requests

3 participants