haskell / cabal

Official upstream development repository for Cabal and cabal-install
https://haskell.org/cabal
Other
1.62k stars 697 forks source link

Building a DLL causes cabal to build every module twice. #6993

Open TDecking opened 4 years ago

TDecking commented 4 years ago

Consider the following cabal file:

cabal-version:       >=1.10
name:                bug
version:             0.1.0.0
license-file:        LICENSE
build-type:          Simple
extra-source-files:  CHANGELOG.md

foreign-library bug
  type:                native-shared
  options:             standalone
  other-modules:       Lib
  build-depends:       base
  c-sources:           wrapper.c
  default-language:    Haskell2010

This file is similar to the ones provided by the user guides. By default, cabal first builds the modules, builds the same modules again, and then links. Inserting ghc-options: -fPIC into the file mitigates this issue.

Tested with cabal 3.2.0.0 and ghc 8.10.1.

srid commented 1 year ago

Inserting ghc-options: -fPIC into the file mitigates this issue.

@TDecking What do you mean by "mitigate"? Did that stop compiling twice, or?

TDecking commented 1 year ago

@srid Yes.

philderbeast commented 10 months ago

@alt-romes you're looking at build passes aren't you?