stack build vs stack ghci with FFI libraries

97 views
Skip to first unread message

Mark Fine

unread,
Oct 7, 2016, 1:21:30 AM10/7/16
to haskell-stack
I have a simple project that's vendoring in serialport and unix packages:
resolver: lts-6.20
packages:
- '.'
- './unix'
- './serialport'
extra-deps: []
flags: {}
stack build works fine:
serialport-0.4.7: unregistering (missing dependencies: unix)
unix-2.7.2.0: unregistering (local file changes: System/Posix.hs System/Posix/ByteString.hs System/Posix/ByteString/FilePath.hsc System/Posix/Dire...)
unix-2.7.2.0: configure
unix-2.7.2.0: build
unix-2.7.2.0: copy/register
serialport-0.4.7: configure
serialport-0.4.7: build
serialport-0.4.7: copy/register
serial-0.0.0: configure
serial-0.0.0: build
serial-0.0.0: copy/register
Completed 3 action(s).
stack ghci has linking errors:

Using main module: 1. Package `serial' component exe:serial with main-is file: /Users/mark/repos/serial/main.hs
Configuring GHCi with the following packages: serial, serialport, unix
GHCi, version 7.10.3: http://www.haskell.org/ghc/  :? for help
[1 of 8] Compiling System.Hardware.Serialport.Types ( /Users/mark/repos/serial/serialport/System/Hardware/Serialport/Types.hs, interpreted )
[2 of 8] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC9ZCmainZCSystemziPosixziTerminalziCommonZCcfgetispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-ha...@haskell.org

[ 2 of 42] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC19ZCmainZCSystemziPosixziTerminalziCommonZCcfgetispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-ha...@haskell.org

[ 2 of 43] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC29ZCmainZCSystemziPosixziTerminalziCommonZCcfgetispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-ha...@haskell.org


<no location info>:
    Could not find module ‘System.Hardware.Serialport’
    It is a member of the hidden package ‘serialport-0.4.7@seria_6XlGeNhayTj8u1Q5vnbF3w’.
Prelude> 
I see that both vendored projects have their own .stack-work's - is that a source of issues? Is there a workaround where I can get stack ghci to behave as well as stack build - things run great as executables, just can't load the code in ghci.

Also, I'd love to be able to bring in both of these projects as git locations - but the unix library requires running autoreconf -i in it's directory, and it's not clear how I can manage that with a git location (instead I'm vendoring them in with git submodules).

Any help would be greatly appreciated!

Mark

Michael Snoyman

unread,
Oct 7, 2016, 1:23:06 AM10/7/16
to Mark Fine, haskell-stack

I'm not a ghci expert, but perhaps marking those vendored libraries as extra-dep: true would help.


--
You received this message because you are subscribed to the Google Groups "haskell-stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stac...@googlegroups.com.
To post to this group, send email to haskel...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/haskell-stack/CANRZ_fkafdAjGLUiUqnjPLSTP%2BzF6rpJaHScyV2pSgX45oCNwg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Mark Fine

unread,
Oct 7, 2016, 1:31:11 AM10/7/16
to Michael Snoyman, haskell-stack
Oh wow, that totally did it - didn't realize you could use location on vendored projects, but that makes total sense:
resolver: lts-6.20
packages:
- .
- location: unix
  extra-dep: true
- location: serialport
  extra-dep: true
extra-deps: []
flags: {}
Thanks!

Mark

tispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-haskell-bugs@haskell.org

[ 2 of 42] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC19ZCmainZCSystemziPosixziTerminalziCommonZCcfg
etispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-haskell-bugs@haskell.org

[ 2 of 43] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC29ZCmainZCSystemziPosixziTerminalziCommonZCcfg
etispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-haskell-bugs@haskell.org


<no location info>:
    Could not find module ‘System.Hardware.Serialport’
    It is a member of the hidden package ‘serialport-0.4.7@seria_6XlGeNhayTj8u1Q5vnbF3w’.
Prelude> 
I see that both vendored projects have their own .stack-work's - is that a source of issues? Is there a workaround where I can get stack ghci to behave as well as stack build - things run great as executables, just can't load the code in ghci.

Also, I'd love to be able to bring in both of these projects as git locations - but the unix library requires running autoreconf -i in it's directory, and it's not clear how I can manage that with a git location (instead I'm vendoring them in with git submodules).

Any help would be greatly appreciated!

Mark
--
You received this message because you are subscribed to the Google Groups "haskell-stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stack+unsubscribe@googlegroups.com.

Michael Snoyman

unread,
Oct 7, 2016, 1:32:31 AM10/7/16
to Mark Fine, haskell-stack

Awesome!


  :? for help
[1 of 8] Compiling System.Hardware.Serialport.Types ( /Users/mark/repos/serial/serialport/System/Hardware/Serialport/Types.hs, interpreted )
[2 of 8] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC9ZCmainZCSystemziPosixziTerminalziCommonZCcfgetispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-ha...@haskell.org

[ 2 of 42] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC19ZCmainZCSystemziPosixziTerminalziCommonZCcfgetispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-ha...@haskell.org

[ 2 of 43] Compiling System.Posix.Terminal.Common ( /Users/mark/repos/serial/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/build/System/Posix/Terminal/Common.hs, interpreted )

ByteCodeLink: can't find label
During interactive linking, GHCi couldn't find the following symbol:
  ghczuwrapperZC29ZCmainZCSystemziPosixziTerminalziCommonZCcfgetispeed
This may be due to you not asking GHCi to load extra object files,
archives or DLLs needed by your current session.  Restart GHCi, specifying
the missing library using the -L/path/to/object/dir and -lmissinglibname
flags, or simply by naming the relevant files on the GHCi command line.
Alternatively, this link failure might indicate a bug in GHCi.
If you suspect the latter, please send a bug report to:
  glasgow-ha...@haskell.org


<no location info>:
    Could not find module ‘System.Hardware.Serialport’
    It is a member of the hidden package ‘serialport-0.4.7@seria_6XlGeNhayTj8u1Q5vnbF3w’.
Prelude> 
I see that both vendored projects have their own .stack-work's - is that a source of issues? Is there a workaround where I can get stack ghci to behave as well as stack build - things run great as executables, just can't load the code in ghci.

Also, I'd love to be able to bring in both of these projects as git locations - but the unix library requires running autoreconf -i in it's directory, and it's not clear how I can manage that with a git location (instead I'm vendoring them in with git submodules).

Any help would be greatly appreciated!

Mark
--
You received this message because you are subscribed to the Google Groups "haskell-stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stac...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "haskell-stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haskell-stac...@googlegroups.com.

To post to this group, send email to haskel...@googlegroups.com.

Mark Fine

unread,
Oct 17, 2016, 5:44:17 PM10/17/16
to Michael Snoyman, haskell-stack
Just a quick follow-up here - the unix package has a cabal build type of Configure - when I try and build it with stack, I get the following error:

--  While building package unix-2.7.2.0 using:
      /Users/mark/repos/xxx/unix/.stack-work/dist/x86_64-osx/Cabal-1.22.5.0/setup/setup --builddir=.stack-work/dist/x86_64-osx/Cabal-1.22.5.0 configure --with-ghc=/Applications/ghc-7.10.3.app/Contents/bin/ghc --with-ghc-pkg=/Applications/ghc-7.10.3.app/Contents/bin/ghc-pkg --user --package-db=clear --package-db=global --package-db=/Users/mark/.stack/snapshots/x86_64-osx/lts-6.3/7.10.3/pkgdb --package-db=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/pkgdb --libdir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/lib --bindir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/bin --datadir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/share --libexecdir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/libexec --sysconfdir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/etc --docdir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/doc/unix-2.7.2.0 --htmldir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/doc/unix-2.7.2.0 --haddockdir=/Users/mark/repos/xxx/.stack-work/install/x86_64-osx/lts-6.3/7.10.3/doc/unix-2.7.2.0 --dependency=base=base-4.8.2.0-cc43d8e06aa74e9c4c0132becc49ee25 --dependency=bytestring=bytestring-0.10.6.0-04b5cc1d05f993b3b016543ca2863add --dependency=time=time-1.5.0.1-9d583724234c876226763fdd0cb776fc --enable-tests --enable-benchmarks
    Process exited with code: ExitFailure 1
    Logs have been written to: /Users/mark/repos/xxx/.stack-work/logs/unix-2.7.2.0.log

    Configuring unix-2.7.2.0...
    Warning: The 'build-type' is 'Configure' but there is no 'configure' script.
    You probably need to run 'autoreconf -i' to generate it.
    setup: configure script not found.

When I manually run autoreconf -i on the unix project subdirectory, the issue goes away. Is there something special I need to specify to get stack to support this kind of cabal build type?

Mark

Michael Snoyman

unread,
Oct 18, 2016, 3:44:21 AM10/18/16
to Mark Fine, haskell-stack
Neither Cabal nor Stack provides any way to automate the running of autoreconf, it just needs to be done manually.

Mark Fine

unread,
Oct 18, 2016, 5:47:14 PM10/18/16
to Michael Snoyman, haskell-stack
Thanks!

Mark
Reply all
Reply to author
Forward
0 new messages