Skip to content

Windows, foreign-library, Cabal-3.10.3.0 regression in linker #9982

@mpilgrem

Description

@mpilgrem

I have a simple package foo with Cabal file:

cabal-version:  2.2
name:           foo
version:        0.1.0.0
foreign-library foo
  type:             native-shared
  other-modules:    Lib
  hs-source-dirs:   src
  build-depends:    base >=4.7 && <5
  default-language: Haskell2010
  if os(windows)
    options:        standalone

With GHC 9.6.4/Cabal-3.10.1.0 it builds fine:

❯ stack --snapshot ghc-9.6.4 build
foo> configure
foo> Configuring foo-0.1.0.0...
foo> build with ghc-9.6.4
foo> Preprocessing foreign library 'foo' for foo-0.1.0.0..
foo> Building foreign library 'foo' for foo-0.1.0.0..
foo> [1 of 1] Compiling Lib
foo> [1 of 2] Compiling Lib [Flags changed]
foo> [2 of 2] Linking .stack-work\dist\ab060f89\build\foo\foo.dll

With GHC 9.6.5/Cabal-3.10.3.0 the build fails in the linker:

❯ stack --snapshot ghc-9.6.5 build
foo> configure
foo> Configuring foo-0.1.0.0...
foo> build with ghc-9.6.5
foo> Preprocessing foreign library 'foo' for foo-0.1.0.0..
foo> Building foreign library 'foo' for foo-0.1.0.0..
foo> [1 of 1] Compiling Lib
foo> [1 of 2] Compiling Lib [Flags changed]
foo> [2 of 2] Linking .stack-work\dist\eebe39f7\build\foo\foo.dll
foo> lld: error: unknown argument: -rpath
foo> lld: error: unknown argument: -rpath
foo> clang: error: linker command failed with exit code 1 (use -v to see invocation)
foo> ghc-9.6.5.exe: `clang.exe' failed in phase `Linker'. (Exit code: 1)

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package foo-0.1.0.0 (scroll up to its section to see the error) using:
       D:\sr\setup-exe-cache\x86_64-windows\Cabal-simple_7psHxtdj_3.10.3.0_ghc-9.6.5.exe --verbose=1 --builddir=.stack-work\dist\eebe39f7 build --ghc-options " -fdiagnostics-color=always"
       Process exited with code: ExitFailure 1

Is this a regression introduced in Cabal-3.10.3.0? I wondered if it was related to:

EDIT: I am pretty sure that this is a regession between Cabal-3.10.1.0 and Cabal-3.10.3.0 because my example builds if I force Stack to build using GHC 9.6.5 but with Cabal-3.10.1.0, using:

cabal-version:  2.2
name:           foo
version:        0.1.0.0
build-type:     Custom

custom-setup
  setup-depends:   base >= 4.7 && < 5
                 , Cabal ==3.10.1.0
                 , Cabal-syntax ==3.10.1.0

foreign-library foo
  type:             native-shared
  other-modules:    Lib
  hs-source-dirs:   src
  build-depends:    base >=4.7 && <5
  default-language: Haskell2010
  if os(windows)
    options:        standalone

EDIT2: Using the same method, it appears to me to be a regression introduced between Cabal-3.10.2.1 and Cabal-3.10.3.0.

(EDIT 3: The good news is this is not a problem for GHC 9.10.0.20240426/Cabal-3.12.0.0.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions