haskell / haskell/cabal

ar flags are too rigid

Open
#8,882 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
1.7k
Forks
750
Avg merge
4d 3h
Merged PRs (30d)
28

Description

**Describe the bug**
Currently Cabal hard-codes the flags passed to `ar` on a per-platform basis. This went wrong in [GHC #23188](https://gitlab.haskell.org/ghc/ghc/-/issues/23188), where using `llvm-ar` on OS X lead to the production of an invalid static archive. In this particular case, `Cabal` failed to use the `ar L` flag, resulting in a nested archive.

**To Reproduce**
On a Darwin box:

```
brew install llvm@11
curl https://downloads.haskell.org/ghc/9.6.1/ghc-9.6.1-aarch64-apple-darwin.tar.bz2 | tar -x
cd ghc-9.6.1-aarch64-apple-darwin/
export AR=/opt/homebrew/opt/llvm@11/bin/llvm-ar
export CC=/opt/homebrew/opt/llvm@11/bin/clang
export CXX=/opt/homebrew/opt/llvm@11/bin/clang++
export RANLIB=/opt/homebrew/opt/llvm@11/bin/llvm-ranlib
./configure --prefix=`pwd`/root
make install

git clone https://github.com/haskell/haskell-language-server
cd haskell-language-server
cabal build -w $HOME/ghc-9.6.1-aarch64-apple-darwin/root/bin/ghc
```

**Expected behavior**
Cabal use appropriate flags for the platform's `ar` implementation.

**System information**
- Operating system
- `cabal`, `ghc` versions

**Additional context**
Add any other context about the problem here.

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure on Darwin with the llvm-ar, clang, and GHC setup shown in the issue, then trace Cabal's platform-specific handling of ar flags. Done means Cabal selects flags appropriate to the ar implementation and the demonstrated haskell-language-server build succeeds without producing an invalid or nested archive.

Written by the indexing model from the issue text.

Assessment

Tech stack
haskell, macos
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.