Commit 54895c90 authored by Sergei Trofimovich's avatar Sergei Trofimovich
Browse files

fix 'make install' for cross-stage2

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.

Signed-off-by: default avatarSergei Trofimovich <>

Test Plan: run 'make install' on stage2 crosscompiler

Reviewers: rwbarton, austin, bgamari

Subscribers: thomie, snowleopard

Differential Revision:
parent f0d98fc6
......@@ -962,6 +962,12 @@ endif
ifeq "$(CrossCompiling)" "YES"
# when installing ghc-stage2 we can't run target's
# 'ghc-pkg' and 'ghc-stage2' but those are needed for registration.
else # CrossCompiling
# Install packages in the right order, so that ghc-pkg doesn't complain.
# Also, install ghc-pkg first.
ifeq "$(Windows_Host)" "NO"
......@@ -971,6 +977,7 @@ else
endif # CrossCompiling
# Set the INSTALL_DISTDIR_p for each package; compiler is special
$(foreach p,$(filter-out compiler,$(INSTALL_PACKAGES)),\
......@@ -49,6 +49,12 @@ utils/ghc-pkg_dist_PROGNAME = ghc-pkg
utils/ghc-pkg_dist_SHELL_WRAPPER = YES
utils/ghc-pkg_dist_INSTALL_INPLACE = YES
# When cross-built ghc-stage2 is installed 'make install' needs to call
# native ghc-pkg (not the cross-built one) to register installed packages
# 'ghc-pkg_DIST_BINARY' variable only refer to native binary.
ghc-pkg_DIST_BINARY_NAME = ghc-pkg$(exeext0)
ghc-pkg_DIST_BINARY = utils/ghc-pkg/dist/build/tmp/$(ghc-pkg_DIST_BINARY_NAME)
# See Note [Stage1Only vs stage=1] in mk/
ifeq "$(Stage1Only)" "YES"
# Install the copy of ghc-pkg from the dist directory when running 'make
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment