Skip to content

Can't load .so/.DLL error when building in stack 2 #4969

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

Open
drathier opened this issue Jul 18, 2019 · 6 comments
Open

Can't load .so/.DLL error when building in stack 2 #4969

drathier opened this issue Jul 18, 2019 · 6 comments

Comments

@drathier
Copy link

Possibly related to #3559 .

Got a hard-to-debug error message from stack 2. The project builds fine in 1.9.3 but fails on 2.1.3. The comp-crypto package contains crypto libs, which are found by the globalstate-types pkg in 1.9.3 but not in 2.1.3.

Dependency chain: lang -> globalstate-types -> comp-crypto.

I expected this to work out of the box, but it doesn't. Secondly, I expected an error message I could understand.

build-failure 2.1.3

stack-2.1.3-osx-x86_64 install --fast

...
globalstate-types> <command line>: can't load .so/.DLL for: /Users/drathier/.stack/snapshots/x86_64-osx/4cddd3f7752ee317a90244a048f88d3bce60013db6c5a4f991984894ac47a3d5/8.6.5/lib/x86_64-osx-ghc-8.6.5/libHScomp-crypto-0.1-iqz19whF4R7ZMNz0UbV0J-ghc8.6.5.dylib (dlopen(/Users/drathier/.stack/snapshots/x86_64-osx/4cddd3f7752ee317a90244a048f88d3bce60013db6c5a4f991984894ac47a3d5/8.6.5/lib/x86_64-osx-ghc-8.6.5/libHScomp-crypto-0.1-iqz19whF4R7ZMNz0UbV0J-ghc8.6.5.dylib, 5): Library not loaded: /private/var/folders/3b/mm4qz4l16zx7rf_2408zr51r0000gn/T/stack-bcc4b1bde172663e/comp-crypto-0.1/rust-src/target/release/deps/libec_vrf_ed25519.dylib
globalstate-types>   Referenced from: /Users/drathier/.stack/snapshots/x86_64-osx/4cddd3f7752ee317a90244a048f88d3bce60013db6c5a4f991984894ac47a3d5/8.6.5/lib/x86_64-osx-ghc-8.6.5/libHScomp-crypto-0.1-iqz19whF4R7ZMNz0UbV0J-ghc8.6.5.dylib
globalstate-types>   Reason: image not found)

--  While building package globalstate-types-0.1.0.0 using:
      /Users/drathier/.stack/setup-exe-cache/x86_64-osx/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-osx/Cabal-2.4.0.1 build --ghc-options " -fdiagnostics-color=always"
    Process exited with code: ExitFailure 1
Progress 1/3

build-success 1.9.3

stack-1.9.3-osx-x86_64 install --fast

...
lang-0.19.0: copy/register
Installing library in /Users/drathier/comp/lang-compiler/.stack-work/install/x86_64-osx/lts-13.20/8.6.5/lib/x86_64-osx-ghc-8.6.5/lang-0.19.0-9XKsIJQKKQ5Jg9KPGVTL4R
Installing executable lang in /Users/drathier/comp/lang-compiler/.stack-work/install/x86_64-osx/lts-13.20/8.6.5/bin
Registering library for lang-0.19.0..
Completed 168 action(s).
Copying from /Users/drathier/comp/lang-compiler/.stack-work/install/x86_64-osx/lts-13.20/8.6.5/bin/lang to /Users/drathier/.local/bin/lang

Copied executables to /Users/drathier/.local/bin:
- lang

dependency: comp-crypto

stack.yaml of comp-crypto-0.1 pkg

resolver: lts-13.20

packages:
- .

extra-lib-dirs:
    - ./rust-src/target/release/

cabal file for comp-crypto-0.1

Name:           comp-crypto
version:         0.1
Synopsis:       Crypto infrastructure for comp
Description:
License:        BSD3
Author:         Comp.com
Stability:      Experimental
Cabal-Version:       >=1.18
Build-Type:     Custom

custom-setup
  setup-depends:
    base  >= 4.7,
    Cabal >= 2.2,
    directory >= 1.3

source-repository head
  type: git
  location: https://gitlab.com/Comp/crypto

Library
  default-language: Haskell2010
  default-extensions:      ForeignFunctionInterface

  hs-source-dirs: haskell-src
  Exposed-modules: Comp.Crypto.SHA256
                   Comp.Crypto.SHA224
                   Comp.Crypto.Ed25519Signature
                   Comp.Crypto.BlockSignature
                   Comp.Crypto.SignatureScheme
                   Comp.Crypto.AccountSignatureSchemes
                   Comp.Crypto.PedersenScheme
                   Comp.Crypto.Elgamal
                   Comp.Crypto.VRF
                   Comp.Crypto.PRF
                   Data.FixedByteString
                   Comp.ID.Attributes
                   Comp.ID.Types
                   Comp.ID.Account

  Other-modules:   Comp.Crypto.ByteStringHelpers
  Build-depends:  base >=4.7
                , bytestring >=0.10
                , cereal >=0.5.7
                , hashable >= 1.0.1.1
                , random >= 1.1
                , stringbuilder >=0.5.0
                , containers >= 0.5.11.0
                , time       >= 1.7
                , random-bytestring >= 0.1.3.0
                , base58string >= 0.10.0
                , QuickCheck >= 2.10
                , vector >= 0.12
                , text >= 1.2.3.1

  extra-libraries: ec_vrf_ed25519
                   sha_2,
                   eddsa_ed25519,
                   dodis_yampolskiy_prf
                   pedersen_scheme
                   elgamal
  if os(windows)
        extra-libraries: ws2_32
                         userenv

Test-Suite tests
  default-language: Haskell2010
  type: exitcode-stdio-1.0
  main-is: Spec.hs
  hs-source-dirs: haskell-tests
  build-depends:    hspec >= 2.5
                    , QuickCheck >= 2.10
                    , hspec-expectations >= 0.8
                    , base >= 4.7
                    , comp-crypto
                    , bytestring >=0.10
                    , cereal >=0.5.7
                    , random >= 1.1
  other-modules:
   CompTests.Crypto.SHA256
   CompTests.Crypto.SHA224
   CompTests.Crypto.Ed25519Signature
   CompTests.Crypto.VRF
   CompTests.Crypto.Elgamal

Executable perf-test
  default-language: Haskell2010
  main-is: Perf.hs
  hs-source-dirs: haskell-tests
  build-depends: base >= 4.7
               , comp-crypto
               , bytestring >= 0.10
               , criterion >= 1.5.4
  other-modules:
    PerformanceTests.Ed25519Perf
    PerformanceTests.SHA256Perf

dependency: globalstate-mockup (globalstate-types)

stack.yaml

resolver: lts-13.21

packages:
- .

extra-deps:
   - git: [email protected]:Comp/crypto.git
     commit: 6c3adc0ea4b748beb48299c4af89d75004df34da

package.yaml

name:                globalstate-types
version:             0.1.0.0
license:             BSD3
author:              "Author name here"
maintainer:          "[email protected]"
copyright:           "2018 Author name here"

extra-source-files:
- README.md
- CHANGELOG.md

# Metadata used when publishing your package
# synopsis:            Short description of your package
# category:            Web

# To avoid duplicated efforts in documentation and dealing with the
# complications of embedding Haddock markup inside cabal files, it is
# common to point users to the README.md file.
description:         See README

dependencies:
- base >= 4.7 && < 5
- bytestring >= 0.10
- unordered-containers >= 0.2
- containers >= 0.6
- hashable >= 1.2
- mtl >= 2.2
- transformers >= 0.5
- cereal >= 0.5
- microlens-platform >=0.3
- comp-crypto
- aeson >= 1.4.2
- ghc-prim >= 0.5.3

library:
  source-dirs: src
  ghc-options:
    - -Wall
    - -Wcompat
    - -Werror=missing-fields
    - -Werror=missing-methods
    - -Wredundant-constraints
    - -fno-ignore-asserts

executables:
  Perf-test:
    main:            Perf.hs
    source-dirs:     perf
    ghc-options:
    - -threaded
    - -with-rtsopts=-N
    - -Wall
    - -Wcompat

    dependencies:
    - globalstate-types
    - criterion >= 1.5.4


tests:
  types-test:
    main:                Spec.hs
    source-dirs:         test
    ghc-options:
    - -threaded
    - -with-rtsopts=-N
    - -Wall
    dependencies:
    - globalstate-types
    - comp-crypto
    - hspec >= 2.6
    - QuickCheck >= 2.12
    - hspec-expectations >= 0.8
    - containers
    - base58string == 0.10.*
    - random

parent project: lang

stack.yaml

resolver: lts-13.20
flags:
  lang:
    dev: true
packages:
- '.'
extra-deps:
- language-glsl-0.3.0
- monadplus-1.3
- zip-archive-0.3.3@sha256:53f871653059f87285f434319598f380d986cd7fd9219de555dcafc496121a7c
- git: [email protected]:Comp/lang/core.git
  commit: d230c35397ca79e3a9f0822c263df113a6028a89
- git: [email protected]:Comp/joy/globalstate-mockup.git
  commit: f8d94fb568c0ab7c22efcbedff8e4aa6378adbc5
  subdirs:
  - globalstate-types
- git: [email protected]:Comp/crypto.git
  commit: 6c3adc0ea4b748beb48299c4af89d75004df34da
@dbaynard
Copy link
Contributor

dbaynard commented Jul 18, 2019

Hi @drathier, thanks for the report. Would you try building without --fast, and post the --verbose log (it would also be helpful to see the verbose log for --fast), please?

It is possible that a file has been corrupted at some point, in which case a stack clean or a stack purge would remove the offending file.

(Edit: accidentally hit 'comment' before I was done…)

@drathier
Copy link
Author

Forgot to add that I've nuked both .stack-work and ~/.stack without any improvement. I'll try building verbosely with/without --fast and report back.

@dbaynard
Copy link
Contributor

I've seen issues before where the external libraries of dependencies are installed in an unexpected place. I can't find the issue right now, though.

If you can build the dependencies themselves, but not the package using the dependencies, you're probably hitting the same issue (which was resolved by changing the dependency, here the comp-crypto package).

@drathier
Copy link
Author

drathier commented Jul 22, 2019

That sounds like it's the same issue. I can build the dependencies by themselves but not as deps. Where would you expect the libraries to be installed?

@dbaynard
Copy link
Contributor

Found it! #4141

Take a look (there'a a solution near the end); it might help. It seemed to require a fix to the dependency.

@ProofOfKeags
Copy link

I just ran into this as well. We have a rust dependency coming in over the C FFI, and on Stack 1.9 it builds just fine but on Stack 2 it claims it can't find the .so/.DLL for the rust dep. I can't figure out anything besides that, but it very clearly builds correctly on Stack 1.9, and breaks on Stack 2 for reasons that are not obvious.

My first guess is that whatever is doing the build of the underlying dependency is not then installing it to a place that can be found by stack 2. When it later tries to link against the dependency it then proceeds to fail.

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

No branches or pull requests

3 participants