Rodrigo Mesquita pushed to branch wip/romes/24212 at Glasgow Haskell Compiler / GHC

Commits:

3 changed files:

Changes:

  • distrib/configure.ac.in
    ... ... @@ -417,6 +417,34 @@ AC_OUTPUT
    417 417
     
    
    418 418
     VALIDATE_GHC_TOOLCHAIN([default.target],[default.target.ghc-toolchain])
    
    419 419
     
    
    420
    +if test "$EnableDistroToolchain" = "YES"; then
    
    421
    +    # If the user specified --enable-distro-toolchain then we just use the
    
    422
    +    # executable names, not paths. We do this by finding strings of paths to
    
    423
    +    # programs and keeping the basename only:
    
    424
    +    cp default.target default.target.bak
    
    425
    +
    
    426
    +    while IFS= read -r line; do
    
    427
    +      if echo "$line" | grep -q 'prgPath = "'; then
    
    428
    +        path=$(echo "$line" | sed -E 's/.*prgPath = "([[^"]]+)".*/\1/')
    
    429
    +        base=$(basename "$path")
    
    430
    +        echo "$line" | sed "s|$path|$base|"
    
    431
    +      else
    
    432
    +        echo "$line"
    
    433
    +      fi
    
    434
    +    done < default.target.bak > default.target
    
    435
    +    echo "Applied --enable-distro-toolchain basename substitution to default.target:"
    
    436
    +    cat default.target
    
    437
    +fi
    
    438
    +
    
    439
    +if test "$windows" = YES -a "$EnableDistroToolchain" = "NO"; then
    
    440
    +    # Handle the Windows toolchain installed in FP_SETUP_WINDOWS_TOOLCHAIN.
    
    441
    +    # We need to issue a substitution to use $tooldir,
    
    442
    +    # See Note [tooldir: How GHC finds mingw on Windows]
    
    443
    +    SUBST_TOOLDIR([default.target])
    
    444
    +    echo "Applied tooldir substitution to default.target:"
    
    445
    +    cat default.target
    
    446
    +fi
    
    447
    +
    
    420 448
     rm -Rf acargs acghc-toolchain actmp-ghc-toolchain
    
    421 449
     
    
    422 450
     echo "****************************************************"
    

  • hadrian/bindist/Makefile
    ... ... @@ -87,6 +87,7 @@ lib/settings : config.mk
    87 87
     	@rm -f $@
    
    88 88
     	@echo '[("target os", "$(HaskellTargetOs)")' >> $@
    
    89 89
     	@echo ',("target arch", "$(HaskellTargetArch)")' >> $@
    
    90
    +	@echo ',("target has libm", "$(TargetHasLibm)")' >> $@
    
    90 91
     	@echo ',("unlit command", "$$topdir/../bin/$(CrossCompilePrefix)unlit")' >> $@
    
    91 92
     	@echo ',("target RTS linker only supports shared libraries", "$(TargetRTSLinkerOnlySupportsSharedLibs)")' >> $@
    
    92 93
     	@echo ',("Use interpreter", "$(GhcWithInterpreter)")' >> $@
    
    ... ... @@ -97,9 +98,10 @@ lib/settings : config.mk
    97 98
     	@echo ',("base unit-id", "$(BaseUnitId)")' >> $@
    
    98 99
     	@echo "]" >> $@
    
    99 100
     
    
    100
    -lib/targets/default.target : config.mk
    
    101
    +lib/targets/default.target : config.mk default.target
    
    101 102
     	@rm -f $@
    
    102
    -	@echo "DOING DEFAULT.TARGET"
    
    103
    +	@echo "Copying the bindist-configured default.target to lib/targets/default.target"
    
    104
    +	cp default.target $@
    
    103 105
     
    
    104 106
     # We need to install binaries relative to libraries.
    
    105 107
     BINARIES = $(wildcard ./bin/*)
    

  • m4/subst_tooldir.m4
    1
    +dnl Note [How we configure the bundled windows toolchain]
    
    2
    +dnl ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    3
    +dnl As per Note [tooldir: How GHC finds mingw on Windows], when using the
    
    4
    +dnl bundled windows toolchain, the GHC settings file must refer to the
    
    5
    +dnl toolchain through a path relative to $tooldir (binary distributions on
    
    6
    +dnl Windows should work without configure, so the paths must be relative to the
    
    7
    +dnl installation). However, hadrian expects the configured toolchain to use
    
    8
    +dnl full paths to the executable.
    
    9
    +dnl
    
    10
    +dnl This is how the bundled windows toolchain is configured, to define the
    
    11
    +dnl toolchain with paths to the executables, while still writing into GHC
    
    12
    +dnl settings the paths relative to $tooldir:
    
    13
    +dnl
    
    14
    +dnl * If using the bundled toolchain, FP_SETUP_WINDOWS_TOOLCHAIN will be invoked
    
    15
    +dnl
    
    16
    +dnl * FP_SETUP_WINDOWS_TOOLCHAIN will set the toolchain variables to paths
    
    17
    +dnl   to the bundled toolchain (e.g. CFLAGS=/full/path/to/mingw/bin/gcc)
    
    18
    +dnl
    
    19
    +dnl * Later on, at the end of distrib/configure.ac, we substitute occurrences of the path to the
    
    20
    +dnl   mingw tooldir by $tooldir (see SUBST_TOOLDIR).
    
    21
    +dnl   The reason is the Settings* variants of toolchain variables are used by the bindist configure to
    
    22
    +dnl   create the settings file, which needs the windows bundled toolchain to be relative to $tooldir.
    
    23
    +dnl
    
    24
    +dnl The ghc-toolchain program isn't concerned with any of these complications:
    
    25
    +dnl it is passed either the full paths to the toolchain executables, or the bundled
    
    26
    +dnl mingw path is set first on $PATH before invoking it. And ghc-toolchain
    
    27
    +dnl will, as always, output target files with full paths to the executables.
    
    28
    +dnl
    
    29
    +dnl Hadrian accounts for this as it does for the toolchain executables
    
    30
    +dnl configured by configure -- in fact, hadrian doesn't need to know whether
    
    31
    +dnl the toolchain description file was generated by configure or by
    
    32
    +dnl ghc-toolchain.
    
    33
    +
    
    34
    +# SUBST_TOOLDIR
    
    35
    +# ----------------------------------
    
    36
    +# $1 - the filepath where to search for occurrences of the path to the
    
    37
    +#      inplace mingw, and update by substituting said occurrences by
    
    38
    +#      the value of $mingw_install_prefix, where the mingw toolchain will be at
    
    39
    +#      install time
    
    40
    +#
    
    41
    +# See Note [How we configure the bundled windows toolchain]
    
    42
    +AC_DEFUN([SUBST_TOOLDIR],
    
    43
    +[
    
    44
    +    sed -i.bkp $1 's%'"$mingw_prefix"'%'"$mingw_install_prefix"'%g'
    
    45
    +])