Windows, foreign-library, Cabal-3.10.3.0 regression in linker
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
I have a simple package `foo` with Cabal file:
~~~yaml
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:
~~~text
❯ 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:
~~~text
❯ 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:~~
* ~~https://github.com/haskell/cabal/issues/9589~~ (EDIT: I now think that's unrelated)
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:
~~~yaml
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.)
Contributor guide
Research direction
Reproduce the minimal `foo` package with its `foreign-library` and Windows `options: standalone` configuration, comparing GHC 9.6.4/Cabal-3.10.1.0 with GHC 9.6.5/Cabal-3.10.3.0. Trace the foreign-library linker argument generation and verify that the failing build no longer passes unsupported `-rpath` arguments to Windows `lld`; confirm behavior against Cabal-3.10.2.1 and Cabal-3.12.0.0.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- haskell
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100