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

executable-dynamic: True should apply to build-type: Custom setup #1720

Open
accursoft opened this issue Mar 10, 2014 · 6 comments
Open

executable-dynamic: True should apply to build-type: Custom setup #1720

accursoft opened this issue Mar 10, 2014 · 6 comments

Comments

@accursoft
Copy link

I have a Haskell installation with only shared libraries, and cabal's config contains:

library-vanilla: False
library-profiling: False
shared: True
executable-dynamic: True

This fails for packages with build-type: Custom, because cabal-install tries to link setup against non-existent static libraries.

@Piezoid
Copy link

Piezoid commented Jun 1, 2014

I use -dynamic in ghc-options as a workaround (with a similar configuration). But yes it need to be fixed.

This workaround is problematic if you build static libraries in a sandbox (for example profiling libraries) , the ghc-options are propagated and can't be cleared.

@int-e
Copy link
Contributor

int-e commented Mar 1, 2015

Perhaps there should be an extra option like ghc-options just for building Setup executables. Note that this is related to cross-compilation as well: once it's possible to specify a host compiler (cf. #1493) it seems natural to have a way of specifying additional flags for it as well.

@int-e
Copy link
Contributor

int-e commented Jul 7, 2015

There is another facet of this issue: If ghc is built without static (aka vanilla) libraries, then even the default Setup executables for the Simple build type fail to build.

@23Skidoo 23Skidoo modified the milestones: Cabal 1.24, Cabal 1.26 Feb 21, 2016
@ezyang ezyang modified the milestone: Cabal 2.0 Sep 6, 2016
@Rufflewind
Copy link
Member

FWIW this does affect Arch Linux now, because the default packages don't come with static libs anymore.

@nponeccop
Copy link

JFYI alex is one of the widely known packages with custom-setup and without too many deps. It fails during configure step:

[foo@arch alex-test]$ cabal install alex
Resolving dependencies...
Notice: installing into a sandbox located at
/home/foo/dev/alex-test/.cabal-sandbox
Configuring alex-3.2.3...
Failed to install alex-3.2.3
Build log ( /home/foo/dev/alex-test/.cabal-sandbox/logs/alex-3.2.3.log ):
cabal: Entering directory '/tmp/cabal-tmp-21549/alex-3.2.3'
cabal: Leaving directory '/tmp/cabal-tmp-21549/alex-3.2.3'
cabal: Error: some packages failed to install:
alex-3.2.3 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:
/usr/bin/ld: cannot find -lHSCabal-1.24.2.0
/usr/bin/ld: cannot find -lHSprocess-1.4.3.0
/usr/bin/ld: cannot find -lHSpretty-1.1.3.3
/usr/bin/ld: cannot find -lHSdirectory-1.3.0.0
/usr/bin/ld: cannot find -lHSunix-2.7.2.1
/usr/bin/ld: cannot find -lHStime-1.6.0.1
/usr/bin/ld: cannot find -lHSfilepath-1.4.1.1
/usr/bin/ld: cannot find -lHSbinary-0.8.3.0
/usr/bin/ld: cannot find -lHScontainers-0.5.7.1
/usr/bin/ld: cannot find -lHSbytestring-0.10.8.1
/usr/bin/ld: cannot find -lHSdeepseq-1.4.2.0
/usr/bin/ld: cannot find -lHSarray-0.5.1.1
/usr/bin/ld: cannot find -lHSbase-4.9.1.0
/usr/bin/ld: cannot find -lHSinteger-gmp-1.0.0.1
/usr/bin/ld: cannot find -lHSghc-prim-0.5.0.0
/usr/bin/ld: cannot find -lHSrts_thr
collect2: error: ld returned 1 exit status
`gcc' failed in phase `Linker'. (Exit code: 1)
)

A more self-contained example fails with a different error, and it should also fail with "normal" GHC if vanilla is disabled:

Setup.hs

import Distribution.Simple
import Acme.Missiles
main = defaultMain

foo.cabal:

name:                foo
version:             0.1.0.0
synopsis: foo
description: bar
homepage:            https://github.com/githubuser/foo#readme
license:             BSD3
license-file:        LICENSE
author:              Author name here
maintainer:          example@example.com
copyright:           2017 Author name here
category:            Web
build-type:          Custom
extra-source-files:  README.md
cabal-version:       >=1.24

custom-setup
  setup-depends: base <5, Cabal <2, acme-missiles <1

executable foo-exe
  hs-source-dirs:      app
  main-is:             Main.hs
  build-depends:       base <5
  default-language:    Haskell2010

The error is:

$ cabal sandbox init
Writing a default package environment file to
/home/foo/dev/alex-test/foo/cabal.sandbox.config
Creating a new sandbox at /home/foo/dev/alex-test/foo/.cabal-sandbox
$ cabal install
Resolving dependencies...
Notice: installing into a sandbox located at
/home/foo/dev/alex-test/foo/.cabal-sandbox
Configuring acme-missiles-0.3...
Building acme-missiles-0.3...
Installed acme-missiles-0.3
Configuring foo-0.1.0.0...
Failed to install foo-0.1.0.0
Build log ( /home/foo/dev/alex-test/foo/.cabal-sandbox/logs/foo-0.1.0.0.log ):
cabal: Entering directory '.'
cabal: Leaving directory '.'
cabal: Error: some packages failed to install:
foo-0.1.0.0 failed during the configure step. The exception was:
user error ('/usr/bin/ghc' exited with an error:

dist/dist-sandbox-aeee24c4/setup/setup.hs:2:1: error:
Failed to load interface for ‘Acme.Missiles’
There are files missing in the ‘acme-missiles-0.3’ package,
try running 'ghc-pkg check'.
Use -v to see a list of the files searched for.
)

@LeifW
Copy link

LeifW commented Apr 18, 2018

Just to expand on @Piezoid's comment, using cabal install --ghc-option=-dynamic foo, or adding ghc-options: -dynamic in my $HOME/.cabal/config works for me as a workaround.

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