summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamar Christina <tamar@zhox.com>2020-08-16 17:18:14 +0100
committerBen Gamari <ben@smart-cactus.org>2021-01-25 14:33:20 -0500
commit3fcbf64bf2608c6dd60da8536067688343fed63c (patch)
treed23b9677416f21041abff24dd8fa5e03893f7f85
parentb846d37c787574efc502e29f53c172ce20ffd5ad (diff)
downloadhaskell-3fcbf64bf2608c6dd60da8536067688343fed63c.tar.gz
Fix use distro toolchian
(cherry picked from commit f065b6b012fb8f73689bc5c2a4904d5e6e377af8)
-rw-r--r--aclocal.m42
-rw-r--r--compiler/main/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 50cb1bbc7d..e35428426a 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -603,6 +603,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)
@@ -625,6 +626,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/main/SysTools/BaseDir.hs b/compiler/main/SysTools/BaseDir.hs
index c4fc71b502..c98d3e8268 100644
--- a/compiler/main/SysTools/BaseDir.hs
+++ b/compiler/main/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 d1462db837..2a43dd8bb3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -445,6 +445,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 450df8002d..81ea4c457a 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 44f1ed7bc8..2839426bbf 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 01e8ccb638..793d91f6af 100644
--- a/hadrian/src/Rules/Generate.hs
+++ b/hadrian/src/Rules/Generate.hs
@@ -235,6 +235,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__"
@@ -264,6 +265,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 ef3794fecf..0d3006b049 100644
--- a/includes/ghc.mk
+++ b/includes/ghc.mk
@@ -185,6 +185,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 9ee2eab59f..bb05baae21 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@