summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ghc.mk7
-rw-r--r--utils/ghc-pkg/ghc.mk6
2 files changed, 13 insertions, 0 deletions
diff --git a/ghc.mk b/ghc.mk
index caa6c38fbb..8971f25981 100644
--- a/ghc.mk
+++ b/ghc.mk
@@ -962,6 +962,12 @@ endif
INSTALLED_PACKAGE_CONF=$(DESTDIR)$(topdir)/package.conf.d
+ifeq "$(CrossCompiling)" "YES"
+# when installing ghc-stage2 we can't run target's
+# 'ghc-pkg' and 'ghc-stage2' but those are needed for registration.
+INSTALLED_GHC_REAL=$(TOP)/inplace/bin/ghc-stage1
+INSTALLED_GHC_PKG_REAL=$(TOP)/$(ghc-pkg_DIST_BINARY)
+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
INSTALLED_GHC_REAL=$(DESTDIR)$(bindir)/ghc.exe
INSTALLED_GHC_PKG_REAL=$(DESTDIR)$(bindir)/ghc-pkg.exe
endif
+endif # CrossCompiling
# Set the INSTALL_DISTDIR_p for each package; compiler is special
$(foreach p,$(filter-out compiler,$(INSTALL_PACKAGES)),\
diff --git a/utils/ghc-pkg/ghc.mk b/utils/ghc-pkg/ghc.mk
index 002c8122f2..4d5ef4e108 100644
--- a/utils/ghc-pkg/ghc.mk
+++ b/utils/ghc-pkg/ghc.mk
@@ -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/config.mk.in.
ifeq "$(Stage1Only)" "YES"
# Install the copy of ghc-pkg from the dist directory when running 'make