summaryrefslogtreecommitdiff
path: root/hadrian/src
diff options
context:
space:
mode:
authorAlp Mestanogullari <alpmestan@gmail.com>2019-04-09 12:08:04 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-05-23 22:32:15 -0400
commit04b4b98447c36a2d28fffe819c97c32b591479ee (patch)
tree4323aadcc215c210110822161c6a8a822a5d67ca /hadrian/src
parent535a26c90f458801aeb1e941a3f541200d171e8f (diff)
downloadhaskell-04b4b98447c36a2d28fffe819c97c32b591479ee.tar.gz
add an --hadrian mode to ./validate
When the '--hadrian' flag is passed to the validate script, we use hadrian to build GHC, package it up in a binary distribution and later on run GHC's testsuite against the said bindist, which gets installed locally in the process. Along the way, this commit fixes a typo, an omission (build iserv binaries before producing the bindist archive) and moves the Makefile that enables 'make install' on those bindists from being a list of strings in the code to an actual file (it was becoming increasingly annoying to work with). Finally, the Settings.Builders.Ghc part of this patch is necessary for being able to use the installed binary distribution, in 'validate'.
Diffstat (limited to 'hadrian/src')
-rw-r--r--hadrian/src/CommandLine.hs2
-rw-r--r--hadrian/src/Rules/BinaryDist.hs153
-rw-r--r--hadrian/src/Settings/Builders/Ghc.hs17
3 files changed, 19 insertions, 153 deletions
diff --git a/hadrian/src/CommandLine.hs b/hadrian/src/CommandLine.hs
index 41b2f8d0b9..461898cdfd 100644
--- a/hadrian/src/CommandLine.hs
+++ b/hadrian/src/CommandLine.hs
@@ -146,7 +146,7 @@ readTestConfig config =
readTestConfigFile :: Maybe String -> Either String (CommandLineArgs -> CommandLineArgs)
readTestConfigFile filepath =
- maybe (Left "Cannot parse test-speed") (Right . set) filepath
+ maybe (Left "Cannot parse test-config-file") (Right . set) filepath
where
set filepath flags = flags { testArgs = (testArgs flags) { testConfigFile = filepath } }
diff --git a/hadrian/src/Rules/BinaryDist.hs b/hadrian/src/Rules/BinaryDist.hs
index c02d9787f9..9f5aba8401 100644
--- a/hadrian/src/Rules/BinaryDist.hs
+++ b/hadrian/src/Rules/BinaryDist.hs
@@ -101,6 +101,7 @@ bindistRules = do
-- We 'need' all binaries and libraries
targets <- mapM pkgTarget =<< stagePackages Stage1
need targets
+ needIservBins
version <- setting ProjectVersion
targetPlatform <- setting TargetPlatformFull
@@ -180,8 +181,9 @@ bindistRules = do
moveFile (ghcRoot -/- "distrib" -/- "configure") configurePath
-- Generate the Makefile that enables the "make install" part
- root -/- "bindist" -/- "ghc-*" -/- "Makefile" %> \makefilePath ->
- writeFile' makefilePath bindistMakefile
+ root -/- "bindist" -/- "ghc-*" -/- "Makefile" %> \makefilePath -> do
+ top <- topDirectory
+ copyFile (top -/- "hadrian" -/- "bindist" -/- "Makefile") makefilePath
root -/- "bindist" -/- "ghc-*" -/- "wrappers/*" %> \wrapperPath ->
writeFile' wrapperPath $ wrapper (takeFileName wrapperPath)
@@ -216,153 +218,6 @@ pkgTarget pkg
| isLibrary pkg = pkgConfFile (vanillaContext Stage1 pkg)
| otherwise = programPath =<< programContext Stage1 pkg
--- TODO: Augment this Makefile to match the various parameters that the current
--- bindist scripts support.
--- | A trivial Makefile that only takes @$prefix@ into account, and not e.g
--- @$datadir@ (for docs) and other variables, yet.
-bindistMakefile :: String
-bindistMakefile = unlines
- [ "MAKEFLAGS += --no-builtin-rules"
- , ".SUFFIXES:"
- , ""
- , "include mk/install.mk"
- , "include mk/config.mk"
- , ""
- , ".PHONY: default"
- , "default:"
- , "\t@echo 'Run \"make install\" to install'"
- , "\t@false"
- , ""
- , "#-----------------------------------------------------------------------"
- , "# INSTALL RULES"
- , ""
- , "# Hacky function to check equality of two strings"
- , "# TODO : find if a better function exists"
- , "eq=$(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))"
- , ""
- , "define installscript"
- , "# $1 = package name"
- , "# $2 = wrapper path"
- , "# $3 = bindir"
- , "# $4 = ghcbindir"
- , "# $5 = Executable binary path"
- , "# $6 = Library Directory"
- , "# $7 = Docs Directory"
- , "# $8 = Includes Directory"
- , "# We are installing wrappers to programs by searching corresponding"
- , "# wrappers. If wrapper is not found, we are attaching the common wrapper"
- , "# to it. This implementation is a bit hacky and depends on consistency"
- , "# of program names. For hadrian build this will work as programs have a"
- , "# consistent naming procedure."
- , "\trm -f '$2'"
- , "\t$(CREATE_SCRIPT) '$2'"
- , "\t@echo \"#!$(SHELL)\" >> '$2'"
- , "\t@echo \"exedir=\\\"$4\\\"\" >> '$2'"
- , "\t@echo \"exeprog=\\\"$1\\\"\" >> '$2'"
- , "\t@echo \"executablename=\\\"$5\\\"\" >> '$2'"
- , "\t@echo \"bindir=\\\"$3\\\"\" >> '$2'"
- , "\t@echo \"libdir=\\\"$6\\\"\" >> '$2'"
- , "\t@echo \"docdir=\\\"$7\\\"\" >> '$2'"
- , "\t@echo \"includedir=\\\"$8\\\"\" >> '$2'"
- , "\t@echo \"\" >> '$2'"
- , "\tcat wrappers/$1 >> '$2'"
- , "\t$(EXECUTABLE_FILE) '$2' ;"
- , "endef"
- , ""
- , "# Hacky function to patch up the 'haddock-interfaces' and 'haddock-html'"
- , "# fields in the package .conf files"
- , "define patchpackageconf"
- , "# $1 = package name (ex: 'bytestring')"
- , "# $2 = path to .conf file"
- , "# $3 = Docs Directory"
- , "\tcat '$2' | sed 's|haddock-interfaces.*|haddock-interfaces: $3/html/libraries/$1/$1.haddock|' \\"
- , "\t | sed 's|haddock-html.*|haddock-html: $3/html/libraries/$1|' \\"
- , "\t > '$2.copy'"
- , "\tmv '$2.copy' '$2'"
- , "endef"
- , ""
- , "# QUESTION : should we use shell commands?"
- , ""
- , ""
- , ".PHONY: install"
- , "install: install_lib install_bin install_includes"
- , "install: install_docs install_wrappers install_ghci"
- , "install: install_mingw update_package_db"
- , ""
- , "ActualBinsDir=${ghclibdir}/bin"
- , "ActualLibsDir=${ghclibdir}/lib"
- , "WrapperBinsDir=${bindir}"
- , ""
- , "# We need to install binaries relative to libraries."
- , "BINARIES = $(wildcard ./bin/*)"
- , "install_bin:"
- , "\t@echo \"Copying binaries to $(ActualBinsDir)\""
- , "\t$(INSTALL_DIR) \"$(ActualBinsDir)\""
- , "\tfor i in $(BINARIES); do \\"
- , "\t\tcp -R $$i \"$(ActualBinsDir)\"; \\"
- , "\tdone"
- , ""
- , "install_ghci:"
- , "\t@echo \"Installing ghci wrapper\""
- , "\t@echo \"#!$(SHELL)\" > '$(WrapperBinsDir)/ghci'"
- , "\tcat wrappers/ghci-script >> '$(WrapperBinsDir)/ghci'"
- , "\t$(EXECUTABLE_FILE) '$(WrapperBinsDir)/ghci'"
- , ""
- , "LIBRARIES = $(wildcard ./lib/*)"
- , "install_lib:"
- , "\t@echo \"Copying libraries to $(ActualLibsDir)\""
- , "\t$(INSTALL_DIR) \"$(ActualLibsDir)\""
- , "\tfor i in $(LIBRARIES); do \\"
- , "\t\tcp -R $$i \"$(ActualLibsDir)/\"; \\"
- , "\tdone"
- , ""
- , "INCLUDES = $(wildcard ./include/*)"
- , "install_includes:"
- , "\t@echo \"Copying libraries to $(includedir)\""
- , "\t$(INSTALL_DIR) \"$(includedir)\""
- , "\tfor i in $(INCLUDES); do \\"
- , "\t\tcp -R $$i \"$(includedir)/\"; \\"
- , "\tdone"
- , ""
- , "DOCS = $(wildcard ./docs/*)"
- , "install_docs:"
- , "\t@echo \"Copying libraries to $(docdir)\""
- , "\t$(INSTALL_DIR) \"$(docdir)\""
- , "\tfor i in $(DOCS); do \\"
- , "\t\tcp -R $$i \"$(docdir)/\"; \\"
- , "\tdone"
- , ""
- , "BINARY_NAMES=$(shell ls ./wrappers/)"
- , "install_wrappers:"
- , "\t@echo \"Installing Wrapper scripts\""
- , "\t$(INSTALL_DIR) \"$(WrapperBinsDir)\""
- , "\t$(foreach p, $(BINARY_NAMES),\\"
- , "\t\t$(call installscript,$p,$(WrapperBinsDir)/$p," ++
- "$(WrapperBinsDir),$(ActualBinsDir),$(ActualBinsDir)/$p," ++
- "$(ActualLibsDir),$(docdir),$(includedir)))"
- , "\trm -f '$(WrapperBinsDir)/ghci-script'" -- FIXME: we shouldn't generate it in the first place
- , ""
- , "PKG_CONFS = $(wildcard $(ActualLibsDir)/package.conf.d/*)"
- , "update_package_db:"
- , "\t@echo \"Updating the package DB\""
- , "\t$(foreach p, $(PKG_CONFS),\\"
- , "\t\t$(call patchpackageconf," ++
- "$(shell echo $(notdir $p) | sed 's/-\\([0-9]*[0-9]\\.\\)*conf//g')," ++
- "$p,$(docdir)))"
- , "\t'$(WrapperBinsDir)/ghc-pkg' recache"
- , ""
- , "# The 'foreach' that copies the mingw directory will only trigger a copy"
- , "# when the wildcard matches, therefore only on Windows."
- , "MINGW = $(wildcard ./mingw)"
- , "install_mingw:"
- , "\t@echo \"Installing MingGW\""
- , "\t$(INSTALL_DIR) \"$(prefix)/mingw\""
- , "\t$(foreach d, $(MINGW),\\"
- , "\t\tcp -R ./mingw \"$(prefix)\")"
- , "# END INSTALL"
- , "# ----------------------------------------------------------------------"
- ]
-
wrapper :: FilePath -> String
wrapper "ghc" = ghcWrapper
wrapper "ghc-pkg" = ghcPkgWrapper
diff --git a/hadrian/src/Settings/Builders/Ghc.hs b/hadrian/src/Settings/Builders/Ghc.hs
index 81fc9d183a..0f5ed94b9b 100644
--- a/hadrian/src/Settings/Builders/Ghc.hs
+++ b/hadrian/src/Settings/Builders/Ghc.hs
@@ -97,13 +97,24 @@ ghcLinkArgs = builder (Ghc LinkHs) ? do
, arg ("-l" ++ libffiName')
]
+ -- This is the -rpath argument that is required for the bindist scenario
+ -- to work. Indeed, when you install a bindist, the actual executables
+ -- end up nested somewhere under $libdir, with the wrapper scripts
+ -- taking their place in $bindir, and 'rpath' therefore doesn't seem
+ -- to give us the right paths for such a case.
+ -- TODO: Could we get away with just one rpath...?
+ bindistRpath = "$ORIGIN" -/- ".." -/- ".." -/- originToLibsDir
+
mconcat [ dynamic ? mconcat
[ arg "-dynamic"
-- TODO what about windows?
, isLibrary pkg ? pure [ "-shared", "-dynload", "deploy" ]
- , hostSupportsRPaths ? arg ("-optl-Wl,-rpath," ++ rpath)
- -- The darwin linker doesn't support/require the -zorigin option
- , hostSupportsRPaths ? not darwin ? arg "-optl-Wl,-zorigin"
+ , hostSupportsRPaths ? mconcat
+ [ arg ("-optl-Wl,-rpath," ++ rpath)
+ , isProgram pkg ? arg ("-optl-Wl,-rpath," ++ bindistRpath)
+ -- The darwin linker doesn't support/require the -zorigin option
+ , not darwin ? arg "-optl-Wl,-zorigin"
+ ]
]
, arg "-no-auto-link-packages"
, nonHsMainPackage pkg ? arg "-no-hs-main"