Skip to content
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

ghc-7.8.4 -prof flag is broken. #386

Closed
s9gf4ult opened this issue Feb 4, 2015 · 11 comments
Closed

ghc-7.8.4 -prof flag is broken. #386

s9gf4ult opened this issue Feb 4, 2015 · 11 comments

Comments

@s9gf4ult
Copy link
Contributor

s9gf4ult commented Feb 4, 2015

Hello. There is problem with ghc-7.8.4. I can not build packages in my sandbox with -prof flag.

% cabal sandbox init  
Writing a default package environment file to
/home/razor/tmp/opalplay/cabal.sandbox.config
Creating a new sandbox at /home/razor/tmp/opalplay/.cabal-sandbox
% cabal install --only-dependencies --force-reinstalls --enable-tests --enable-benchmarks --reorder-goals --ghc-options="-prof -rtsopts"
Resolving dependencies...
Notice: installing into a sandbox located at
/home/razor/tmp/opalplay/.cabal-sandbox
Configuring blaze-textual-0.2.0.9...
Configuring contravariant-1.2.0.1...
Building contravariant-1.2.0.1...
Building blaze-textual-0.2.0.9...
Failed to install contravariant-1.2.0.1
Build log ( /home/razor/tmp/opalplay/.cabal-sandbox/logs/contravariant-1.2.0.1.log ):
Configuring contravariant-1.2.0.1...
Building contravariant-1.2.0.1...
Preprocessing library contravariant-1.2.0.1...
[1 of 3] Compiling Data.Functor.Contravariant ( Data/Functor/Contravariant.hs, dist/dist-sandbox-b1578701/build/Data/Functor/Contravariant.o )

Top level:
    Failed to load interface for ‘GHC.Integer.Type’
    Perhaps you haven't installed the "p_dyn" libraries for package ‘integer-gmp’?
    Use -v to see a list of the files searched for.
Failed to install blaze-textual-0.2.0.9
Build log ( /home/razor/tmp/opalplay/.cabal-sandbox/logs/blaze-textual-0.2.0.9.log ):
Configuring blaze-textual-0.2.0.9...
Building blaze-textual-0.2.0.9...
Preprocessing library blaze-textual-0.2.0.9...
[1 of 4] Compiling Blaze.Text.Int   ( Blaze/Text/Int.hs, dist/dist-sandbox-b1578701/build/Blaze/Text/Int.o )

And so on.

It is also strange that all packages installed from portage are compiled with profile use flag without errors.

@orlitzky
Copy link
Contributor

orlitzky commented Feb 4, 2015

I don't have a good solution yet, but the reason this happens is because GHC 7.8 uses the system's dynamic linker by default instead of the old static one. So cabal is trying to link GMP dynamically, but we're missing a "p_dyn" (profiling/dynamic) version of GHC.Integer.Type:

$ ls /usr/lib64/ghc-7.8.4/integer-gmp-0.5.1.0/GHC/Integer/
total 80K
drwxr-xr-x 2 root root 4.0K 2015-01-13 03:04 GMP
drwxr-xr-x 2 root root 4.0K 2015-01-13 03:04 Logarithms
-rw-r--r-- 1 root root 1.6K 2015-01-13 03:03 Logarithms.dyn_hi
-rw-r--r-- 1 root root 1.6K 2015-01-13 03:03 Logarithms.hi
-rw-r--r-- 1 root root 1.6K 2015-01-13 03:03 Logarithms.p_hi
-rw-r--r-- 1 root root  18K 2015-01-13 03:03 Type.dyn_hi
-rw-r--r-- 1 root root  18K 2015-01-13 03:03 Type.hi
-rw-r--r-- 1 root root  18K 2015-01-13 03:03 Type.p_hi

A workaround is to pass --disable-shared to cabal, but we may also be able to get integer-gmp to build a copy of Type.p_dyn_hi.

@s9gf4ult
Copy link
Contributor Author

s9gf4ult commented Feb 4, 2015

Looks like --disable-shared is working workaround, thanks.

@trofi
Copy link
Contributor

trofi commented Feb 4, 2015

cabal install --only-dependencies --force-reinstalls --enable-tests --enable-benchmarks --reorder-goals --ghc-options="-prof -rtsopts"

Passing -prof manually as a ghc option is a bit too lowlevel, you are expected to know what you are doing (like tweaking GHC_LIBRARY_WAYS to contain p_dyn for dev-lang/ghc ebuild).

cabal install has --enable-library-profiling (aka -p) and --enable-executable-profiling which should get "something, that works".

@s9gf4ult
Copy link
Contributor Author

s9gf4ult commented Feb 5, 2015

Looks like it's not ok.

14:27 razor@gazoline /home/razor/work/dpwiz/base58-bytestring % cabal install --only-dependencies --force-reinstalls --enable-tests --enable-benchmarks --reorder-goals -p --disable-shared                               
Warning: base58-bytestring.cabal: Unknown fields: extra-source-files (line 22)
Fields allowed in this section:
exposed-modules, reexported-modules, required-signatures,
exposed-signatures, exposed, buildable, build-tools, build-depends,
cpp-options, cc-options, ld-options, pkgconfig-depends, frameworks,
c-sources, js-sources, default-language, other-languages,
default-extensions, other-extensions, extensions, extra-libraries,
extra-ghci-libraries, extra-lib-dirs, includes, install-includes,
include-dirs, hs-source-dirs, other-modules, ghc-prof-options,
ghcjs-prof-options, ghc-shared-options, ghcjs-shared-options,
ghc-options, ghcjs-options, jhc-options, hugs-options,
nhc98-options
Resolving dependencies...
..........................................
Installed distributive-0.4.4
Building math-functions-0.1.5.2...
Failed to install math-functions-0.1.5.2
Build log ( /home/razor/work/dpwiz/base58-bytestring/.cabal-sandbox/logs/math-functions-0.1.5.2.log ):
Configuring math-functions-0.1.5.2...
Building math-functions-0.1.5.2...
Preprocessing library math-functions-0.1.5.2...
[1 of 6] Compiling Numeric.Sum      ( Numeric/Sum.hs, dist/dist-sandbox-101a30f4/build/Numeric/Sum.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package pretty-1.1.1.1 ... linking ... done.
Loading package template-haskell ... linking ... done.
Loading package primitive-0.5.4.0 ... linking ... done.
Loading package vector-0.10.12.2 ... linking ... done.
Loading package vector-th-unbox-0.2.1.2 ... <command line>: can't load .so/.DLL for: libHSvector-th-unbox-0.2.1.2.so (libHSvector-th-unbox-0.2.1.2.so: cannot open shared object file: No such file or directory)
Configuring monad-par-0.3.4.7...
Building monad-par-0.3.4.7...
Configuring tasty-0.10.1...
Installed monad-par-0.3.4.7
......................

@s9gf4ult
Copy link
Contributor Author

s9gf4ult commented Feb 5, 2015

And then

Building bifunctors-4.2...
Failed to install profunctors-4.3.2
Build log ( /home/razor/work/dpwiz/base58-bytestring/.cabal-sandbox/logs/profunctors-4.3.2.log ):
Configuring profunctors-4.3.2...
Building profunctors-4.3.2...
Preprocessing library profunctors-4.3.2...
[ 1 of 14] Compiling Data.Profunctor.Trace ( src/Data/Profunctor/Trace.hs, dist/dist-sandbox-101a30f4/build/Data/Profunctor/Trace.o )
[ 2 of 14] Compiling Data.Profunctor.Unsafe ( src/Data/Profunctor/Unsafe.hs, dist/dist-sandbox-101a30f4/build/Data/Profunctor/Unsafe.o )
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package array-0.5.0.0 ... linking ... done.
Loading package deepseq-1.3.0.2 ... linking ... done.
Loading package containers-0.5.5.1 ... linking ... done.
Loading package bytestring-0.10.4.0 ... linking ... done.
Loading package text-1.2.0.4 ... linking ... done.
Loading package hashable-1.2.3.1 ... linking ... done.
Loading package nats-1 ... linking ... done.
Loading package unordered-containers-0.2.5.1 ... linking ... done.
Loading package semigroups-0.16.0.1 ... linking ... done.
Loading package transformers-0.4.2.0 ... linking ... done.
Loading package transformers-compat-0.3.3.4 ... linking ... done.
Loading package void-0.7 ... linking ... done.
Loading package contravariant-1.2.0.1 ... <command line>: can't load .so/.DLL for: libHScontravariant-1.2.0.1.so (libHScontravariant-1.2.0.1.so: cannot open shared object file: No such file or directory)
Installed bifunctors-4.2

@trofi
Copy link
Contributor

trofi commented Feb 5, 2015

I'd guess it's an effect of --disable-shared. Template haskell uses GHCi ghc api which loads shared libs by default.

I'd suggest dropping --disable-shared unless you absolutely need it for some reason.

@s9gf4ult
Copy link
Contributor Author

s9gf4ult commented Feb 5, 2015

But

A workaround is to pass --disable-shared

--disable-shared is needed to build sandbox libraries with profiling

@trofi
Copy link
Contributor

trofi commented Feb 5, 2015

That's unexpected. Do you have complete example for hackage package?

I've tried profunctors-4.3.2 and it works.
My action sequence:

mkdir /tmp/z
cd /tmp/z/
cabal sandbox init
cabal install profunctors -p --reinstall --force-reinstalls

(--force-reinstalls as i have a ton of packages already installed system packages)

@trofi
Copy link
Contributor

trofi commented Feb 9, 2016

Is it still a problem for you to profile stuff on newer toolchain on ghc-7.10.2 / 7.10.3?

@s9gf4ult
Copy link
Contributor Author

I dont know. To be honest I am using stack already.

@trofi
Copy link
Contributor

trofi commented Feb 10, 2016

Ah, ok. Let's close it as obsolete then.

@trofi trofi closed this as completed Feb 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants