summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-08-19 09:41:12 -0400
committerZubin Duggal <zubin.duggal@gmail.com>2021-10-12 14:54:33 +0530
commitf3b1b8d93ee9fa609f388a1acffaafba7d4b20a7 (patch)
treebf364a6f4e91ff010820ec67b1041e0a69e3cea7
parent0893719989e7c889b1f30e4d67acdc526e479120 (diff)
downloadhaskell-f3b1b8d93ee9fa609f388a1acffaafba7d4b20a7.tar.gz
hadrian: Ensure that settings is regenerated during bindist installation
Previously Hadrian would simply install the settings file generated in the build environment during the binary distribution installation. This is wrong since these environments may differ (e.g. different `cc` versions). We noticed on Darwin when installation of a binary distribution produced on a newer Darwin release resulted in a broken compiler due to the installed `settings` file incorrectly claiming that `cc` supported `-no-pie`. Fixing this sadly requires a bit of code duplication since `settings` is produced by Hadrian and not `configure`. For now I have simply duplicated the `settings` generation logic used by the Make build system into Hadrian's bindist Makefile. Ultimately the solution will probably involve shipping a freestanding utility to replace `configure`'s toolchain probing logic and generate a toolchain description file (similar to `settings`) as described in #19877. Fixes #20253. (cherry picked from commit 81975ef375de07a0ea5a69596b2077d7f5959182)
-rw-r--r--hadrian/bindist/Makefile66
-rw-r--r--hadrian/src/Rules/BinaryDist.hs7
-rw-r--r--includes/ghc.mk1
3 files changed, 73 insertions, 1 deletions
diff --git a/hadrian/bindist/Makefile b/hadrian/bindist/Makefile
index 74d2def7f5..d770a77dad 100644
--- a/hadrian/bindist/Makefile
+++ b/hadrian/bindist/Makefile
@@ -95,6 +95,70 @@ ActualLibsDir=${ghclibdir}/lib
endif
WrapperBinsDir=${bindir}
+# N.B. this is duplicated from includes/ghc.mk.
+lib/settings :
+ $(call removeFiles,$@)
+ @echo '[("GCC extra via C opts", "$(GccExtraViaCOpts)")' >> $@
+ @echo ',("C compiler command", "$(SettingsCCompilerCommand)")' >> $@
+ @echo ',("C compiler flags", "$(SettingsCCompilerFlags)")' >> $@
+ @echo ',("C++ compiler flags", "$(SettingsCxxCompilerFlags)")' >> $@
+ @echo ',("C compiler link flags", "$(SettingsCCompilerLinkFlags)")' >> $@
+ @echo ',("C compiler supports -no-pie", "$(SettingsCCompilerSupportsNoPie)")' >> $@
+ @echo ',("Haskell CPP command", "$(SettingsHaskellCPPCommand)")' >> $@
+ @echo ',("Haskell CPP flags", "$(SettingsHaskellCPPFlags)")' >> $@
+ @echo ',("ld command", "$(SettingsLdCommand)")' >> $@
+ @echo ',("ld flags", "$(SettingsLdFlags)")' >> $@
+ @echo ',("ld supports compact unwind", "$(LdHasNoCompactUnwind)")' >> $@
+ @echo ',("ld supports build-id", "$(LdHasBuildId)")' >> $@
+ @echo ',("ld supports filelist", "$(LdHasFilelist)")' >> $@
+ @echo ',("ld is GNU ld", "$(LdIsGNULd)")' >> $@
+ @echo ',("Merge objects command", "$(SettingsMergeObjectsCommand)")' >> $@
+ @echo ',("Merge objects flags", "$(SettingsMergeObjectsFlags)")' >> $@
+ @echo ',("ar command", "$(SettingsArCommand)")' >> $@
+ @echo ',("ar flags", "$(ArArgs)")' >> $@
+ @echo ',("ar supports at file", "$(ArSupportsAtFile)")' >> $@
+ @echo ',("ranlib command", "$(SettingsRanlibCommand)")' >> $@
+ @echo ',("otool command", "$(SettingsOtoolCommand)")' >> $@
+ @echo ',("install_name_tool command", "$(SettingsInstallNameToolCommand)")' >> $@
+ @echo ',("touch command", "$(SettingsTouchCommand)")' >> $@
+ @echo ',("dllwrap command", "$(SettingsDllWrapCommand)")' >> $@
+ @echo ',("windres command", "$(SettingsWindresCommand)")' >> $@
+ @echo ',("libtool command", "$(SettingsLibtoolCommand)")' >> $@
+ @echo ',("unlit command", "$$topdir/bin/unlit")' >> $@
+ @echo ',("cross compiling", "$(CrossCompiling)")' >> $@
+ @echo ',("target platform string", "$(TARGETPLATFORM)")' >> $@
+ @echo ',("target os", "$(HaskellTargetOs)")' >> $@
+ @echo ',("target arch", "$(HaskellTargetArch)")' >> $@
+ @echo ',("target word size", "$(TargetWordSize)")' >> $@
+ @echo ',("target word big endian", "$(TargetWordBigEndian)")' >> $@
+ @echo ',("target has GNU nonexec stack", "$(TargetHasGnuNonexecStack)")' >> $@
+ @echo ',("target has .ident directive", "$(TargetHasIdentDirective)")' >> $@
+ @echo ',("target has subsections via symbols", "$(TargetHasSubsectionsViaSymbols)")' >> $@
+ @echo ',("target has RTS linker", "$(TargetHasRTSLinker)")' >> $@
+ @echo ',("Unregisterised", "$(GhcUnregisterised)")' >> $@
+ @echo ',("LLVM target", "$(LLVMTarget_CPP)")' >> $@
+ @echo ',("LLVM llc command", "$(SettingsLlcCommand)")' >> $@
+ @echo ',("LLVM opt command", "$(SettingsOptCommand)")' >> $@
+ @echo ',("LLVM clang command", "$(SettingsClangCommand)")' >> $@
+ @echo
+ @echo ',("bignum backend", "$(BIGNUM_BACKEND)")' >> $@
+ @echo ',("Use interpreter", "$(GhcWithInterpreter)")' >> $@
+ @echo ',("Support SMP", "$(GhcWithSMP)")' >> $@
+ @echo ',("RTS ways", "$(GhcRTSWays)")' >> $@
+ @echo ',("Tables next to code", "$(TablesNextToCode)")' >> $@
+ @echo ',("Leading underscore", "$(LeadingUnderscore)")' >> $@
+ @echo ',("Use LibFFI", "$(UseLibffiForAdjustors)")' >> $@
+# Note that GhcThreaded just reflects the Makefile variable setting. In
+# particular, the stage1 compiler is never actually compiled with -threaded, but
+# it will nevertheless have cGhcThreaded = True. The "+RTS --info" output will
+# show what RTS GHC is really using.
+ @echo ",(\"Use Threads\", \"$(GhcThreaded)\")" >> $@
+ @echo ",(\"Use Debugging\", \"$(GhcDebugged)\")" >> $@
+ @echo ",(\"RTS expects libdw\", \"$(GhcRtsWithLibdw)\")" >> $@
+ @echo "]" >> $@
+
+
+
# We need to install binaries relative to libraries.
BINARIES = $(wildcard ./bin/*)
install_bin_libdir:
@@ -110,7 +174,7 @@ install_bin_direct:
cp ./bin/* "$(WrapperBinsDir)/"
LIBRARIES = $(wildcard ./lib/*)
-install_lib:
+install_lib: lib/settings
@echo "Copying libraries to $(ActualLibsDir)"
$(INSTALL_DIR) "$(ActualLibsDir)"
for i in $(LIBRARIES); do \
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index 43a0f62f8c..8a03064ffd 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -193,6 +193,13 @@ bindistRules = do
copyDirectory (ghcBuildDir -/- "lib") bindistFilesDir
copyDirectory (rtsIncludeDir) bindistFilesDir
+ -- The settings file must be regenerated by the bindist installation
+ -- logic to account for the environment discovered by the bindist
+ -- configure script on the host. Not on Windows, however, where
+ -- we do not ship a configure script with the bindist. See #20254.
+ unless windowsHost $
+ removeFile (bindistFilesDir -/- "lib" -/- "settings")
+
-- Call ghc-pkg recache, after copying so the package.cache is
-- accurate, then it's on the distributor to use `cp -a` to install
-- a relocatable bindist.
diff --git a/includes/ghc.mk b/includes/ghc.mk
index 6b4611523d..719d23ddef 100644
--- a/includes/ghc.mk
+++ b/includes/ghc.mk
@@ -211,6 +211,7 @@ $(eval $(call includesHeaderPlatform,1))
includes_SETTINGS = includes/dist/build/settings
+# N.B. this is duplicated in hadrian/bindist/Makefile.
$(includes_SETTINGS) : includes/Makefile | $$(dir $$@)/.
$(call removeFiles,$@)
@echo '[("GCC extra via C opts", "$(GccExtraViaCOpts)")' >> $@