summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2020-08-16 17:18:14 +0100
committerMarge Bot <ben+marge-bot@smart-cactus.org>2020-08-28 02:23:13 -0400
commitf065b6b012fb8f73689bc5c2a4904d5e6e377af8 (patch)
tree46d9289744458c7e6d97234772d5bf134590c53e
parentc6f50cea42a9ffc947bf4243986663cc820b0ec8 (diff)
downloadhaskell-f065b6b012fb8f73689bc5c2a4904d5e6e377af8.tar.gz
Fix use distro toolchian
-rw-r--r--aclocal.m42
-rw-r--r--compiler/GHC/SysTools/BaseDir.hs5
-rw-r--r--configure.ac1
-rw-r--r--hadrian/cfg/system.config.in2
-rw-r--r--hadrian/src/Oracles/Flag.hs2
-rw-r--r--hadrian/src/Rules/Generate.hs3
-rw-r--r--includes/ghc.mk3
-rw-r--r--mk/project.mk.in5
8 files changed, 19 insertions, 4 deletions
diff --git a/aclocal.m4 b/aclocal.m4
index 5506f8cd47..8d52319bb9 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -583,6 +583,7 @@ AC_DEFUN([FP_SETTINGS],
SettingsCCompilerLinkFlags="$CONF_GCC_LINKER_OPTS_STAGE2"
SettingsCCompilerSupportsNoPie="$CONF_GCC_SUPPORTS_NO_PIE"
SettingsLdFlags="$CONF_LD_LINKER_OPTS_STAGE2"
+ SettingsUseDistroMINGW="$EnableDistroToolchain"
AC_SUBST(SettingsCCompilerCommand)
AC_SUBST(SettingsHaskellCPPCommand)
AC_SUBST(SettingsHaskellCPPFlags)
@@ -601,6 +602,7 @@ AC_DEFUN([FP_SETTINGS],
AC_SUBST(SettingsClangCommand)
AC_SUBST(SettingsLlcCommand)
AC_SUBST(SettingsOptCommand)
+ AC_SUBST(SettingsUseDistroMINGW)
])
# Helper for cloning a shell variable's state
diff --git a/compiler/GHC/SysTools/BaseDir.hs b/compiler/GHC/SysTools/BaseDir.hs
index e5b0c7ca61..31077451d7 100644
--- a/compiler/GHC/SysTools/BaseDir.hs
+++ b/compiler/GHC/SysTools/BaseDir.hs
@@ -79,7 +79,7 @@ $topdir/../../{mingw, perl}/.
-- | Expand occurrences of the @$tooldir@ interpolation in a string
-- on Windows, leave the string untouched otherwise.
expandToolDir :: Maybe FilePath -> String -> String
-#if defined(mingw32_HOST_OS)
+#if defined(mingw32_HOST_OS) && !defined(USE_INPLACE_MINGW_TOOLCHAIN)
expandToolDir (Just tool_dir) s = expandPathVar "tooldir" tool_dir s
expandToolDir Nothing _ = panic "Could not determine $tooldir"
#else
@@ -117,10 +117,11 @@ tryFindTopDir Nothing
-- Returns @Nothing@ when not on Windows.
-- When called on Windows, it either throws an error when the
-- tooldir can't be located, or returns @Just tooldirpath@.
+-- If the distro toolchain is being used we treat Windows the same as Linux
findToolDir
:: FilePath -- ^ topdir
-> IO (Maybe FilePath)
-#if defined(mingw32_HOST_OS)
+#if defined(mingw32_HOST_OS) && !defined(USE_INPLACE_MINGW_TOOLCHAIN)
findToolDir top_dir = go 0 (top_dir </> "..")
where maxDepth = 3
go :: Int -> FilePath -> IO (Maybe FilePath)
diff --git a/configure.ac b/configure.ac
index c560f1cd6d..6a422d7ff9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -462,6 +462,7 @@ then
# so never tried without the prefix.
AC_PATH_PROG([CC],[gcc], [clang])
AC_PATH_PROG([NM],[nm])
+ AC_PATH_PROG([LD],[ld])
AC_PATH_PROG([AR],[ar])
AC_PATH_PROG([RANLIB],[ranlib])
AC_PATH_PROG([OBJDUMP],[objdump])
diff --git a/hadrian/cfg/system.config.in b/hadrian/cfg/system.config.in
index 7fba53f43e..3fa53330e1 100644
--- a/hadrian/cfg/system.config.in
+++ b/hadrian/cfg/system.config.in
@@ -92,6 +92,8 @@ project-patch-level1 = @ProjectPatchLevel1@
project-patch-level2 = @ProjectPatchLevel2@
project-git-commit-id = @ProjectGitCommitId@
+system-use-distro-mingw = @SettingsUseDistroMINGW@
+
# Compilation and linking flags:
#===============================
diff --git a/hadrian/src/Oracles/Flag.hs b/hadrian/src/Oracles/Flag.hs
index 4f88af6432..960036fa89 100644
--- a/hadrian/src/Oracles/Flag.hs
+++ b/hadrian/src/Oracles/Flag.hs
@@ -25,6 +25,7 @@ data Flag = ArSupportsAtFile
| HaveLibMingwEx
| UseSystemFfi
| BootstrapThreadedRts
+ | SystemDistroMINGW
-- Note, if a flag is set to empty string we treat it as set to NO. This seems
-- fragile, but some flags do behave like this.
@@ -45,6 +46,7 @@ flag f = do
HaveLibMingwEx -> "have-lib-mingw-ex"
UseSystemFfi -> "use-system-ffi"
BootstrapThreadedRts -> "bootstrap-threaded-rts"
+ SystemDistroMINGW -> "system-use-distro-mingw"
value <- lookupValueOrError configFile key
when (value `notElem` ["YES", "NO", ""]) . error $ "Configuration flag "
++ quote (key ++ " = " ++ value) ++ " cannot be parsed."
diff --git a/hadrian/src/Rules/Generate.hs b/hadrian/src/Rules/Generate.hs
index e584907a9b..99a1a9e42f 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -245,6 +245,7 @@ generateGhcPlatformH = do
hostOs <- chooseSetting HostOs TargetOs
hostVendor <- chooseSetting HostVendor TargetVendor
ghcUnreg <- getFlag GhcUnregisterised
+ inplaceTools <- getFlag SystemDistroMINGW
return . unlines $
[ "#if !defined(__GHCPLATFORM_H__)"
, "#define __GHCPLATFORM_H__"
@@ -274,6 +275,8 @@ generateGhcPlatformH = do
, ""
]
++
+ [ "#define USE_INPLACE_MINGW_TOOLCHAIN 1" | inplaceTools ]
+ ++
[ "#define UnregisterisedCompiler 1" | ghcUnreg ]
++
[ ""
diff --git a/includes/ghc.mk b/includes/ghc.mk
index 70733f1e2c..38addb815e 100644
--- a/includes/ghc.mk
+++ b/includes/ghc.mk
@@ -186,6 +186,9 @@ $$(includes_$1_H_PLATFORM) : includes/ghc.mk includes/Makefile | $$$$(dir $$$$@)
@echo "#define BUILD_VENDOR \"$(BuildVendor_$1_CPP)\"" >> $$@
@echo "#define HOST_VENDOR \"$(HostVendor_$1_CPP)\"" >> $$@
@echo >> $$@
+ifeq "$$(SettingsUseDistroMINGW)" "YES"
+ @echo "#define USE_INPLACE_MINGW_TOOLCHAIN 1" >> $$@
+endif
ifeq "$$(GhcUnregisterised)" "YES"
@echo "#define UnregisterisedCompiler 1" >> $$@
endif
diff --git a/mk/project.mk.in b/mk/project.mk.in
index 21d5f6f683..e40a73bf13 100644
--- a/mk/project.mk.in
+++ b/mk/project.mk.in
@@ -20,8 +20,8 @@
#
# The ProjectVersionInt is included in interface files, and GHC
# checks that it's reading interface generated by the same ProjectVersion
-# as itself. It does this even though interface file syntax may not
-# change between versions. Rationale: calling conventions or other
+# as itself. It does this even though interface file syntax may not
+# change between versions. Rationale: calling conventions or other
# random .o-file stuff might change even if the .hi syntax doesn't
ProjectName = @ProjectName@
@@ -127,6 +127,7 @@ BuildVendor_CPP = @BuildVendor_CPP@
# Valid options: YES/NO
#
LeadingUnderscore=@LeadingUnderscore@
+SettingsUseDistroMINGW=@SettingsUseDistroMINGW@
# Pin a suffix on executables? If so, what (Windows only).
exeext0=@exeext_host@