Skip to content
Snippets Groups Projects
Commit 9cac8f11 authored by Matthew Pickering's avatar Matthew Pickering Committed by Marge Bot
Browse files

Abstract windows toolchain setup

This commit splits up the windows toolchain setup logic into two
functions.

* FP_INSTALL_WINDOWS_TOOLCHAIN - deals with downloading the toolchain if
  it isn't already downloaded
* FP_SETUP_WINDOWS_TOOLCHAIN - sets the environment variables to point
  to the correct place

FP_SETUP_WINDOWS_TOOLCHAIN is abstracted from the location of the mingw
toolchain and also the eventual location where we will install the
toolchain in the installed bindist.

This is the first step towards #23608
parent 0bfa0031
No related branches found
No related tags found
No related merge requests found
......@@ -346,7 +346,8 @@ FP_FIND_ROOT
# Extract and configure the Windows toolchain
if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then
FP_SETUP_WINDOWS_TOOLCHAIN
FP_INSTALL_WINDOWS_TOOLCHAIN
FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/inplace/mingw], [$hardtop/inplace/mingw])
else
AC_PATH_TOOL([CC],[gcc], [clang])
AC_PATH_TOOL([CXX],[g++], [clang++])
......
......@@ -36,14 +36,15 @@ dnl ghc-toolchain.
# SUBST_TOOLDIR
# ----------------------------------
# $1 - the variable where to search for occurrences of the path to the
# distributed mingw, and update by substituting said occurrences by
# the literal '$tooldir/mingw'
# inplace mingw, and update by substituting said occurrences by
# the value of $mingw_install_prefix, where the mingw toolchain will be at
# install time
#
# See Note [How we configure the bundled windows toolchain]
AC_DEFUN([SUBST_TOOLDIR],
[
dnl and Note [How we configure the bundled windows toolchain]
$1=`echo $$1 | sed 's%'"$mingwpath"'%$$tooldir/mingw%'`
$1=`echo "$$1" | sed 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g'`
])
# FP_SETTINGS
......
AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
# Download and install the windows toolchain
AC_DEFUN([FP_INSTALL_WINDOWS_TOOLCHAIN],[
# Find the mingw-w64 archive file to extract.
if test "$HostArch" = "i386"
then
......@@ -72,18 +73,28 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
# NB. Download and extract the MingW-w64 distribution if required
set_up_tarballs
])
# Set up the environment variables
# $1 The actual location of the windows toolchain (before install)
# $2 the location that the windows toolchain will be installed in relative to the libdir
AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
# N.B. The parameters which get plopped in the `settings` file used by the
# resulting compiler are computed in `FP_SETTINGS`. Specifically, we use
# $$topdir-relative paths instead of fullpaths to the toolchain, by replacing
# occurrences of $hardtop/inplace/mingw with $$tooldir/mingw
mingw_prefix="$1"
mingw_install_prefix="$2"
# Our Windows toolchain is based around Clang and LLD. We use compiler-rt
# for the runtime, libc++ and libc++abi for the C++ standard library
# implementation, and libunwind for C++ unwinding.
mingwbin="$hardtop/inplace/mingw/bin/"
mingwlib="$hardtop/inplace/mingw/lib"
mingwinclude="$hardtop/inplace/mingw/include"
mingwpath="$hardtop/inplace/mingw"
mingwbin="$mingw_prefix/bin/"
mingwlib="$mingw_prefix/lib"
mingwinclude="$mingw_prefix/include"
mingw_mingw32_lib="$mingw_prefix/x86_64-w64-mingw32/lib"
CC="${mingwbin}clang.exe"
CXX="${mingwbin}clang++.exe"
......@@ -106,8 +117,8 @@ AC_DEFUN([FP_SETUP_WINDOWS_TOOLCHAIN],[
HaskellCPPArgs="$HaskellCPPArgs -I$mingwinclude"
CONF_GCC_LINKER_OPTS_STAGE1="-fuse-ld=lld $cflags -L$mingwlib -L$hardtop/inplace/mingw/x86_64-w64-mingw32/lib"
CONF_GCC_LINKER_OPTS_STAGE2="-fuse-ld=lld $cflags -L$mingwlib -L$hardtop/inplace/mingw/x86_64-w64-mingw32/lib"
CONF_GCC_LINKER_OPTS_STAGE1="-fuse-ld=lld $cflags -L$mingwlib -L$mingw_mingw32_lib"
CONF_GCC_LINKER_OPTS_STAGE2="-fuse-ld=lld $cflags -L$mingwlib -L$mingw_mingw32_lib"
# N.BOn Windows we can't easily dynamically-link against libc++ since there is
# no RPATH support, meaning that the loader will have no way of finding our
......
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