Skip to content

Alert the user that on Windows, with configuration executable-dynamic: True executables (including build-tools) cannot be built #9807

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

Closed
andreasabel opened this issue Mar 14, 2024 · 6 comments · Fixed by #10217
Labels
cabal-install: cmd/build newcomer platform: windows re: build-tool Concerning `build-tools` and `build-tool-depends` re: dynamic-linking Concerning dynamic linking (e.g. flags "shared", "*-dynamic") re: user experience User experience (UX) issue

Comments

@andreasabel
Copy link
Member

This issue is singled out from:

Adding executable-dynamic: True to the cabal configuration on Windows will fail executables to build.
This include situations where you just want to build a library, but it has build-tool-depends: alex or similar causing the linking of build-tool alex to fail.

Reproduced on a fresh Haskell installation: https://github.com/agda/agda/actions/runs/8213506540/job/22465003537#step:10:233

Building executable 'alex' for alex-3.5.1.0..
[ 1 of 19] Compiling DFS              ( src\DFS.hs, dist\build\alex\alex-tmp\DFS.dyn_o )

src\DFS.hs:24:8: error: [GHC-88719]
Error:     Could not load module ‘Prelude’.
    Perhaps you haven't installed the "dyn" libraries for package ‘base-4.19.1.0’?
@andreasabel andreasabel added platform: windows cabal-install: cmd/build re: dynamic-linking Concerning dynamic linking (e.g. flags "shared", "*-dynamic") re: build-tool Concerning `build-tools` and `build-tool-depends` labels Mar 14, 2024
@jasagredo
Copy link
Collaborator

Dynamic linking in Windows is simply not supported by GHC. This is not a Cabal bug unless you wanted to imply that executable-dynamic: True should crash before even attempting compilation on Windows.

I'm closing this issue, please re-open of you disagree

@jasagredo jasagredo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
@andreasabel
Copy link
Member Author

I do disagree.

This is not a Cabal bug unless you wanted to imply that executable-dynamic: True should crash before even attempting compilation on Windows.

I do think it should exit with an error explaining the problem.

Aren't we Haskell programmers? Aren't we proposing strong typing?
GHC does not compile ill-typed programs. Cabal should not process ill-formed configurations either.

@andreasabel andreasabel reopened this Jul 19, 2024
@jasagredo
Copy link
Collaborator

Perfectly understandable!

Could you change the title or description so that just with a glance it is clear that is what you would like to see implemented?

I think the idea is very useful and might be worth adding a specific mechanism for it so that other configurations that are known unusable are also included (such as using rpath on Windows which I think also fails)

@andreasabel andreasabel changed the title On Windows, with configuration executable-dynamic: True executables (including build-tools) cannot be built Alert the user that on Windows, with configuration executable-dynamic: True executables (including build-tools) cannot be built Jul 19, 2024
@jasagredo
Copy link
Collaborator

Note this already exists with relocatable builds:

➜ cabal build --enable-relocatable
Resolving dependencies...
Build profile: -w ghc-9.8.2 -O1
In order, the following will be built (use -v for more details):
 - aa-0.1.0.0 (lib) (configuration changed)
Configuring library for aa-0.1.0.0...
Error: [Cabal-3339]
Operating system: windows, does not support relocatable builds

Error: [Cabal-7125]
Failed to build aa-0.1.0.0. The failure occurred during the configure step.

It should just be a matter of doing a very similar check for shared executables if we are on Windows.

@ulysses4ever
Copy link
Collaborator

Sounds like a low-hanging fruit then. I'll put the "newcomer" label on it.

@jasagredo
Copy link
Collaborator

Ah actually I did it while waiting for some tests, it was barely a 10 lines change in total

@mergify mergify bot closed this as completed in #10217 Jul 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cabal-install: cmd/build newcomer platform: windows re: build-tool Concerning `build-tools` and `build-tool-depends` re: dynamic-linking Concerning dynamic linking (e.g. flags "shared", "*-dynamic") re: user experience User experience (UX) issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants