commercialhaskell / commercialhaskell/stack

Target-specific ghc-options [feature request]

Open
#2,166 1 comment 0 reactions 0 assignees View on GitHub
type: enhancement
Dominant language
Haskell
Stars
4.1k
Forks
850
Avg merge
10h 37m
Merged PRs (30d)
4

Description

I have a lot of packages in my project. There are many libraries and executables. I want to add some GHC options to executables, for example, `-static -optl-static -optl-pthread`. I don't want to add it to every single executable, because it isn't maintainable, it must be a single place where developer can edit this options. But when I write `stack build --ghc-options=...` in my build script, libraries break:

```
Preprocessing library test-0.1.0.0...
/usr/bin/ld: /usr/lib/ghc/base_HQfYBxpPvuw8OunzQu6JGM/libHSbase-4.8.2.0-HQfYBxpPvuw8OunzQu6JGM.a(FD__16.o): relocation R_X86_64_32S against `stg_bh_upd_frame_info' can not be used when making a shared object; recompile with -fPIC
/usr/lib/ghc/base_HQfYBxpPvuw8OunzQu6JGM/libHSbase-4.8.2.0-HQfYBxpPvuw8OunzQu6JGM.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
```

```
$ stack build --ghc-options='-static -optl-static -optl-pthread' test:exe:myexe
test-0.1.0.0: build
Preprocessing library test-0.1.0.0...
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/5/crtbeginT.o: relocation R_X86_64_32 against `__TMC_END__' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-linux-gnu/5/crtbeginT.o: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
```

**Feature request**

It would be good to add GHC options to executables only – specific executable targets (like `mypkg:exe:myexe`) or all executables at once (like `--target-ghc-options=*:exe=...`).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.