Can't build with --enable-executable-static missing crt0.o
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
I was trying to build a fully static executable to test a few hypothesis, however, I just ran into this bug. Weirdly, I couldn't reproduce it in an actual project. After building with `cabal build --enable-executable-static`:
```
(tmp.jzlXN3vozO) ⚑ cabal build --enable-executable-static
Warning: this is a debug build of cabal-install with assertions enabled.
Warning: Parsing the index cache failed (Data.Binary.Get.runGet at position
16: Non-matching structured hashes: f46da61e7afa58a5e8fd1d2b6fb79899;
expected: d81bdd513f41b5d7ee4cd28455adadbe). Trying to regenerate the index
cache...
Resolving dependencies...
Build profile: -w ghc-9.8.1 -O1
In order, the following will be built (use -v for more details):
- tmp-jzlXN3vozO-0.1.0.0 (exe:tmp-jzlXN3vozO) (first run)
Warning: this is a debug build of cabal-install with assertions enabled.
Configuring executable 'tmp-jzlXN3vozO' for tmp-jzlXN3vozO-0.1.0.0...
Warning: this is a debug build of cabal-install with assertions enabled.
Preprocessing executable 'tmp-jzlXN3vozO' for tmp-jzlXN3vozO-0.1.0.0...
Building executable 'tmp-jzlXN3vozO' for tmp-jzlXN3vozO-0.1.0.0...
[1 of 1] Compiling Main ( app/Main.hs, /private/var/folders/tv/35hlch6s3y15hfvndc71l6d40000gn/T/tmp.jzlXN3vozO/dist-newstyle/build/aarch64-osx/ghc-9.8.1/tmp-jzlXN3vozO-0.1.0.0/x/tmp-jzlXN3vozO/build/tmp-jzlXN3vozO/tmp-jzlXN3vozO-tmp/Main.o )
[2 of 2] Linking /private/var/folders/tv/35hlch6s3y15hfvndc71l6d40000gn/T/tmp.jzlXN3vozO/dist-newstyle/build/aarch64-osx/ghc-9.8.1/tmp-jzlXN3vozO-0.1.0.0/x/tmp-jzlXN3vozO/build/tmp-jzlXN3vozO/tmp-jzlXN3vozO
ld: library not found for -lcrt0.o
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-9.8.1: `gcc' failed in phase `Linker'. (Exit code: 1)
Error: [Cabal-7125]
Failed to build exe:tmp-jzlXN3vozO from tmp-jzlXN3vozO-0.1.0.0.
```
**To Reproduce**
Steps to reproduce the behavior:
```
cd $(mktemp -d)
cabal init --exe --simple
cabal build --enable-executable-static
```
**Expected behavior**
The executable should compile and be fully static (no dynamic libraries).
**System information**
- Operating system: macOS
- `cabal`: HEAD and 3.10, `ghc`: 9.8
**Additional context**
Add any other context about the problem here.
Contributor guide
Assessment
This issue has not been assessed yet.