Skip to content
Snippets Groups Projects
Commit c80799d4 authored by Rodrigo Mesquita's avatar Rodrigo Mesquita :seedling:
Browse files

Add Note [How we configure the bundled windows toolchain]

parent 4372c1fa
No related branches found
No related tags found
No related merge requests found
Pipeline #81402 canceled
...@@ -444,7 +444,6 @@ generateGhcPlatformH = do ...@@ -444,7 +444,6 @@ generateGhcPlatformH = do
, "#endif /* __GHCPLATFORM_H__ */" , "#endif /* __GHCPLATFORM_H__ */"
] ]
-- See Note [tooldir: How GHC finds mingw on Windows]
generateSettings :: Expr String generateSettings :: Expr String
generateSettings = do generateSettings = do
ctx <- getContext ctx <- getContext
...@@ -533,6 +532,8 @@ generateSettings = do ...@@ -533,6 +532,8 @@ generateSettings = do
-- Like @'queryTarget'@ specialized to String, but replace occurrences of -- Like @'queryTarget'@ specialized to String, but replace occurrences of
-- @topDirectory </> inplace/mingw@ with @$$tooldir/mingw@ in the resulting string -- @topDirectory </> inplace/mingw@ with @$$tooldir/mingw@ in the resulting string
--
-- See Note [How we configure the bundled windows toolchain]
queryTarget' :: (Toolchain.Target -> String) -> Expr String queryTarget' :: (Toolchain.Target -> String) -> Expr String
queryTarget' f = do queryTarget' f = do
topdir <- expr $ topDirectory topdir <- expr $ topDirectory
......
dnl Note [How we configure the bundled windows toolchain]
dnl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dnl As per Note [tooldir: How GHC finds mingw on Windows], when using the
dnl bundled windows toolchain, the GHC settings file must refer to the
dnl toolchain through a path relative to $$tooldir (binary distributions on
dnl Windows should work without configure, so the paths must be relative to the
dnl installation). However, hadrian expects the configured toolchain to use
dnl full paths to the executable.
dnl
dnl This is how the bundled windows toolchain is configured, to define the
dnl toolchain with paths to the executables, while still writing into GHC
dnl settings the paths relative to $$tooldir:
dnl
dnl * If using the bundled toolchain, FP_SETUP_WINDOWS_TOOLCHAIN will be invoked
dnl
dnl * FP_SETUP_WINDOWS_TOOLCHAIN will set the toolchain variables to paths
dnl to the bundled toolchain (e.g. CFLAGS=/full/path/to/mingw/bin/gcc)
dnl
dnl * Later on, in FP_SETTINGS, we substitute occurrences of the path to the
dnl mingw tooldir by $$tooldir (see SUBST_TOOLDIR).
dnl The reason is the Settings* variants of toolchain variables are used by the bindist configure to
dnl create the settings file, which needs the windows bundled toolchain to be relative to $$tooldir.
dnl
dnl * Finally, hadrian will also substitute the mingw prefix by $$tooldir before writing the toolchain to the settings file (see generateSettings)
dnl
dnl The ghc-toolchain program isn't concerned with any of these complications:
dnl it is passed either the full paths to the toolchain executables, or the bundled
dnl mingw path is set first on $PATH before invoking it. And ghc-toolchain
dnl will, as always, output target files with full paths to the executables.
dnl
dnl Hadrian accounts for this as it does for the toolchain executables
dnl configured by configure -- in fact, hadrian doesn't need to know whether
dnl the toolchain description file was generated by configure or by
dnl ghc-toolchain.
# SUBST_TOOLDIR # SUBST_TOOLDIR
# ---------------------------------- # ----------------------------------
# $1 - the variable where to search for occurrences of the path to the # $1 - the variable where to search for occurrences of the path to the
# distributed mingw, and update by substituting said occurrences by # distributed mingw, and update by substituting said occurrences by
# the literal '$$tooldir/mingw' # the literal '$$tooldir/mingw'
#
# See Note [How we configure the bundled windows toolchain]
AC_DEFUN([SUBST_TOOLDIR], AC_DEFUN([SUBST_TOOLDIR],
[ [
dnl See Note [tooldir: How GHC finds mingw on Windows] dnl and Note [How we configure the bundled windows toolchain]
$1=`echo $$1 | sed 's%'"$mingwpath"'%$$tooldir/mingw%'` $1=`echo $$1 | sed 's%'"$mingwpath"'%$$tooldir/mingw%'`
]) ])
......
...@@ -65,7 +65,8 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[ ...@@ -65,7 +65,8 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
fi fi
} }
# See Note [tooldir: How GHC finds mingw on Windows] # See Note [How we configure the bundled windows toolchain]
# and Note [tooldir: How GHC finds mingw on Windows]
test -d inplace || mkdir inplace test -d inplace || mkdir inplace
# NB. Download and extract the MingW-w64 distribution if required # NB. Download and extract the MingW-w64 distribution if required
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment