Skip to content

env file created by "cabal install --lib ..." (Cabal 3.8.1 ) breaks profiling with ghc 9.6.1 on my Mac #8948

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
GeorgeCo opened this issue May 15, 2023 · 3 comments
Labels

Comments

@GeorgeCo
Copy link

Describe the bug
env file created by "cabal install --lib ..." (Cabal 3.8.1 ) breaks profiling with ghc 9.6.1 on my Mac

To Reproduce
Steps to reproduce the behavior:

On a Mac running ghc 9.6.1 and cabal 3.8.1 where packages have been installed with "cabal install --lib ..." do

ghc -static -prof -fprof-auto hello.hs
Loaded package environment from /Users/gcolpitts/.ghc/x86_64-darwin-9.6.1/environments/default
[1 of 2] Compiling Main             ( hello.hs, hello.o ) [Missing object file]
[2 of 2] Linking hello [Objects changed]
ld: warning: directory not found for option '-L/opt/local/lib/'
ld: library not found for -lHStxmth-0.12.7.1-f954854b_p
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ghc-9.6.1: `gcc' failed in phase `Linker'. (Exit code: 1)

The file hello.hs has one line

main = putStrLn "hello"

The file compiles without error if I add "-package-env=-"

ghc -static -package-env=- -prof -fprof-auto hello.hs
[1 of 2] Compiling Main             ( hello.hs, hello.o ) [Missing object file]
[2 of 2] Linking hello [Objects changed]

Expected behavior

I expect it to compile without error if I omit "-package-env=-"

System information
MacOS Ventura 13.3.1
cabal --version
cabal-install version 3.8.1.0
compiled using version 3.8.1.0 of the Cabal library
bash-3.2$ ghc --version
The Glorious Glasgow Haskell Compilation System, version 9.6.1

@gbaz
Copy link
Collaborator

gbaz commented May 15, 2023

So it appears that with a package environment, ghc tries to link against profiling libs of all packages in the environment, regardless of if they are used by the package being compiled. This seems like a ghc issue and not a cabal issue per-se? I.e. your reproducer only requires ghc and an environment file (which may also be created outside of cabal) that happens to have a lib without profiling involved, correct?

@ulysses4ever
Copy link
Collaborator

On a general note, I don't believe cabal install --lib is compatible with profiling as per #7832

@GeorgeCo
Copy link
Author

GeorgeCo commented Dec 3, 2023

@ulysses4ever Thanks but as far as I can tell #7832 is a bug since it is not closed. It is definitely a bug in my opinion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants