Opened 4 months ago

Last modified 2 months ago

#15837 new bug

Hadrian should build dynamically linked ghc binary

Reported by: davide Owned by: davide
Priority: normal Milestone:
Component: Build System (Hadrian) Version: 8.6.1
Keywords: Cc: alpmestan, Tritlo, snowleopard
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s): Phab:D5385 Phab:D5327 Phab:D5423
Wiki Page:

Description (last modified by davide)

The ghc binary is dynamically linked via make in various flavors (e.g. quick). Hadrian builds a static linked binary in these cases (this is a bug). Various change are needed to fix this:

  1. Add new .cabal file field extra-dynamic-library-flavours (see this PR).
  2. Use .cabal extra-dynamic-library-flavours for the RTS (see this comment, depends on 1.)
  3. Hadrian: fix management of nontrivial dynamic flavours of libHSrts (see this PR).
  4. Hadrian should build ghc with the -fPIC -dynamic options (see this comment, depends on 3.).
  5. Use the correct relative path to the dynamically linked libraries (see Phab:D5281, depends on 3. and 4.).
  6. Build ghc-iserv-dyn, as it is will be required required by many tests (Phab:D5327)
  7. Hadrian should only use "-shared -dynload deploy" when linking shared libraries (definitely not when linking executables). This problem causes ghc-iserv-dyn to segfault because it is built as a shared library instead of as an executable.

Change History (21)

comment:1 Changed 4 months ago by davide

Owner: set to davide

comment:2 Changed 4 months ago by davide

Cc: alpmestan added

comment:3 Changed 4 months ago by davide

Description: modified (diff)

comment:4 Changed 3 months ago by davide

Description: modified (diff)

comment:5 Changed 3 months ago by Tritlo

Cc: Tritlo added

comment:6 Changed 3 months ago by snowleopard

Cc: snowleopard added

comment:7 Changed 3 months ago by alpmestan

Differential Rev(s): Phab:D5385

The Cabal PR got merged, and I just pushed D5385 which updates the Cabal submodule to point to my commit, makes use of extra-dynamic-library-flavours in rts.cabal.in when the dynamic flag is passed, and arranges for that flag to be passed by Hadrian whenever appropriate.

Once this lands, we will be done with 1., 2. and 3. from the original comment.

comment:8 Changed 3 months ago by davide

Description: modified (diff)
Differential Rev(s): Phab:D5385Phab:D5385 Phab:D5327

Update: With changes 1 to 7 I'm able to build a dynamically linked ghc and this fixes a significant number of tests! The end is in sight! The current status is:

  • (1, 2, 3) Are done and merged (Thank you Alp!).
  • (6) Phab:D5327 done and merged!
  • (4, 7) Should be fixed in a small patch that I am currently preparing.
  • (5) Phab:D5281 after 4 and 7 are fixed, this needs some updating, but is on the right track.
Last edited 3 months ago by davide (previous) (diff)

comment:9 Changed 3 months ago by davide

I've changed the plan. Now all remaining work (points 4, 5, and 7) are all in Phab:D5281.

Last edited 3 months ago by davide (previous) (diff)

comment:10 Changed 3 months ago by Alp Mestanogullari <alpmestan@…>

In fb99716/ghc:

Hadrian: bump Cabal submodule, install extra dynamic flavours of RTS

Previously, Hadrian was building all the appropriate dynamic ways for
libHSrts
but they were not picked up and installed in the package database when
we register the rts library. Since we use Cabal for registering
packages and
the .cabal files of packages as sources of truth for configuring and
installing,
we ended up patching Cabal to add a new field,
'extra-dynamic-library-flavours',
to specify those extra flavours to install in .cabal files:

    https://github.com/haskell/cabal/pull/5606

We now make use of this in rts.cabal.in to expose dynamic flavours
behind a
Cabal flag, which Hadrian will use whenever we are building a GHC
flavour that
requires dynamic libraries.

This is all part of a larger plan to build a dynamic stage 2 GHC by
default,
like with make, which in turn will fix a lot of test failures. See

Test Plan:
hadrian/build.sh _build/stage1/lib/package.conf.d/rts-1.0.conf
_build/stage1/lib/x86_64-.../ should contain many libHSrts-*.so

Reviewers: snowleopard, DavidEichmann, bgamari, erikd, simonmar

Reviewed By: snowleopard, DavidEichmann

Subscribers: rwbarton, carter

GHC Trac Issues: #15837

Differential Revision: https://phabricator.haskell.org/D5385

comment:11 Changed 3 months ago by Alp Mestanogullari <alpmestan@…>

In 79d5427e/ghc:

Hadrian: support dynamically linking ghc

* (#15837 point 5) Use the -rpath gcc option and using the $ORIGIN
variable which the dynamic linker sets to the location of the ghc
binary.
* (#15837 point 4) "-fPIC -dynamic" options are used when building ghc
when either ghc or the rts have a dynamic way.
* (#15837 point 7) "-shared -dynload deploy" options are only used when
linking a library (no longer when linking a program).

Reviewers: bgamari, alpmestan

Reviewed By: alpmestan

Subscribers: adamse, rwbarton, carter

Differential Revision: https://phabricator.haskell.org/D5281

comment:12 Changed 3 months ago by alpmestan

Resolution: fixed
Status: newclosed

Both of our patches landed on master.

comment:13 Changed 3 months ago by adamse

I was wondering if the dynamic GHC building (in 79d5427e) should respect the Hadrian equivalent of DYNAMIC_GHC_PROGRAMS=NO. I don't think the current code will do that.

Last edited 3 months ago by adamse (previous) (diff)

comment:14 Changed 2 months ago by davide

My commit (79d5427e1f9d) breaks the hadrian build in some cases. When building the default flavour, the ghc binary is linked with -lffi. When there is no system wide libffi .so installed, this will fail, even though there should be a locally built libffi. Here is an example of the command line generated by hadrian:

$ _build/stage0/bin/ghc -Wall -hisuf hi -osuf o -hcsuf hc -fPIC -dynamic -hide-all-packages -no-user-package-db '-package-db _build/stage1/lib/package.conf.d' '-package-id array-0.5.2.0' '-package-id base-4.12.0.0' '-package-id bytestring-0.10.9.0' '-package-id containers-0.6.0.1' '-package-id deepseq-1.4.4.0' '-package-id directory-1.3.3.1' '-package-id filepath-1.4.2.1' '-package-id ghc-8.7' '-package-id ghc-boot-8.7' '-package-id ghc-prim-0.5.3' '-package-id ghci-8.7' '-package-id haskeline-0.7.4.3' '-package-id process-1.6.3.0' '-package-id time-1.9.2' '-package-id transformers-0.5.5.0' '-package-id unix-2.7.2.2' -i -i_build/stage1/ghc/build -i_build/stage1/ghc/build/ghc/autogen -ighc/. -Iincludes -I_build/generated -I_build/stage1/ghc/build -I/nix/store/x5ms5m9ga6v7vy3akc58yx279ggfnbnl-ghc-build-environment/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/ghc-8.7/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/process-1.6.3.0/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/unix-2.7.2.2/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/time-1.9.2/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/bytestring-0.10.9.0/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/base-4.12.0.0/include -I/nix/store/x5ms5m9ga6v7vy3akc58yx279ggfnbnl-ghc-build-environment/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/integer-gmp-1.0.2.0/include -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/_build/T-15837_default/stage1/lib/x86_64-linux-ghc-8.7.20181205/rts-1.0/include -I_build/generated -optc-I_build/generated -optP-include -optP_build/stage1/ghc/build/ghc/autogen/cabal_macros.h -optc-fno-stack-protector -optP-DGHCI -odir _build/stage1/ghc/build -hidir _build/stage1/ghc/build -stubdir _build/stage1/ghc/build -dynamic -optl-Wl,-rpath -optl-Wl,$ORIGIN/../lib/x86_64-linux-ghc-8.7.20181205 -no-auto-link-packages -no-hs-main -optl-lgmp -Wnoncanonical-monad-instances -optc-Werror=unused-but-set-variable -optc-Wno-error=inline _build/stage1/ghc/build/c/hschooks.o _build/stage1/ghc/build/Main.o _build/stage1/ghc/build/GHCi/Leak.o _build/stage1/ghc/build/GHCi/UI.o _build/stage1/ghc/build/GHCi/UI/Info.o _build/stage1/ghc/build/GHCi/UI/Monad.o _build/stage1/ghc/build/GHCi/UI/Tags.o -o _build/stage1/bin/ghc -O2 -H32m -Wall -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances -Wnoncanonical-monoid-instances -fno-warn-name-shadowing -threaded -XHaskell2010 -XNoImplicitPrelude -ghcversion-file=/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/_build/generated/ghcversion.h -I_build/stage1/compiler/build -Wcpp-undef

Note that there is no mention of libffi (i.e. no use of -lffi). Ghc sees rts as a dependency, and sees hs-libraries: HSrts-1.0 Cffi in the ghc-pkg database and then adds -lffi to the linking command. Further more, bgamari has suggested that we may not be supposed to link with libffi.

We build libffi via hadrian but don't generate a .so. Instead we copy the same .a file as as both an .a and an .so for all flavours

 | Copy file: _build/stage1/libffi/build/inst/include/ffi.h => _build/stage1/rts/build/ffi.h
 | Copy file: _build/stage1/libffi/build/inst/include/ffitarget.h => _build/stage1/rts/build/ffitarget.h
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_p.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi-ghc8.7.20181126.so
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_thr.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_thr_p.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_debug_p.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_thr_debug_p.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_l.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_thr_l.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_debug.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi_thr_debug.a
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi-ghc8.7.20181126_thr.so
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi-ghc8.7.20181126_debug.so
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi-ghc8.7.20181126_l.so
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi-ghc8.7.20181126_thr_debug.so
 | Copy file (untracked): _build/stage1/libffi/build/inst/lib/libffi.a => _build/stage1/rts/build/libCffi-ghc8.7.20181126_thr_l.so

Though this may work for the .a files, it wont work for the .so. It's an easy fix to also build the .so and copy that instead:

  • modify hadrian/src/Settings/Builders/Configure.hs to use --enable-shared=yes when the way is dynamic.
  • modify hadrian/src/Rules/Libffi.hs to copy .so instead of .a when the way is dynamic.

comment:15 Changed 2 months ago by davide

Owner: davide deleted
Resolution: fixed
Status: closednew

comment:16 Changed 2 months ago by davide

Owner: set to davide

comment:17 Changed 2 months ago by davide

Note that the make build system succeeds and can be used as a reference here. Here is the verbose (-v3) output of the make build command that builds/links the ghc binary:

# Model ghc build (make default)

"inplace/bin/ghc-stage1" -o ghc/stage2/build/tmp/ghc-stage2 -hisuf dyn_hi -osuf  dyn_o -hcsuf dyn_hc -fPIC -dynamic  -H32m -O -Wall      -hide-all-packages -i -ighc/. -ighc/stage2/build -Ighc/stage2/build -ighc/stage2/build/ghc/autogen -Ighc/stage2/build/ghc/autogen    -optP-DGHCI -optP-include -optPghc/stage2/build/ghc/autogen/cabal_macros.h -package-id array-0.5.2.0 -package-id base-4.12.0.0 -package-id bytestring-0.10.9.0 -package-id containers-0.6.0.1 -package-id deepseq-1.4.4.0 -package-id directory-1.3.3.1 -package-id filepath-1.4.2.1 -package-id ghc-8.7 -package-id ghc-boot-8.7 -package-id ghc-prim-0.5.3 -package-id ghci-8.7 -package-id haskeline-0.7.4.3 -package-id process-1.6.3.0 -package-id time-1.9.2 -package-id transformers-0.5.5.0 -package-id unix-2.7.2.2 -Wall -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances -Wnoncanonical-monoid-instances -fno-warn-name-shadowing -threaded -XHaskell2010 -XNoImplicitPrelude  -O2 -haddock -Wcpp-undef -no-hs-main -threaded -no-user-package-db -rtsopts       -Wnoncanonical-monad-instances  -odir ghc/stage2/build -hidir ghc/stage2/build -stubdir ghc/stage2/build     -fPIC -dynamic  -H32m -O -Wall      -hide-all-packages -i -ighc/. -ighc/stage2/build -Ighc/stage2/build -ighc/stage2/build/ghc/autogen -Ighc/stage2/build/ghc/autogen    -optP-DGHCI -optP-include -optPghc/stage2/build/ghc/autogen/cabal_macros.h -package-id array-0.5.2.0 -package-id base-4.12.0.0 -package-id bytestring-0.10.9.0 -package-id containers-0.6.0.1 -package-id deepseq-1.4.4.0 -package-id directory-1.3.3.1 -package-id filepath-1.4.2.1 -package-id ghc-8.7 -package-id ghc-boot-8.7 -package-id ghc-prim-0.5.3 -package-id ghci-8.7 -package-id haskeline-0.7.4.3 -package-id process-1.6.3.0 -package-id time-1.9.2 -package-id transformers-0.5.5.0 -package-id unix-2.7.2.2 -Wall -Wnoncanonical-monad-instances -Wnoncanonical-monadfail-instances -Wnoncanonical-monoid-instances -fno-warn-name-shadowing -threaded -XHaskell2010 -XNoImplicitPrelude  -O2 -haddock -Wcpp-undef -no-hs-main -threaded -no-user-package-db -rtsopts       -Wnoncanonical-monad-instances  -fno-use-rpaths -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../haskeline-0.7.4.3' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../stm-2.5.0.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-8.7' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../terminfo-0.4.1.2' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../process-1.6.3.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../hpc-0.6.0.3' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghci-8.7' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../transformers-0.5.5.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../template-haskell-2.15.0.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../pretty-1.1.3.6' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-heap-8.7' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-boot-8.7' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-boot-th-8.7' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../directory-1.3.3.1' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../unix-2.7.2.2' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../time-1.9.2' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../filepath-1.4.2.1' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../binary-0.8.6.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../containers-0.6.0.1' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../bytestring-0.10.9.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../deepseq-1.4.4.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../array-0.5.2.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../base-4.12.0.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../integer-gmp-1.0.2.0' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../ghc-prim-0.5.3' -optl-Wl,-rpath -optl-Wl,'$ORIGIN/../rts' -optl-Wl,-zorigin ghc/stage2/build/Main.dyn_o ghc/stage2/build/GHCi/Leak.dyn_o ghc/stage2/build/GHCi/UI.dyn_o ghc/stage2/build/GHCi/UI/Info.dyn_o ghc/stage2/build/GHCi/UI/Monad.dyn_o ghc/stage2/build/GHCi/UI/Tags.dyn_o ghc/stage2/build/hschooks.dyn_o

Glasgow Haskell Compiler, Version 8.7.20181205, stage 1 booted by GHC version 8.4.4
Using binary package database: /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/inplace/lib/package.conf.d/package.cache
package flags [-package-id array-0.5.2.0{unit array-0.5.2.0 True ([])},
               -package-id base-4.12.0.0{unit base-4.12.0.0 True ([])},
               -package-id bytestring-0.10.9.0{unit bytestring-0.10.9.0 True ([])},
               -package-id containers-0.6.0.1{unit containers-0.6.0.1 True ([])},
               -package-id deepseq-1.4.4.0{unit deepseq-1.4.4.0 True ([])},
               -package-id directory-1.3.3.1{unit directory-1.3.3.1 True ([])},
               -package-id filepath-1.4.2.1{unit filepath-1.4.2.1 True ([])},
               -package-id ghc-8.7{unit ghc-8.7 True ([])},
               -package-id ghc-boot-8.7{unit ghc-boot-8.7 True ([])},
               -package-id ghc-prim-0.5.3{unit ghc-prim-0.5.3 True ([])},
               -package-id ghci-8.7{unit ghci-8.7 True ([])},
               -package-id haskeline-0.7.4.3{unit haskeline-0.7.4.3 True ([])},
               -package-id process-1.6.3.0{unit process-1.6.3.0 True ([])},
               -package-id time-1.9.2{unit time-1.9.2 True ([])},
               -package-id transformers-0.5.5.0{unit transformers-0.5.5.0 True ([])},
               -package-id unix-2.7.2.2{unit unix-2.7.2.2 True ([])},
               -package-id array-0.5.2.0{unit array-0.5.2.0 True ([])},
               -package-id base-4.12.0.0{unit base-4.12.0.0 True ([])},
               -package-id bytestring-0.10.9.0{unit bytestring-0.10.9.0 True ([])},
               -package-id containers-0.6.0.1{unit containers-0.6.0.1 True ([])},
               -package-id deepseq-1.4.4.0{unit deepseq-1.4.4.0 True ([])},
               -package-id directory-1.3.3.1{unit directory-1.3.3.1 True ([])},
               -package-id filepath-1.4.2.1{unit filepath-1.4.2.1 True ([])},
               -package-id ghc-8.7{unit ghc-8.7 True ([])},
               -package-id ghc-boot-8.7{unit ghc-boot-8.7 True ([])},
               -package-id ghc-prim-0.5.3{unit ghc-prim-0.5.3 True ([])},
               -package-id ghci-8.7{unit ghci-8.7 True ([])},
               -package-id haskeline-0.7.4.3{unit haskeline-0.7.4.3 True ([])},
               -package-id process-1.6.3.0{unit process-1.6.3.0 True ([])},
               -package-id time-1.9.2{unit time-1.9.2 True ([])},
               -package-id transformers-0.5.5.0{unit transformers-0.5.5.0 True ([])},
               -package-id unix-2.7.2.2{unit unix-2.7.2.2 True ([])}]
loading package database /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/inplace/lib/package.conf.d
wired-in package ghc-prim mapped to ghc-prim-0.5.3
wired-in package integer-wired-in mapped to integer-gmp-1.0.2.0
wired-in package base mapped to base-4.12.0.0
wired-in package rts mapped to rts
wired-in package template-haskell mapped to template-haskell-2.15.0.0
wired-in package ghc mapped to ghc-8.7
("getPreloadPackagesAnd pkgids:",[])
("getPreloadPackagesAnd preload:",["haskeline-0.7.4.3","stm-2.5.0.0","ghc","terminfo-0.4.1.2","process-1.6.3.0","hpc-0.6.0.3","ghci-8.7","transformers-0.5.5.0","template-haskell","pretty-1.1.3.6","ghc-heap-8.7","ghc-boot-8.7","ghc-boot-th-8.7","binary-0.8.6.0","directory-1.3.3.1","unix-2.7.2.2","time-1.9.2","filepath-1.4.2.1","containers-0.6.0.1","bytestring-0.10.9.0","deepseq-1.4.4.0","array-0.5.2.0","base","integer-wired-in","ghc-prim","rts"])
Warning: -rtsopts and -with-rtsopts have no effect with -no-hs-main.
    Call hs_init_ghc() from your main() function to set these options.
Created temporary directory: /run/user/1000/ghc13514_0
*** C Compiler:
/nix/store/qanjz18apdwi0vl98sdrvyf4z4hv65df-gcc-wrapper-7.3.0/bin/cc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c /run/user/1000/ghc13514_0/ghc_1.c -o /run/user/1000/ghc13514_0/ghc_2.o -no-pie -fPIC -U__PIC__ -D__PIC__ -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/rts/dist/build -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/includes -I/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/includes/dist-derivedconstants/header
("getPreloadPackagesAnd pkgids:",[])
("getPreloadPackagesAnd preload:",["haskeline-0.7.4.3","stm-2.5.0.0","ghc","terminfo-0.4.1.2","process-1.6.3.0","hpc-0.6.0.3","ghci-8.7","transformers-0.5.5.0","template-haskell","pretty-1.1.3.6","ghc-heap-8.7","ghc-boot-8.7","ghc-boot-th-8.7","binary-0.8.6.0","directory-1.3.3.1","unix-2.7.2.2","time-1.9.2","filepath-1.4.2.1","containers-0.6.0.1","bytestring-0.10.9.0","deepseq-1.4.4.0","array-0.5.2.0","base","integer-wired-in","ghc-prim","rts"])
@@@ Stripping prefix for "Cffi" to "ffi" for package "rts"
("collectLinkOpts",(["-lHShaskeline-0.7.4.3-ghc8.7.20181205","-lHSstm-2.5.0.0-ghc8.7.20181205","-lHSghc-8.7-ghc8.7.20181205","-lHSterminfo-0.4.1.2-ghc8.7.20181205","-lHSprocess-1.6.3.0-ghc8.7.20181205","-lHShpc-0.6.0.3-ghc8.7.20181205","-lHSghci-8.7-ghc8.7.20181205","-lHStransformers-0.5.5.0-ghc8.7.20181205","-lHStemplate-haskell-2.15.0.0-ghc8.7.20181205","-lHSpretty-1.1.3.6-ghc8.7.20181205","-lHSghc-heap-8.7-ghc8.7.20181205","-lHSghc-boot-8.7-ghc8.7.20181205","-lHSghc-boot-th-8.7-ghc8.7.20181205","-lHSbinary-0.8.6.0-ghc8.7.20181205","-lHSdirectory-1.3.3.1-ghc8.7.20181205","-lHSunix-2.7.2.2-ghc8.7.20181205","-lHStime-1.9.2-ghc8.7.20181205","-lHSfilepath-1.4.2.1-ghc8.7.20181205","-lHScontainers-0.6.0.1-ghc8.7.20181205","-lHSbytestring-0.10.9.0-ghc8.7.20181205","-lHSdeepseq-1.4.4.0-ghc8.7.20181205","-lHSarray-0.5.2.0-ghc8.7.20181205","-lHSbase-4.12.0.0-ghc8.7.20181205","-lHSinteger-gmp-1.0.2.0-ghc8.7.20181205","-lHSghc-prim-0.5.3-ghc8.7.20181205","-lHSrts_thr-ghc8.7.20181205","-lffi"],["-ltinfo","-lrt","-lutil","-ldl","-lgmp","-lm","-lrt","-ldl","-lnuma"],["-Wl,-u,base_GHCziTopHandler_runIO_closure","-Wl,-u,base_GHCziTopHandler_runNonIO_closure","-Wl,-u,ghczmprim_GHCziTuple_Z0T_closure","-Wl,-u,ghczmprim_GHCziTypes_True_closure","-Wl,-u,ghczmprim_GHCziTypes_False_closure","-Wl,-u,base_GHCziPack_unpackCString_closure","-Wl,-u,base_GHCziWeak_runFinalizzerBatch_closure","-Wl,-u,base_GHCziIOziException_stackOverflow_closure","-Wl,-u,base_GHCziIOziException_heapOverflow_closure","-Wl,-u,base_GHCziIOziException_allocationLimitExceeded_closure","-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnMVar_closure","-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnSTM_closure","-Wl,-u,base_GHCziIOziException_cannotCompactFunction_closure","-Wl,-u,base_GHCziIOziException_cannotCompactPinned_closure","-Wl,-u,base_GHCziIOziException_cannotCompactMutable_closure","-Wl,-u,base_ControlziExceptionziBase_absentSumFieldError_closure","-Wl,-u,base_ControlziExceptionziBase_nonTermination_closure","-Wl,-u,base_ControlziExceptionziBase_nestedAtomically_closure","-Wl,-u,base_GHCziEventziThread_blockedOnBadFD_closure","-Wl,-u,base_GHCziConcziSync_runSparks_closure","-Wl,-u,base_GHCziConcziIO_ensureIOManagerIsRunning_closure","-Wl,-u,base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure","-Wl,-u,base_GHCziConcziSignal_runHandlersPtr_closure","-Wl,-u,base_GHCziTopHandler_flushStdHandles_closure","-Wl,-u,base_GHCziTopHandler_runMainIO_closure","-Wl,-u,ghczmprim_GHCziTypes_Czh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Izh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Fzh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Dzh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Wzh_con_info","-Wl,-u,base_GHCziPtr_Ptr_con_info","-Wl,-u,base_GHCziPtr_FunPtr_con_info","-Wl,-u,base_GHCziInt_I8zh_con_info","-Wl,-u,base_GHCziInt_I16zh_con_info","-Wl,-u,base_GHCziInt_I32zh_con_info","-Wl,-u,base_GHCziInt_I64zh_con_info","-Wl,-u,base_GHCziWord_W8zh_con_info","-Wl,-u,base_GHCziWord_W16zh_con_info","-Wl,-u,base_GHCziWord_W32zh_con_info","-Wl,-u,base_GHCziWord_W64zh_con_info","-Wl,-u,base_GHCziStable_StablePtr_con_info","-Wl,-u,hs_atomic_add8","-Wl,-u,hs_atomic_add16","-Wl,-u,hs_atomic_add32","-Wl,-u,hs_atomic_add64","-Wl,-u,hs_atomic_sub8","-Wl,-u,hs_atomic_sub16","-Wl,-u,hs_atomic_sub32","-Wl,-u,hs_atomic_sub64","-Wl,-u,hs_atomic_and8","-Wl,-u,hs_atomic_and16","-Wl,-u,hs_atomic_and32","-Wl,-u,hs_atomic_and64","-Wl,-u,hs_atomic_nand8","-Wl,-u,hs_atomic_nand16","-Wl,-u,hs_atomic_nand32","-Wl,-u,hs_atomic_nand64","-Wl,-u,hs_atomic_or8","-Wl,-u,hs_atomic_or16","-Wl,-u,hs_atomic_or32","-Wl,-u,hs_atomic_or64","-Wl,-u,hs_atomic_xor8","-Wl,-u,hs_atomic_xor16","-Wl,-u,hs_atomic_xor32","-Wl,-u,hs_atomic_xor64","-Wl,-u,hs_cmpxchg8","-Wl,-u,hs_cmpxchg16","-Wl,-u,hs_cmpxchg32","-Wl,-u,hs_cmpxchg64","-Wl,-u,hs_atomicread8","-Wl,-u,hs_atomicread16","-Wl,-u,hs_atomicread32","-Wl,-u,hs_atomicread64","-Wl,-u,hs_atomicwrite8","-Wl,-u,hs_atomicwrite16","-Wl,-u,hs_atomicwrite32","-Wl,-u,hs_atomicwrite64"]))
*** C Compiler:
/nix/store/qanjz18apdwi0vl98sdrvyf4z4hv65df-gcc-wrapper-7.3.0/bin/cc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c /run/user/1000/ghc13514_0/ghc_4.s -o /run/user/1000/ghc13514_0/ghc_5.o
("getPreloadPackagesAnd pkgids:",[])
("getPreloadPackagesAnd preload:",["haskeline-0.7.4.3","stm-2.5.0.0","ghc","terminfo-0.4.1.2","process-1.6.3.0","hpc-0.6.0.3","ghci-8.7","transformers-0.5.5.0","template-haskell","pretty-1.1.3.6","ghc-heap-8.7","ghc-boot-8.7","ghc-boot-th-8.7","binary-0.8.6.0","directory-1.3.3.1","unix-2.7.2.2","time-1.9.2","filepath-1.4.2.1","containers-0.6.0.1","bytestring-0.10.9.0","deepseq-1.4.4.0","array-0.5.2.0","base","integer-wired-in","ghc-prim","rts"])
@@@ Stripping prefix for "Cffi" to "ffi" for package "rts"
("collectLinkOpts",(["-lHShaskeline-0.7.4.3-ghc8.7.20181205","-lHSstm-2.5.0.0-ghc8.7.20181205","-lHSghc-8.7-ghc8.7.20181205","-lHSterminfo-0.4.1.2-ghc8.7.20181205","-lHSprocess-1.6.3.0-ghc8.7.20181205","-lHShpc-0.6.0.3-ghc8.7.20181205","-lHSghci-8.7-ghc8.7.20181205","-lHStransformers-0.5.5.0-ghc8.7.20181205","-lHStemplate-haskell-2.15.0.0-ghc8.7.20181205","-lHSpretty-1.1.3.6-ghc8.7.20181205","-lHSghc-heap-8.7-ghc8.7.20181205","-lHSghc-boot-8.7-ghc8.7.20181205","-lHSghc-boot-th-8.7-ghc8.7.20181205","-lHSbinary-0.8.6.0-ghc8.7.20181205","-lHSdirectory-1.3.3.1-ghc8.7.20181205","-lHSunix-2.7.2.2-ghc8.7.20181205","-lHStime-1.9.2-ghc8.7.20181205","-lHSfilepath-1.4.2.1-ghc8.7.20181205","-lHScontainers-0.6.0.1-ghc8.7.20181205","-lHSbytestring-0.10.9.0-ghc8.7.20181205","-lHSdeepseq-1.4.4.0-ghc8.7.20181205","-lHSarray-0.5.2.0-ghc8.7.20181205","-lHSbase-4.12.0.0-ghc8.7.20181205","-lHSinteger-gmp-1.0.2.0-ghc8.7.20181205","-lHSghc-prim-0.5.3-ghc8.7.20181205","-lHSrts_thr-ghc8.7.20181205","-lffi"],["-ltinfo","-lrt","-lutil","-ldl","-lgmp","-lm","-lrt","-ldl","-lnuma"],["-Wl,-u,base_GHCziTopHandler_runIO_closure","-Wl,-u,base_GHCziTopHandler_runNonIO_closure","-Wl,-u,ghczmprim_GHCziTuple_Z0T_closure","-Wl,-u,ghczmprim_GHCziTypes_True_closure","-Wl,-u,ghczmprim_GHCziTypes_False_closure","-Wl,-u,base_GHCziPack_unpackCString_closure","-Wl,-u,base_GHCziWeak_runFinalizzerBatch_closure","-Wl,-u,base_GHCziIOziException_stackOverflow_closure","-Wl,-u,base_GHCziIOziException_heapOverflow_closure","-Wl,-u,base_GHCziIOziException_allocationLimitExceeded_closure","-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnMVar_closure","-Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnSTM_closure","-Wl,-u,base_GHCziIOziException_cannotCompactFunction_closure","-Wl,-u,base_GHCziIOziException_cannotCompactPinned_closure","-Wl,-u,base_GHCziIOziException_cannotCompactMutable_closure","-Wl,-u,base_ControlziExceptionziBase_absentSumFieldError_closure","-Wl,-u,base_ControlziExceptionziBase_nonTermination_closure","-Wl,-u,base_ControlziExceptionziBase_nestedAtomically_closure","-Wl,-u,base_GHCziEventziThread_blockedOnBadFD_closure","-Wl,-u,base_GHCziConcziSync_runSparks_closure","-Wl,-u,base_GHCziConcziIO_ensureIOManagerIsRunning_closure","-Wl,-u,base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure","-Wl,-u,base_GHCziConcziSignal_runHandlersPtr_closure","-Wl,-u,base_GHCziTopHandler_flushStdHandles_closure","-Wl,-u,base_GHCziTopHandler_runMainIO_closure","-Wl,-u,ghczmprim_GHCziTypes_Czh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Izh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Fzh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Dzh_con_info","-Wl,-u,ghczmprim_GHCziTypes_Wzh_con_info","-Wl,-u,base_GHCziPtr_Ptr_con_info","-Wl,-u,base_GHCziPtr_FunPtr_con_info","-Wl,-u,base_GHCziInt_I8zh_con_info","-Wl,-u,base_GHCziInt_I16zh_con_info","-Wl,-u,base_GHCziInt_I32zh_con_info","-Wl,-u,base_GHCziInt_I64zh_con_info","-Wl,-u,base_GHCziWord_W8zh_con_info","-Wl,-u,base_GHCziWord_W16zh_con_info","-Wl,-u,base_GHCziWord_W32zh_con_info","-Wl,-u,base_GHCziWord_W64zh_con_info","-Wl,-u,base_GHCziStable_StablePtr_con_info","-Wl,-u,hs_atomic_add8","-Wl,-u,hs_atomic_add16","-Wl,-u,hs_atomic_add32","-Wl,-u,hs_atomic_add64","-Wl,-u,hs_atomic_sub8","-Wl,-u,hs_atomic_sub16","-Wl,-u,hs_atomic_sub32","-Wl,-u,hs_atomic_sub64","-Wl,-u,hs_atomic_and8","-Wl,-u,hs_atomic_and16","-Wl,-u,hs_atomic_and32","-Wl,-u,hs_atomic_and64","-Wl,-u,hs_atomic_nand8","-Wl,-u,hs_atomic_nand16","-Wl,-u,hs_atomic_nand32","-Wl,-u,hs_atomic_nand64","-Wl,-u,hs_atomic_or8","-Wl,-u,hs_atomic_or16","-Wl,-u,hs_atomic_or32","-Wl,-u,hs_atomic_or64","-Wl,-u,hs_atomic_xor8","-Wl,-u,hs_atomic_xor16","-Wl,-u,hs_atomic_xor32","-Wl,-u,hs_atomic_xor64","-Wl,-u,hs_cmpxchg8","-Wl,-u,hs_cmpxchg16","-Wl,-u,hs_cmpxchg32","-Wl,-u,hs_cmpxchg64","-Wl,-u,hs_atomicread8","-Wl,-u,hs_atomicread16","-Wl,-u,hs_atomicread32","-Wl,-u,hs_atomicread64","-Wl,-u,hs_atomicwrite8","-Wl,-u,hs_atomicwrite16","-Wl,-u,hs_atomicwrite32","-Wl,-u,hs_atomicwrite64"]))
*** Linker:
/nix/store/qanjz18apdwi0vl98sdrvyf4z4hv65df-gcc-wrapper-7.3.0/bin/cc -fno-stack-protector -DTABLES_NEXT_TO_CODE '-Wl,--hash-size=31' -Wl,--reduce-memory-overheads -Wl,--no-as-needed -Wl,-rpath '-Wl,$ORIGIN/../haskeline-0.7.4.3' -Wl,-rpath '-Wl,$ORIGIN/../stm-2.5.0.0' -Wl,-rpath '-Wl,$ORIGIN/../ghc-8.7' -Wl,-rpath '-Wl,$ORIGIN/../terminfo-0.4.1.2' -Wl,-rpath '-Wl,$ORIGIN/../process-1.6.3.0' -Wl,-rpath '-Wl,$ORIGIN/../hpc-0.6.0.3' -Wl,-rpath '-Wl,$ORIGIN/../ghci-8.7' -Wl,-rpath '-Wl,$ORIGIN/../transformers-0.5.5.0' -Wl,-rpath '-Wl,$ORIGIN/../template-haskell-2.15.0.0' -Wl,-rpath '-Wl,$ORIGIN/../pretty-1.1.3.6' -Wl,-rpath '-Wl,$ORIGIN/../ghc-heap-8.7' -Wl,-rpath '-Wl,$ORIGIN/../ghc-boot-8.7' -Wl,-rpath '-Wl,$ORIGIN/../ghc-boot-th-8.7' -Wl,-rpath '-Wl,$ORIGIN/../directory-1.3.3.1' -Wl,-rpath '-Wl,$ORIGIN/../unix-2.7.2.2' -Wl,-rpath '-Wl,$ORIGIN/../time-1.9.2' -Wl,-rpath '-Wl,$ORIGIN/../filepath-1.4.2.1' -Wl,-rpath '-Wl,$ORIGIN/../binary-0.8.6.0' -Wl,-rpath '-Wl,$ORIGIN/../containers-0.6.0.1' -Wl,-rpath '-Wl,$ORIGIN/../bytestring-0.10.9.0' -Wl,-rpath '-Wl,$ORIGIN/../deepseq-1.4.4.0' -Wl,-rpath '-Wl,$ORIGIN/../array-0.5.2.0' -Wl,-rpath '-Wl,$ORIGIN/../base-4.12.0.0' -Wl,-rpath '-Wl,$ORIGIN/../integer-gmp-1.0.2.0' -Wl,-rpath '-Wl,$ORIGIN/../ghc-prim-0.5.3' -Wl,-rpath '-Wl,$ORIGIN/../rts' -Wl,-zorigin -o ghc/stage2/build/tmp/ghc-stage2 -lm -no-pie -fPIC -U__PIC__ -D__PIC__ -Wl,--gc-sections ghc/stage2/build/Main.dyn_o ghc/stage2/build/GHCi/Leak.dyn_o ghc/stage2/build/GHCi/UI.dyn_o ghc/stage2/build/GHCi/UI/Info.dyn_o ghc/stage2/build/GHCi/UI/Monad.dyn_o ghc/stage2/build/GHCi/UI/Tags.dyn_o ghc/stage2/build/hschooks.dyn_o -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/haskeline/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/haskeline/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/stm/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/stm/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/compiler/stage2/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/compiler/stage2/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/terminfo/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/terminfo/dist-install/build -L/nix/store/x5ms5m9ga6v7vy3akc58yx279ggfnbnl-ghc-build-environment/lib -Xlinker -rpath-link -Xlinker /nix/store/x5ms5m9ga6v7vy3akc58yx279ggfnbnl-ghc-build-environment/lib -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/process/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/process/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/hpc/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/hpc/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghci/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghci/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/transformers/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/transformers/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/template-haskell/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/template-haskell/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/pretty/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/pretty/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-heap/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-heap/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-boot/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-boot/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-boot-th/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-boot-th/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/binary/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/binary/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/directory/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/directory/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/unix/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/unix/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/time/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/time/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/filepath/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/filepath/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/containers/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/containers/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/bytestring/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/bytestring/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/deepseq/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/deepseq/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/array/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/array/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/base/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/base/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/integer-gmp/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/integer-gmp/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-prim/dist-install/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/libraries/ghc-prim/dist-install/build -L/home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/rts/dist/build -Xlinker -rpath-link -Xlinker /home/david/MEGA/File_Dump/Well-Typed/GHC/_nosync_git/ghc/rts/dist/build /run/user/1000/ghc13514_0/ghc_2.o /run/user/1000/ghc13514_0/ghc_5.o -Wl,-u,base_GHCziTopHandler_runIO_closure -Wl,-u,base_GHCziTopHandler_runNonIO_closure -Wl,-u,ghczmprim_GHCziTuple_Z0T_closure -Wl,-u,ghczmprim_GHCziTypes_True_closure -Wl,-u,ghczmprim_GHCziTypes_False_closure -Wl,-u,base_GHCziPack_unpackCString_closure -Wl,-u,base_GHCziWeak_runFinalizzerBatch_closure -Wl,-u,base_GHCziIOziException_stackOverflow_closure -Wl,-u,base_GHCziIOziException_heapOverflow_closure -Wl,-u,base_GHCziIOziException_allocationLimitExceeded_closure -Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnMVar_closure -Wl,-u,base_GHCziIOziException_blockedIndefinitelyOnSTM_closure -Wl,-u,base_GHCziIOziException_cannotCompactFunction_closure -Wl,-u,base_GHCziIOziException_cannotCompactPinned_closure -Wl,-u,base_GHCziIOziException_cannotCompactMutable_closure -Wl,-u,base_ControlziExceptionziBase_absentSumFieldError_closure -Wl,-u,base_ControlziExceptionziBase_nonTermination_closure -Wl,-u,base_ControlziExceptionziBase_nestedAtomically_closure -Wl,-u,base_GHCziEventziThread_blockedOnBadFD_closure -Wl,-u,base_GHCziConcziSync_runSparks_closure -Wl,-u,base_GHCziConcziIO_ensureIOManagerIsRunning_closure -Wl,-u,base_GHCziConcziIO_ioManagerCapabilitiesChanged_closure -Wl,-u,base_GHCziConcziSignal_runHandlersPtr_closure -Wl,-u,base_GHCziTopHandler_flushStdHandles_closure -Wl,-u,base_GHCziTopHandler_runMainIO_closure -Wl,-u,ghczmprim_GHCziTypes_Czh_con_info -Wl,-u,ghczmprim_GHCziTypes_Izh_con_info -Wl,-u,ghczmprim_GHCziTypes_Fzh_con_info -Wl,-u,ghczmprim_GHCziTypes_Dzh_con_info -Wl,-u,ghczmprim_GHCziTypes_Wzh_con_info -Wl,-u,base_GHCziPtr_Ptr_con_info -Wl,-u,base_GHCziPtr_FunPtr_con_info -Wl,-u,base_GHCziInt_I8zh_con_info -Wl,-u,base_GHCziInt_I16zh_con_info -Wl,-u,base_GHCziInt_I32zh_con_info -Wl,-u,base_GHCziInt_I64zh_con_info -Wl,-u,base_GHCziWord_W8zh_con_info -Wl,-u,base_GHCziWord_W16zh_con_info -Wl,-u,base_GHCziWord_W32zh_con_info -Wl,-u,base_GHCziWord_W64zh_con_info -Wl,-u,base_GHCziStable_StablePtr_con_info -Wl,-u,hs_atomic_add8 -Wl,-u,hs_atomic_add16 -Wl,-u,hs_atomic_add32 -Wl,-u,hs_atomic_add64 -Wl,-u,hs_atomic_sub8 -Wl,-u,hs_atomic_sub16 -Wl,-u,hs_atomic_sub32 -Wl,-u,hs_atomic_sub64 -Wl,-u,hs_atomic_and8 -Wl,-u,hs_atomic_and16 -Wl,-u,hs_atomic_and32 -Wl,-u,hs_atomic_and64 -Wl,-u,hs_atomic_nand8 -Wl,-u,hs_atomic_nand16 -Wl,-u,hs_atomic_nand32 -Wl,-u,hs_atomic_nand64 -Wl,-u,hs_atomic_or8 -Wl,-u,hs_atomic_or16 -Wl,-u,hs_atomic_or32 -Wl,-u,hs_atomic_or64 -Wl,-u,hs_atomic_xor8 -Wl,-u,hs_atomic_xor16 -Wl,-u,hs_atomic_xor32 -Wl,-u,hs_atomic_xor64 -Wl,-u,hs_cmpxchg8 -Wl,-u,hs_cmpxchg16 -Wl,-u,hs_cmpxchg32 -Wl,-u,hs_cmpxchg64 -Wl,-u,hs_atomicread8 -Wl,-u,hs_atomicread16 -Wl,-u,hs_atomicread32 -Wl,-u,hs_atomicread64 -Wl,-u,hs_atomicwrite8 -Wl,-u,hs_atomicwrite16 -Wl,-u,hs_atomicwrite32 -Wl,-u,hs_atomicwrite64 -lHShaskeline-0.7.4.3-ghc8.7.20181205 -lHSstm-2.5.0.0-ghc8.7.20181205 -lHSghc-8.7-ghc8.7.20181205 -lHSterminfo-0.4.1.2-ghc8.7.20181205 -lHSprocess-1.6.3.0-ghc8.7.20181205 -lHShpc-0.6.0.3-ghc8.7.20181205 -lHSghci-8.7-ghc8.7.20181205 -lHStransformers-0.5.5.0-ghc8.7.20181205 -lHStemplate-haskell-2.15.0.0-ghc8.7.20181205 -lHSpretty-1.1.3.6-ghc8.7.20181205 -lHSghc-heap-8.7-ghc8.7.20181205 -lHSghc-boot-8.7-ghc8.7.20181205 -lHSghc-boot-th-8.7-ghc8.7.20181205 -lHSbinary-0.8.6.0-ghc8.7.20181205 -lHSdirectory-1.3.3.1-ghc8.7.20181205 -lHSunix-2.7.2.2-ghc8.7.20181205 -lHStime-1.9.2-ghc8.7.20181205 -lHSfilepath-1.4.2.1-ghc8.7.20181205 -lHScontainers-0.6.0.1-ghc8.7.20181205 -lHSbytestring-0.10.9.0-ghc8.7.20181205 -lHSdeepseq-1.4.4.0-ghc8.7.20181205 -lHSarray-0.5.2.0-ghc8.7.20181205 -lHSbase-4.12.0.0-ghc8.7.20181205 -lHSinteger-gmp-1.0.2.0-ghc8.7.20181205 -lHSghc-prim-0.5.3-ghc8.7.20181205 -lHSrts_thr-ghc8.7.20181205 -lffi -ltinfo -lrt -lutil -ldl -lgmp -lm -lrt -ldl -lnuma
*** Deleting temp files:
Deleting: /run/user/1000/ghc13514_0/ghc_1.c /run/user/1000/ghc13514_0/ghc_3.rsp /run/user/1000/ghc13514_0/ghc_4.s /run/user/1000/ghc13514_0/ghc_6.rsp /run/user/1000/ghc13514_0/ghc_7.rsp /run/user/1000/ghc13514_0/ghc_2.o /run/user/1000/ghc13514_0/ghc_5.o
*** Deleting temp dirs:
Deleting: /run/user/1000/ghc13514_0

Note that make also uses -lffi. Hence I will proceed under the assumption that -lffi is correct, and the problem that needs to be solved in getting the linker to correctly find the locally built libffi .so file.

comment:18 Changed 2 months ago by davide

The locally built libffi is bundled with the rts package. As libffi is not a haskell library, the naming convention is to call the library Cffi in rts/rts.cabal.in (see specifically the line extra-bundled-libraries: Cffi).

When ghc is calculating the linker options, ghc sees that Cffi is bundled with rts and tries to link with it. The "C" prefix is striped, but unlike haskell libraries a version number is not suffixed (this logic is in compiler/main/Packages.hs:packageHsLibs). Hence ghc links with the -lffi option instead of e.g. -lCffi or -lCffi-7.0. This means the linker is looking for a corresponding .so file named libffi.so.

As per comment:14 it is easy to produce the libffi.so file, but it isn't in the correct location at the moment. There are 2 relevant steps that hadrian takes here:

  1. After building libffi, copy the .so from _build/stage1/libffi/build/inst/lib/libffi.so to _build/stage1/rts/build/X.
  2. "Install" the .so by copying it from _build/stage1/rts/build/ to _build/stage1/lib/x86_64-linux-ghc-8.7.20181205/X

Currently X uses a naming convention convention of e.g.libCffi-ghc8.7.20181126_thr_debug.so. This naming convention does not match ghc's as described before. It seems that changing X to match the ghc naming convention would solve the problem, but is that the correct solution? Changing the naming convention for the static libffi libraries also sounds necessary, but I thought the the static build has been working so far. How is that possible?

Last edited 2 months ago by davide (previous) (diff)

comment:19 Changed 2 months ago by davide

When looking at the output of make I get:

$ find . -name "*ffi*.so*" -or -name "*ffi*.a*"
./libffi/build/x86_64-unknown-linux-gnu/.libs/libffi_convenience.a
./libffi/build/x86_64-unknown-linux-gnu/.libs/libffi.so.7.1.0
./libffi/build/x86_64-unknown-linux-gnu/.libs/libffi.so.7
./libffi/build/x86_64-unknown-linux-gnu/.libs/libffi.so
./libffi/build/x86_64-unknown-linux-gnu/.libs/libffi.a
./libffi/build/inst/lib/libffi.so.7.1.0
./libffi/build/inst/lib/libffi.so.7
./libffi/build/inst/lib/libffi.so
./libffi/build/inst/lib/libffi.a
./rts/dist/build/libCffi_p.a
./rts/dist/build/libffi.so
./rts/dist/build/libffi.so.7
./rts/dist/build/libffi.so.7.1.0
./rts/dist/build/libCffi_l.a
./rts/dist/build/libCffi_debug.a
./rts/dist/build/libCffi_thr.a
./rts/dist/build/libCffi_thr_debug.a
./rts/dist/build/libCffi_thr_l.a
./rts/dist/build/libCffi_thr_p.a
./rts/dist/build/libCffi_thr_debug_p.a
./rts/dist/build/libCffi_debug_p.a
./rts/dist/build/libCffi.a

Note that all the libCffi*.a files are identical, and all libCffi*.so files are identical.

Dynamic

This matches closely with my previous comments, but with the addition of some extra versioned .so files. Note the symlinks:

$ ls -l _build/stage1/libffi/build/inst/lib/libffi.so*
lrwxrwxrwx 1 david david    15 Dec  6 10:28 _build/stage1/libffi/build/inst/lib/libffi.so -> libffi.so.7.1.0
lrwxrwxrwx 1 david david    15 Dec  6 10:28 _build/stage1/libffi/build/inst/lib/libffi.so.7 -> libffi.so.7.1.0
-rwxr-xr-x 1 david david 70232 Dec  6 10:28 _build/stage1/libffi/build/inst/lib/libffi.so.7.1.0

Static

This matches hadrians behavior w.r.t static libffi. On that grounds I'm going to leave the static libs behavior as is, but add a note about possible simplification here: only copy a single .a file as we will do with the dynamic version.

comment:20 Changed 2 months ago by davide

Differential Rev(s): Phab:D5385 Phab:D5327Phab:D5385 Phab:D5327 Phab:D5423

I've created a patch Phab:D5423, with a note about future improvement.

comment:21 Changed 2 months ago by Ben Gamari <ben@…>

In 4efafe7e/ghc:

Revert dynamically linking ghc.

Building a dynamically linked ghc is broken do to incorrectly building
and installing libffi. This disables building a dynamically linked ghc
and ghc-iserv-dyn while keeping most of the code in the relevant
commits: 79d5427e1 and 89fa34ecd

Test Plan:
Ensure build environment does NOT have a system libffi installed (you
may want to use a nix environment).
Then `hadrian/build.sh -c --flavour=default`.

Reviewers: bgamari, alpmestan

Reviewed By: alpmestan

Subscribers: rwbarton, carter

GHC Trac Issues: #15837

Differential Revision: https://phabricator.haskell.org/D5430
Note: See TracTickets for help on using tickets.