fix 'make install' for cross-stage2

Authored by trofi on Apr 7 2017, 4:25 AM.



When cross-built GHC is being installed one of
latest steps is to register installed libraries
with 'ghc-pkg'.

GHC uses freshly installed 'ghc-pkg' and 'ghc-stage2'
for that.

Tested as:

./configure --target=aarch64-unknown-linux-gnu
make install DESTDIR=$(pwd)/__s2 STRIP_CMD=:

Before the change install failed on ghc-pkg execution phase:

".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg" \
    --force \
    --global-package-db \
    ".../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/package.conf.d" \
    update rts/dist/package.conf.install
/bin/sh: .../ghc-cross/__s2/usr/local/lib/ghc-8.3.20170406/bin/ghc-pkg: \
    No such file or directory

To avoid breakage we use 'ghc' and 'ghc-pkg' built by stage0.

Reid wrote very similar patch for android crosscompiler:

Signed-off-by: Sergei Trofimovich <>

Test Plan

run 'make install' on stage2 crosscompiler

Diff Detail

rGHC Glasgow Haskell Compiler
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.
trofi created this revision.Apr 7 2017, 4:25 AM
This revision was automatically updated to reflect the committed changes.
rwbarton edited edge metadata.Apr 9 2017, 4:22 PM

Hi @trofi, I've only been half-following this series of commits, but I'm wondering whether there is any documentation on the intended meaning of make install in various configurations, since make install working when crosscompiling is essentially a new feature? Maybe the wiki page for crosscompiling would be a good place?

In particular it's not obvious at first that make install installing a stage2 compiler is ever useful because installed compilers cannot be relocated in the filesystem and the host system usually cannot execute the stage2 compiler. I guess it is probably intended for packaging build systems, maybe in conjunction with a tool like fakeroot?

Is make bindist also supported?

trofi added a comment.Apr 9 2017, 5:46 PM

I can expand existing with cross-compiling/cross-building case.

On 'make install':

My main use case was to tweak 'make install DESTDIR=/tmp/foo' and 'make install Stage1Only=YES DESTDIR=/tmp/foo'
to the point it can be used to create a package for target system (exactly as what 'make install' for non-cross
case would do). Package managers then can convert the result in '/tmp/foo' to package for target platform.

I personally use:

  • 'make install DESTDIR=/tmp/foo' to cross-build GHC for Gentoo to new platforms (emerge --buildpkg). Created packages are directly installable on target by unpacking tarballs (emerge --usepkg), Very usefult step as part of initial porting.
  • 'make install Stage1Only=YES DESTDIR=/tmp/foo' to install cross-compilers into system as normal packages along with native compiler.

On 'make bindist':

I must confess I never tested 'make bindist'. I'll check at least native case and cross-compiler ('Stage1Only=YES')
case. I think 'make bindist' for cross-built stage2 could also work if we expect installation to happen on target
(and not on host).

Is all/some this stuff worth writing on wiki?