Skip to content

cabal: link only executables with -optl-static under fully_static_link - #2498

Open
TrapsterDK wants to merge 1 commit into
tweag:masterfrom
TrapsterDK:cabal-static-exe
Open

TrapsterDK wants to merge 1 commit into
tweag:masterfrom
TrapsterDK:cabal-static-exe

Conversation

@TrapsterDK

Copy link
Copy Markdown
Contributor

Fixes #2495

With fully_static_link, haskell/cabal.bzl passed --ghc-option=-optl-static to every Cabal component, so a haskell_cabal_library linked its shared object with -static. The flag is now only passed when is_library is false, which matches haskell_binary, where -optl-static is only used to link executables.

Tests: new analysis tests in rules_haskell_tests/tests/haskell_cabal_fully_static_link check the cabal_wrapper arguments of a library and an executable built with the feature, using a new cabal_wrapper_extra_args_test helper in tests/analysis_tests.bzl. bazel test --config=linux-bindist //tests/haskell_cabal_fully_static_link/... passes (2 tests); without the fix library_not_static fails. buildifier_test passes.

Assisted by Claude.

The fully_static_link feature passed --ghc-option=-optl-static to every
Cabal component, libraries included, so a library's shared object was
linked with -static. haskell_binary only passes -optl-static when linking
an executable. haskell_cabal_library now does the same: the flag is only
passed when is_library is false.

Add analysis tests that check the cabal_wrapper arguments of a library
and an executable built with the feature.

Assisted-by: Claude

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

haskell_cabal_library links shared libraries with -optl-static under fully_static_link

1 participant