Skip to content

Cabal 2's 'foreign-library' doesn't work with HEAD #3364

@bjornbm

Description

@bjornbm

General summary/comments (optional)

Stack HEAD (aa5003a) does not produce a "foreign library" as specified by the foreign-librarystanza in the .cabal file. This stanza is a new feature of Cabal-2.0.0.*.I have tested this only on Windows.

Steps to reproduce

  1. Use HEAD of stack (or commit aa5003a).
  2. stack build this example repository: https://github.com/bjornbm/cabal-flib-invalid-cache-repro.git

This has been tested only on i386-windows.

Expected

I expected a DLL named myflib.dll to be produced.

For comparison this the result of building with cabal-install 2.0.0.0:

$  ~/AppData/Roaming/cabal/bin/cabal.exe --version
cabal-install version 2.0.0.0
compiled using version 2.0.0.2 of the Cabal library
$ PATH=~/AppData/Local/Programs/stack/i386-windows/ghc-8.2.1/bin:$PATH ~/AppData/Roaming/cabal/bin/cabal.exe build
Resolving dependencies...
Configuring testpkg-0.1.0.0...
Preprocessing library for testpkg-0.1.0.0..
Building library for testpkg-0.1.0.0..
[1 of 1] Compiling Lib              ( lib\Lib.hs, dist\build\Lib.o )
Preprocessing foreign library 'myflib' for testpkg-0.1.0.0..
Building foreign library 'myflib' for testpkg-0.1.0.0..
[1 of 1] Compiling FLib             ( flib\FLib.hs, dist\build\myflib\myflib-tmp\FLib.o )
[1 of 1] Compiling FLib             ( flib\FLib.hs, dist\build\myflib\myflib-tmp\FLib.o ) [flags changed]
Linking dist\build\myflib\myflib.dll ...

Actual

Stack complained:

$ stack build
testpkg-0.1.0.0: configure (lib)
Configuring testpkg-0.1.0.0...
testpkg-0.1.0.0: build (lib)
Preprocessing library for testpkg-0.1.0.0..
Building library for testpkg-0.1.0.0..
[1 of 1] Compiling Lib              ( lib\Lib.hs, .stack-work\dist\9cd999cb\build\Lib.o )
testpkg-0.1.0.0: copy/register
Installing library in C:\Users\bjorn\repos\cabal-flib-invalid-cache-repro\.stack-work\install\03648e34\lib\i386-windows-ghc-8.2.1\testpkg-0.1.0.0-8BkLVLBjses1NkNpiyJL1z
Installing foreign library myflib in C:\Users\bjorn\repos\cabal-flib-invalid-cache-repro\.stack-work\install\03648e34\lib
.stack-work\dist\9cd999cb\build\myflib\myflib.dll: copyFile: does not exist (No such file or directory)
'cabal copy' failed.  Error message:

--  While building package testpkg-0.1.0.0 using:
      C:\sr\setup-exe-cache\i386-windows\Cabal-simple_Z6RU0evB_2.0.0.2_ghc-8.2.1.exe --builddir=.stack-work\dist\9cd999cb copy
    Process exited with code: ExitFailure 1

One possible cause of this issue is:
* No module named "Main". The 'main-is' source file should usually have a header indicating that it's a 'Main' module.

No .stack-work\dist\9cd999cb\build\myflib directory was created, and of course no myflib.dll was created in that directory.

The log of stack build --verbose --cabal-verbose can be found in this Gist.

Stack version

$ stack --version
Version 1.5.1, Git revision aa5003a153504f54051e42a844a0c1c3d7f82163 (5099 commits) i386 hpack-0.17.1

Built from commit aa5003a.

Method of installation

Built from clean checkout of HEAD from github.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions