Hey there! I’m just getting into Haskell and I’m trying to get the compiler working, but I’m having an issue.
I’m on Linux and I have my gmp
library installed to ~/.local/lib
because I’m not root on my machine and can’t install system packages.
I can compile a hello world program if I run ghc -L$HOME/.local/lib hello.hs
, but I want to add -L$HOME/.local/lib
as a default linker argument so that I don’t have to pass it in every time I compile a haskell program.
Are there any environment variables or configurations I can set to add global linker flags?
It looks like haskell packages have a way to add linker flags, so maybe I can make a dummy package that adds to the linker search path, and then just install it?
1 Like
You can edit the C compiler link flags
line in $(ghc --print-libdir)/settings
and add the -L
flag there. (or set the CONF_GCC_LINKER_OPTS_STAGE2
environment envariable to your linker flag when installing ghc)
3 Likes
That worked great, thanks! 
I didn’t see anything about a settings dir in the GHC User Guide. Did I just miss it, or should that be added. I could maybe open a PR.
1 Like
Knowledge about the settings
file is better suited in the GHC commentary IMO, given it’s purely an internal implementation detail. Ironically I failed to find such a wiki page, it makes sense to create a page for it though, in the future it may be gradually populated by explanations of individual settings
fields.
2 Likes
There you go, created a new page for it:
I mentioned the ld flags
setting, and a note that I didn’t know when that was used instead of the c compiler link flags
. I’m not sure what the best tense to use when indicating something I’m unsure of in the docs.
It might be better to avoid the I
pronoun for a doc that could have multiple authors.
2 Likes