Cabal does not try `clang` as a name for gcc
- Dominant language
- Haskell
- Stars
- 1.7k
- Forks
- 750
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 28
Description
**Describe the bug**
We had a bug at work where our project would not build in a pure nix-shell on macOS, since the Nix stdenv uses clang on macOS. However, it worked properly in an impure nix shell. We observed that macOS has /usr/bin/gcc which is a symlink to clang, leading to this working properly inside the impure shell.
We solved it by generating a cabal project file with Nix that looked like this:
```
program-locations
gcc-location: ${stdenv.cc}/bin/cc
```
**To Reproduce**
Build a package with `nix-shell --pure` on macOS, with a `c-sources` option in the cabal file:
```
c-sources:
test.c
```
Please use version-prefixed commands (e.g. `v2-build` or `v1-build`) to avoid ambiguity.
**Expected behavior**
The package should build as Nix discovers the clang in the environment.
**System information**
- Operating system - macOS 12.4
- `cabal`, `ghc` versions - cabal 3.8.1.0, ghc 9.2.4
**Additional context**
I am surprised this happened at all; generally Nix hardcodes the compiler path. I did not manage to cause it on linux.
Contributor guide
Assessment
This issue has not been assessed yet.