[Git][ghc/ghc][wip/marge_bot_batch_merge_job] 12 commits: configure: Avoid hard-coded ld path on Windows

Marge Bot gitlab at gitlab.haskell.org
Sat Sep 5 13:30:58 UTC 2020



 Marge Bot pushed to branch wip/marge_bot_batch_merge_job at Glasgow Haskell Compiler / GHC


Commits:
07bdcac3 by GHC GitLab CI at 2020-09-04T22:26:25-04:00
configure: Avoid hard-coded ld path on Windows

The fix to #17962 ended up regressing on Windows as it failed to
replicate the logic responsible for overriding the toolchain paths on
Windows. This resulted in a hard-coded path to a directory that likely
doesn't exist on the user's system (#18550).

- - - - -
0be8e746 by Benjamin Maurer at 2020-09-04T22:27:01-04:00
Documented the as of yet undocumented '--print-*'  GHC flags,
as well as `-split-objs`, since that is related to
`--print-object-splitting-supported`.
See #18641

- - - - -
4813486f by Sylvain Henry at 2020-09-04T22:27:44-04:00
Move Hadrian's wiki pages in tree (fix #16165)

Only the debugging page contains interesting stuff. Some of this stuff
looks old (e.g. recommending "cabal install")...

- - - - -
a3662f63 by GHC GitLab CI at 2020-09-05T09:30:46-04:00
rts: Consistently use stgMallocBytes instead of malloc

This can help in debugging RTS memory leaks since all allocations go
through the same interface.

- - - - -
2c863773 by Ben Gamari at 2020-09-05T09:30:46-04:00
configure: Fix whitespace

- - - - -
37933ab5 by Ben Gamari at 2020-09-05T09:30:47-04:00
gitlab-ci: More intelligent detection of locale availability

Previously ci.sh would unconditionally use C.UTF-8. However, this fails
on Centos 7, which appears not to provide this locale. Now we first try
C.UTF-8, then try en_US.UTF-8, then fail.

Works around #18607.

- - - - -
57447690 by Ben Gamari at 2020-09-05T09:30:47-04:00
gitlab-ci: Rename RELEASE variable to RELEASE_JOB

This interfered with the autoconf variable of the same name, breaking
pre-release builds.

- - - - -
ea1c5571 by Ben Gamari at 2020-09-05T09:30:47-04:00
gitlab-ci: Bump Windows toolchain version

This should have been done when we bumped the bootstrap compiler to
8.8.4.

- - - - -
9211dba5 by Ben Gamari at 2020-09-05T09:30:47-04:00
gitlab-ci: Drop Windows make job

These are a significant burden on our CI resources and end up failing
quite often due to #18274. Here I drop the make jobs during
validaion; it is now run only during the nightly builds.

- - - - -
56bfc73d by Ben Gamari at 2020-09-05T09:30:47-04:00
testsuite: Drop Windows-specific output for parseTree

The normalise_slashes normaliser should handle this.

- - - - -
d8a96a79 by Ben Gamari at 2020-09-05T09:30:47-04:00
testsuite: Mark T5975[ab] as broken on Windows

Due to #7305.

- - - - -
2c5f7a35 by Ben Gamari at 2020-09-05T09:30:47-04:00
gitlab-ci: Fix typo

A small typo in a rule regular expression.

- - - - -


21 changed files:

- .gitlab-ci.yml
- .gitlab/ci.sh
- aclocal.m4
- compiler/GHC/Settings/IO.hs
- configure.ac
- docs/users_guide/codegens.rst
- docs/users_guide/expected-undocumented-flags.txt
- docs/users_guide/phases.rst
- docs/users_guide/using.rst
- hadrian/cfg/system.config.in
- + hadrian/doc/debugging.md
- hadrian/src/Builder.hs
- mk/config.mk.in
- rts/linker/PEi386.c
- rts/win32/IOManager.c
- rts/win32/OSThreads.c
- rts/win32/WorkQueue.c
- rts/xxhash.c
- rules/build-package-way.mk
- − testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32
- testsuite/tests/ghci/scripts/all.T


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -6,7 +6,7 @@ variables:
 
   # Sequential version number capturing the versions of all tools fetched by
   # .gitlab/ci.sh.
-  WINDOWS_TOOLCHAIN_VERSION: 1
+  WINDOWS_TOOLCHAIN_VERSION: 2
 
   # Disable shallow clones; they break our linting rules
   GIT_DEPTH: 0
@@ -49,7 +49,7 @@ workflow:
     - if: $CI_COMMIT_TAG
     - if: '$CI_COMMIT_BRANCH == "master"'
     - if: '$CI_COMMIT_BRANCH == "wip/marge_bot_batch_merge_job"'
-    - if: '$CI_COMMIT_BRANCH =~ /ghc-[0.9]+\.[0-9]+/'
+    - if: '$CI_COMMIT_BRANCH =~ /ghc-[0-9]+\.[0-9]+/'
     - if: '$CI_PIPELINE_SOURCE == "web"'
 
 .nightly: &nightly
@@ -67,7 +67,7 @@ workflow:
     when: always
     expire_in: 1 year
   rules:
-    - if: '$RELEASE == "yes"'
+    - if: '$RELEASE_JOB == "yes"'
 
 ############################################################
 # Runner Tags
@@ -896,9 +896,6 @@ validate-x86_64-windows-hadrian:
   cache:
     key: "x86_64-windows-$WINDOWS_TOOLCHAIN_VERSION"
 
-validate-x86_64-windows:
-  extends: .build-x86_64-windows-make
-
 nightly-x86_64-windows:
   <<: *nightly
   extends: .build-x86_64-windows-make
@@ -909,13 +906,13 @@ nightly-x86_64-windows:
 # Normal Windows validate builds are profiled; that won't do for releases.
 release-x86_64-windows:
   <<: *release
-  extends: validate-x86_64-windows
+  extends: .build-x86_64-windows-make
   variables:
     BUILD_FLAVOUR: "perf"
     #
 release-x86_64-windows-integer-simple:
   <<: *release
-  extends: validate-x86_64-windows
+  extends: .build-x86_64-windows-make
   variables:
     BIGNUM_BACKEND: native
     BUILD_FLAVOUR: "perf"
@@ -970,7 +967,7 @@ doc-tarball:
   image: "registry.gitlab.haskell.org/ghc/ci-images/x86_64-linux-deb9:$DOCKER_REV"
   dependencies:
     - validate-x86_64-linux-deb9-debug
-    - validate-x86_64-windows
+    - validate-x86_64-windows-hadrian
   variables:
     LINUX_BINDIST: "ghc-x86_64-deb9-linux-debug.tar.xz"
     WINDOWS_BINDIST: "ghc-x86_64-mingw32.tar.xz"


=====================================
.gitlab/ci.sh
=====================================
@@ -26,9 +26,6 @@ LT_CYAN="1;36"
 WHITE="1;37"
 LT_GRAY="0;37"
 
-export LANG=C.UTF-8
-export LC_ALL=C.UTF-8
-
 # GitLab Pipelines log section delimiters
 # https://gitlab.com/gitlab-org/gitlab-foss/issues/14664
 start_section() {
@@ -60,6 +57,30 @@ function run() {
 
 TOP="$(pwd)"
 
+function setup_locale() {
+  # BSD grep terminates early with -q, consequently locale -a will get a
+  # SIGPIPE and the pipeline will fail with pipefail.
+  shopt -o -u pipefail
+  if locale -a | grep -q C.UTF-8; then
+    # Debian
+    export LANG=C.UTF-8
+  elif locale -a | grep -q C.utf8; then
+    # Fedora calls it this
+    export LANG=C.utf8
+  elif locale -a | grep -q en_US.UTF-8; then
+    # Centos doesn't have C.UTF-8
+    export LANG=en_US.UTF-8
+  else
+    error "Failed to find usable locale"
+    info "Available locales:"
+    locale -a
+    fail "No usable locale, aborting..."
+  fi
+  info "Using locale $LANG..."
+  export LC_ALL=$LANG
+  shopt -o -s pipefail
+}
+
 function mingw_init() {
   case "$MSYSTEM" in
     MINGW32)
@@ -423,6 +444,8 @@ function shell() {
   run $cmd
 }
 
+setup_locale
+
 # Determine Cabal data directory
 case "$(uname)" in
   MSYS_*|MINGW*) exe=".exe"; cabal_dir="$APPDATA/cabal" ;;


=====================================
aclocal.m4
=====================================
@@ -532,6 +532,10 @@ AC_DEFUN([FP_SETTINGS],
         SettingsHaskellCPPCommand="${mingw_bin_prefix}gcc.exe"
         SettingsHaskellCPPFlags="$HaskellCPPArgs"
         SettingsLdCommand="${mingw_bin_prefix}ld.exe"
+        # Overrides FIND_MERGE_OBJECTS in order to avoid hard-coding linker
+        # path on Windows (#18550).
+        SettingsMergeObjectsCommand="${SettingsLdCommand}"
+        SettingsMergeObjectsFlags="-r --oformat=pe-bigobj-x86-64"
         SettingsArCommand="${mingw_bin_prefix}ar.exe"
         SettingsRanlibCommand="${mingw_bin_prefix}ranlib.exe"
         SettingsDllWrapCommand="${mingw_bin_prefix}dllwrap.exe"
@@ -545,6 +549,8 @@ AC_DEFUN([FP_SETTINGS],
         SettingsHaskellCPPCommand="$(basename $HaskellCPPCmd)"
         SettingsHaskellCPPFlags="$HaskellCPPArgs"
         SettingsLdCommand="$(basename $LdCmd)"
+        SettingsMergeObjectsCommand="$(basename $MergeObjsCmd)"
+        SettingsMergeObjectsFlags="$MergeObjsArgs"
         SettingsArCommand="$(basename $ArCmd)"
         SettingsDllWrapCommand="$(basename $DllWrapCmd)"
         SettingsWindresCommand="$(basename $WindresCmd)"
@@ -554,6 +560,8 @@ AC_DEFUN([FP_SETTINGS],
         SettingsHaskellCPPCommand="$HaskellCPPCmd"
         SettingsHaskellCPPFlags="$HaskellCPPArgs"
         SettingsLdCommand="$LdCmd"
+        SettingsMergeObjectsCommand="$MergeObjsCmd"
+        SettingsMergeObjectsFlags="$MergeObjsArgs"
         SettingsArCommand="$ArCmd"
         SettingsRanlibCommand="$RanlibCmd"
         if test -z "$DllWrapCmd"
@@ -609,6 +617,8 @@ AC_DEFUN([FP_SETTINGS],
     AC_SUBST(SettingsCCompilerSupportsNoPie)
     AC_SUBST(SettingsLdCommand)
     AC_SUBST(SettingsLdFlags)
+    AC_SUBST(SettingsMergeObjectsCommand)
+    AC_SUBST(SettingsMergeObjectsFlags)
     AC_SUBST(SettingsArCommand)
     AC_SUBST(SettingsRanlibCommand)
     AC_SUBST(SettingsDllWrapCommand)
@@ -1617,37 +1627,37 @@ AC_SUBST([GccExtraViaCOpts],$fp_cv_gcc_extra_opts)
 # ---------------------
 AC_DEFUN([FP_SETUP_PROJECT_VERSION],
 [
-if test "$RELEASE" = "NO"; then
-    AC_MSG_CHECKING([for GHC version date])
-    if test -f VERSION_DATE; then
-        PACKAGE_VERSION=${PACKAGE_VERSION}.`cat VERSION_DATE`
-        AC_MSG_RESULT(given $PACKAGE_VERSION)
-    elif test -e .git; then
-        changequote(, )dnl
-        ver_posixtime=`git log -1 --pretty=format:%ct`
-        ver_date=`perl -MPOSIX -e "print strftime('%Y%m%d', gmtime($ver_posixtime));"`
-        if echo $ver_date | grep '^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' 2>&1 >/dev/null; then true; else
-        changequote([, ])dnl
-                AC_MSG_ERROR([failed to detect version date: check that git and perl are in your path])
+    if test "$RELEASE" = "NO"; then
+        AC_MSG_CHECKING([for GHC version date])
+        if test -f VERSION_DATE; then
+            PACKAGE_VERSION=${PACKAGE_VERSION}.`cat VERSION_DATE`
+            AC_MSG_RESULT(given $PACKAGE_VERSION)
+        elif test -e .git; then
+            changequote(, )dnl
+            ver_posixtime=`git log -1 --pretty=format:%ct`
+            ver_date=`perl -MPOSIX -e "print strftime('%Y%m%d', gmtime($ver_posixtime));"`
+            if echo $ver_date | grep '^[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$' 2>&1 >/dev/null; then true; else
+            changequote([, ])dnl
+                    AC_MSG_ERROR([failed to detect version date: check that git and perl are in your path])
+            fi
+            PACKAGE_VERSION=${PACKAGE_VERSION}.$ver_date
+            AC_MSG_RESULT(inferred $PACKAGE_VERSION)
+        elif test -f VERSION; then
+            PACKAGE_VERSION=`cat VERSION`
+            AC_MSG_RESULT(given $PACKAGE_VERSION)
+        else
+            AC_MSG_WARN([cannot determine snapshot version: no .git directory and no VERSION file])
+            dnl We'd really rather this case didn't happen, but it might
+            dnl do (in particular, people using lndir trees may find that
+            dnl the build system can't find any other date). If it does
+            dnl happen, then we use the current date.
+            dnl This way we get some idea about how recent a build is.
+            dnl It also means that packages built for 2 different builds
+            dnl will probably use different version numbers, so things are
+            dnl less likely to go wrong.
+            PACKAGE_VERSION=${PACKAGE_VERSION}.`date +%Y%m%d`
         fi
-        PACKAGE_VERSION=${PACKAGE_VERSION}.$ver_date
-        AC_MSG_RESULT(inferred $PACKAGE_VERSION)
-    elif test -f VERSION; then
-        PACKAGE_VERSION=`cat VERSION`
-        AC_MSG_RESULT(given $PACKAGE_VERSION)
-    else
-        AC_MSG_WARN([cannot determine snapshot version: no .git directory and no VERSION file])
-        dnl We'd really rather this case didn't happen, but it might
-        dnl do (in particular, people using lndir trees may find that
-        dnl the build system can't find any other date). If it does
-        dnl happen, then we use the current date.
-        dnl This way we get some idea about how recent a build is.
-        dnl It also means that packages built for 2 different builds
-        dnl will probably use different version numbers, so things are
-        dnl less likely to go wrong.
-        PACKAGE_VERSION=${PACKAGE_VERSION}.`date +%Y%m%d`
     fi
-fi
 
     AC_MSG_CHECKING([for GHC Git commit id])
     if test -e .git; then
@@ -1666,54 +1676,54 @@ fi
     fi
 
 
-# Some renamings
-AC_SUBST([ProjectName], [$PACKAGE_NAME])
-AC_SUBST([ProjectVersion], [$PACKAGE_VERSION])
-AC_SUBST([ProjectGitCommitId], [$PACKAGE_GIT_COMMIT_ID])
+    # Some renamings
+    AC_SUBST([ProjectName], [$PACKAGE_NAME])
+    AC_SUBST([ProjectVersion], [$PACKAGE_VERSION])
+    AC_SUBST([ProjectGitCommitId], [$PACKAGE_GIT_COMMIT_ID])
 
-# Split PACKAGE_VERSION into (possibly empty) parts
-VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
-VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
-VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
-ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
+    # Split PACKAGE_VERSION into (possibly empty) parts
+    VERSION_MAJOR=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
+    VERSION_TMP=`echo $PACKAGE_VERSION | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
+    VERSION_MINOR=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1'/`
+    ProjectPatchLevel=`echo $VERSION_TMP | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3'/`
 
-# Calculate project version as an integer, using 2 digits for minor version
-case $VERSION_MINOR in
-  ?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;
-  ??) ProjectVersionInt=${VERSION_MAJOR}${VERSION_MINOR} ;;
-  *) AC_MSG_ERROR([bad minor version in $PACKAGE_VERSION]) ;;
-esac
-AC_SUBST([ProjectVersionInt])
+    # Calculate project version as an integer, using 2 digits for minor version
+    case $VERSION_MINOR in
+      ?) ProjectVersionInt=${VERSION_MAJOR}0${VERSION_MINOR} ;;
+      ??) ProjectVersionInt=${VERSION_MAJOR}${VERSION_MINOR} ;;
+      *) AC_MSG_ERROR([bad minor version in $PACKAGE_VERSION]) ;;
+    esac
+    AC_SUBST([ProjectVersionInt])
 
-# The project patchlevel is zero unless stated otherwise
-test -z "$ProjectPatchLevel" && ProjectPatchLevel=0
+    # The project patchlevel is zero unless stated otherwise
+    test -z "$ProjectPatchLevel" && ProjectPatchLevel=0
 
-# Save split version of ProjectPatchLevel
-ProjectPatchLevel1=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1/'`
-ProjectPatchLevel2=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3/'`
+    # Save split version of ProjectPatchLevel
+    ProjectPatchLevel1=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\1/'`
+    ProjectPatchLevel2=`echo $ProjectPatchLevel | sed 's/^\(@<:@^.@:>@*\)\(\.\{0,1\}\(.*\)\)$/\3/'`
 
-AC_SUBST([ProjectPatchLevel1])
-AC_SUBST([ProjectPatchLevel2])
+    AC_SUBST([ProjectPatchLevel1])
+    AC_SUBST([ProjectPatchLevel2])
 
-# Remove dots from the patch level; this allows us to have versions like 6.4.1.20050508
-ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'`
+    # Remove dots from the patch level; this allows us to have versions like 6.4.1.20050508
+    ProjectPatchLevel=`echo $ProjectPatchLevel | sed 's/\.//'`
 
-AC_SUBST([ProjectPatchLevel])
+    AC_SUBST([ProjectPatchLevel])
 
-# The version of the GHC package changes every day, since the
-# patchlevel is the current date.  We don't want to force
-# recompilation of the entire compiler when this happens, so for
-# GHC HEAD we omit the patchlevel from the package version number.
-#
-# The ProjectPatchLevel1 > 20000000 iff GHC HEAD. If it's for a stable
-# release like 7.10.1 or for a release candidate such as 7.10.1.20141224
-# then we don't omit the patchlevel components.
+    # The version of the GHC package changes every day, since the
+    # patchlevel is the current date.  We don't want to force
+    # recompilation of the entire compiler when this happens, so for
+    # GHC HEAD we omit the patchlevel from the package version number.
+    #
+    # The ProjectPatchLevel1 > 20000000 iff GHC HEAD. If it's for a stable
+    # release like 7.10.1 or for a release candidate such as 7.10.1.20141224
+    # then we don't omit the patchlevel components.
 
-ProjectVersionMunged="$ProjectVersion"
-if test "$ProjectPatchLevel1" -gt 20000000; then
-  ProjectVersionMunged="${VERSION_MAJOR}.${VERSION_MINOR}"
-fi
-AC_SUBST([ProjectVersionMunged])
+    ProjectVersionMunged="$ProjectVersion"
+    if test "$ProjectPatchLevel1" -gt 20000000; then
+      ProjectVersionMunged="${VERSION_MAJOR}.${VERSION_MINOR}"
+    fi
+    AC_SUBST([ProjectVersionMunged])
 ])# FP_SETUP_PROJECT_VERSION
 
 # Check for a working timer_create().  We need a pretty detailed check
@@ -2625,7 +2635,7 @@ AC_DEFUN([CHECK_FOR_GOLD_T22266],[
         ])
 
         $CC -c -o conftest.a.o conftest.a.c || AC_MSG_ERROR([Failed to compile test])
-        $SettingsMergeObjectsCommand $SettingsMergeObjectsFlags -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object])
+        $MergeObjsCmd $MergeObjsArgs -T conftest.t conftest.a.o -o conftest.ar.o || AC_MSG_ERROR([Failed to merge test object])
 
         $CC -c -o conftest.main.o conftest.main.c || AC_MSG_ERROR([Failed to compile test driver])
         $CC conftest.ar.o conftest.main.o -o conftest || AC_MSG_ERROR([Failed to link test driver])
@@ -2645,33 +2655,30 @@ AC_DEFUN([CHECK_FOR_GOLD_T22266],[
 # ------------------
 # Find which linker to use to merge object files.
 #
+# See Note [Merging object files for GHCi] in GHC.Driver.Pipeline.
 AC_DEFUN([FIND_MERGE_OBJECTS],[
     AC_REQUIRE([FIND_LD])
 
-    if test -z "$SettingsMergeObjectsCommand"; then
-        SettingsMergeObjectsCommand="$LD"
+    if test -z "$MergeObjsCmd"; then
+        MergeObjsCmd="$LD"
     fi
-    if test -z "$SettingsMergeObjectsFlags"; then
-        SettingsMergeObjectsFlags="-r"
+    if test -z "$MergeObjsArgs"; then
+        MergeObjsArgs="-r"
     fi
 
-    CHECK_FOR_GOLD_T22266($SettingsMergeObjectsCommand)
+    CHECK_FOR_GOLD_T22266($MergeObjsCmd)
     if test "$result" = "1"; then
-        AC_MSG_NOTICE([$SettingsMergeObjectsCommand is broken due to binutils 22266, looking for another linker...])
-        SettingsMergeObjectsCommand=""
-        AC_CHECK_TARGET_TOOL([SettingsMergeObjectsCommand], [ld])
-        CHECK_FOR_GOLD_T22266($SettingsMergeObjectsCommand)
+        AC_MSG_NOTICE([$MergeObjsCmd is broken due to binutils 22266, looking for another linker...])
+        MergeObjsCmd=""
+        AC_CHECK_TARGET_TOOL([MergeObjsCmd], [ld])
+        CHECK_FOR_GOLD_T22266($MergeObjsCmd)
         if test "$result" = "1"; then
-            AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the SettingsMergeObjectsCommand variable to a functional linker.])
+            AC_MSG_ERROR([Linker is affected by binutils 22266 but couldn't find another unaffected linker. Please set the MergeObjsCmd variable to a functional linker.])
         fi
     fi
 
-    if test "$windows" = YES -a "$EnableDistroToolchain" = "NO" -a "$WORD_SIZE" = 64; then
-        SettingsMergeObjectsFlags="$SettingsMergeObjectsFlags --oformat=pe-bigobj-x86-64"
-    fi
-
-    AC_SUBST(SettingsMergeObjectsCommand)
-    AC_SUBST(SettingsMergeObjectsFlags)
+    AC_SUBST([MergeObjsCmd])
+    AC_SUBST([MergeObjsArgs])
 ])
 
 # FIND_PYTHON


=====================================
compiler/GHC/Settings/IO.hs
=====================================
@@ -137,7 +137,7 @@ initSettings top_dir = do
         as_args  = map Option cc_args
         ld_prog  = cc_prog
         ld_args  = map Option (cc_args ++ words cc_link_args_str)
-  ld_r_prog <- getSetting "Merge objects command"
+  ld_r_prog <- getToolSetting "Merge objects command"
   ld_r_args <- getSetting "Merge objects flags"
 
   llvmTarget <- getSetting "LLVM target"


=====================================
configure.ac
=====================================
@@ -449,6 +449,8 @@ then
     NM="${mingwbin}nm.exe"
     RANLIB="${mingwbin}ranlib.exe"
     OBJDUMP="${mingwbin}objdump.exe"
+    MergeObjsCmd="$LD"
+    MergeObjsArgs="-r --oformat=pe-bigobj-x86-64"
     fp_prog_ar="${mingwbin}ar.exe"
 
     AC_PATH_PROG([Genlib],[genlib])


=====================================
docs/users_guide/codegens.rst
=====================================
@@ -124,4 +124,5 @@ to build GHC with the appropriate options set. Consult the GHC Building
 Guide for details.
 
 You can check if your GHC is unregisterised by calling
+``ghc --print-unregisterised`` (see :ghc-flag:`--print-unregisterised`) or
 ``ghc --info`` (see :ghc-flag:`--info`).


=====================================
docs/users_guide/expected-undocumented-flags.txt
=====================================
@@ -1,26 +1,6 @@
 -#include
 --abi-hash
 --backpack
---print-booter-version
---print-build-platform
---print-c-compiler-flags
---print-c-compiler-link-flags
---print-debug-on
---print-global-package-db
---print-have-interpreter
---print-have-native-code-generator
---print-host-platform
---print-ld-flags
---print-leading-underscore
---print-object-splitting-supported
---print-project-git-commit-id
---print-project-version
---print-rts-ways
---print-stage
---print-support-smp
---print-tables-next-to-code
---print-target-platform
---print-unregisterised
 --show-packages
 -Onot
 -Wall-missed-specializations
@@ -161,7 +141,6 @@
 -rtsopts=none
 -rtsopts=some
 -smp
--split-objs
 -syslib
 -this-component-id
 -ticky-LNE


=====================================
docs/users_guide/phases.rst
=====================================
@@ -675,6 +675,19 @@ Options affecting code generation
     and ``-dynhisuf`` are the counterparts of ``-o``, ``-osuf``, and
     ``-hisuf`` respectively, but applying to the dynamic compilation.
 
+.. ghc-flag:: -split-objs
+    :shortdesc: Split generated object files into smaller files
+    :type: dynamic
+    :category: codegen
+
+    When using this option, the object file is split into many smaller objects.
+    This feature is used when building libraries, so that a program statically
+    linked against the library will pull in less of the library.
+
+    Since this uses platform specific techniques, it may not be available on
+    all target platforms. See the :ghc-flag:`--print-object-splitting-supported`
+    flag to check whether your GHC supports object splitting.
+
 .. _options-linker:
 
 Options affecting linking


=====================================
docs/users_guide/using.rst
=====================================
@@ -420,6 +420,101 @@ The available mode flags are:
 
     Print GHC's numeric version number only.
 
+.. ghc-flag:: --print-booter-version
+    :shortdesc: display bootstrap compiler version
+    :type: mode
+    :category: modes
+
+    Print the numeric version of the GHC binary used to
+    bootstrap the build of this compiler.
+
+.. ghc-flag:: --print-build-platform
+    :shortdesc: display platform on which GHC was built
+    :type: mode
+    :category: modes
+
+    Print the target string of the build platform, on which GHC was built,
+    as generated by GNU Autotools.
+    The format is ``cpu-manufacturer-operating_system-(kernel)``, e.g.,
+    ``x86_64-unknown-linux``.
+
+.. ghc-flag:: --print-c-compiler-flags
+    :shortdesc: C compiler flags used to build GHC
+    :type: mode
+    :category: modes
+
+    List the flags passed to the C compiler during GHC build.
+
+.. ghc-flag:: --print-c-compiler-link-flags
+    :shortdesc: C linker flags used to build GHC
+    :type: mode
+    :category: modes
+
+    List the flags passed to the C compiler for the linking step
+    during GHC build.
+
+.. ghc-flag:: --print-debug-on
+    :shortdesc: print whether GHC was built with ``-DDEBUG``
+    :type: mode
+    :category: modes
+
+    Print ``True`` if GHC was built with ``-DDebug`` flag.
+    This enables assertions and extra debug code.
+    The flag can be set in ``GhcStage1HcOpts`` and/or ``GhcStage2HcOpts``
+    and is automatically set for ``devel1`` and ``devel2`` build flavors.
+
+.. ghc-flag:: --print-global-package-db
+    :shortdesc: display GHC's global package database directory
+    :type: mode
+    :category: modes
+
+    Print the path to GHC's global package database directory.
+    A package database stores details about installed packages as a directory
+    containing a file for each package.
+    This flag prints the path to the global database shipped with GHC, and
+    looks something like ``/usr/lib/ghc/package.conf.d`` on Unix.
+    There may be other package databases, e.g., the user package databse.
+    For more details see :ref:`package-databases`.
+
+.. ghc-flag:: --print-have-interpreter
+    :shortdesc: display whether GHC was built with interactive support
+    :type: mode
+    :category: modes
+
+    Print ``YES`` if GHC was compiled to include the interpreter, ``NO`` otherwise.
+    If this GHC does not have the interpreter included, running it in interactive
+    mode (see :ghc-flag:`--interactive`) will throw an error.
+    This only pertains the use of GHC interactively, not any separate GHCi binaries
+    (see :ref:`ghci`).
+
+.. ghc-flag:: --print-have-native-code-generator
+    :shortdesc: display whether target platform has NCG support
+    :type: mode
+    :category: modes
+
+    Print ``YES`` if native code generator supports the target platform,
+    ``NO`` otherwise.
+    (See :ref:`native-code-gen`)
+
+.. ghc-flag:: --print-host-platform
+    :shortdesc: display host platform of GHC
+    :type: mode
+    :category: modes
+
+    Print the target string of the host platform, i.e.,
+    the one on which GHC is supposed to run, as generated by GNU Autotools.
+    The format is ``cpu-manufacturer-operating_system-(kernel)``, e.g.,
+    ``x86_64-unknown-linux``.
+
+.. ghc-flag:: --print-leading-underscore
+    :shortdesc: display use of leading underscores on symbol names
+    :type: mode
+    :category: modes
+
+    Print ``YES`` if GHC was compiled to use symbols with leading underscores
+    in object files, ``NO`` otherwise.
+    This is usually atarget platform dependent.
+
 .. ghc-flag:: --print-libdir
     :shortdesc: display GHC library directory
     :type: mode
@@ -434,6 +529,106 @@ The available mode flags are:
     This is the value of ``$libdir`` in the package
     configuration file (see :ref:`packages`).
 
+.. ghc-flag:: --print-ld-flags
+    :shortdesc: display linker flags used to compile GHC
+    :type: mode
+    :category: modes
+
+    Print linke flags used to compile GHC.
+
+.. ghc-flag:: --print-object-splitting-supported
+    :shortdesc: display whether GHC supports object splitting
+    :type: mode
+    :category: modes
+
+    Print ``YES`` if GHC was compiled with support for splitting generated
+    object files into smaller objects, ``NO`` otherwise.
+    This feature uses platform specific techniques and may not be available on
+    all platforms.
+    See :ghc-flag:`-split-objs` for details.
+
+.. ghc-flag:: --print-project-git-commit-id
+    :shortdesc: display Git commit id GHC is built from
+    :type: mode
+    :category: modes
+
+    Print the Git commit id from which this GHC was built.
+    This can be used to trace the current binary back to a specific
+    revision, which is especially useful during development on GHC itself.
+    It is set by the configure script.
+
+.. ghc-flag:: --print-project-version
+    :shortdesc: display GHC version
+    :type: mode
+    :category: modes
+
+    Print the version set in the configure script during build.
+    This is simply the GHC version.
+
+.. ghc-flag:: --print-rts-ways
+    :shortdesc: display which way RTS was built
+    :type: mode
+    :category: modes
+
+    Packages, like the Runtime System, can be built in a number of ways:
+    - profiling - with profiling support
+    - dynamic - with dynamic linking
+    - logging - RTS event logging
+    - threaded - mulithreaded RTS
+    - debug - RTS with debug information
+
+    Various combinations of these flavours are possible.
+
+.. ghc-flag:: --print-stage
+    :shortdesc: display ``stage`` number of GHC
+    :type: mode
+    :category: modes
+
+    GHC is built using GHC itself and this build happens in stages,
+    which are numbered.
+
+    - Stage 0 is the GHC you have installed.  The "GHC you have installed" is also called "the bootstrap compiler".
+    - Stage 1 is the first GHC we build, using stage 0.  Stage 1 is then used to build the packages.
+    - Stage 2 is the second GHC we build, using stage 1.  This is the one we normally install when you say make install.
+    - Stage 3 is optional, but is sometimes built to test stage 2.
+
+    Stage 1 does not support interactive execution (GHCi) and Template Haskell.
+
+.. ghc-flag:: --print-support-smp
+    :shortdesc: display whether GHC was compiled with SMP support
+    :type: mode
+    :category: modes
+
+    Print ``YES`` if GHC was built with multiporcessor support, ``NO`` otherwise.
+
+.. ghc-flag:: --print-tables-next-to-code
+    :shortdesc: display whether GHC was compiled with ``--enable-tables-next-to-code``
+    :type: mode
+    :category: modes
+
+    Print ``YES`` if GHC was built with the flag ``--enable-tables-next-to-code``, ``NO`` otherwise.
+    This option is on by default, as it generates a more efficient code layout.
+
+.. ghc-flag:: --print-target-platform
+    :shortdesc: display target platform of GHC
+    :type: mode
+    :category: modes
+
+    Print the target string of the target platform, i.e.,
+    the one on which generated binaries will run, as generated by GNU Autotools.
+    The format is ``cpu-manufacturer-operating_system-(kernel)``, e.g.,
+    ``x86_64-unknown-linux``.
+
+.. ghc-flag:: --print-unregisterised
+    :shortdesc: display whether this GHC was built in unregisterised mode
+    :type: mode
+    :category: modes
+
+    Print ``YES`` if this GHC was built in unregisterised mode, ``NO`` otherwise.
+    "Unregisterised" means that GHC will disable most platform-specific tricks
+    and optimisations. Only the LLVM and C code generators will be available.
+    See :ref:`unreg` for more details.
+
 .. _make-mode:
 
 Using ``ghc`` ``--make``


=====================================
hadrian/cfg/system.config.in
=====================================
@@ -14,6 +14,7 @@ hs-cpp         = @HaskellCPPCmd@
 ld             = @LdCmd@
 make           = @MakeCmd@
 nm             = @NmCmd@
+merge-objects  = @MergeObjsCmd@
 objdump        = @ObjdumpCmd@
 ranlib         = @REAL_RANLIB_CMD@
 sphinx-build   = @SPHINXBUILD@
@@ -117,10 +118,10 @@ conf-ld-linker-args-stage1  = @CONF_LD_LINKER_OPTS_STAGE1@
 conf-ld-linker-args-stage2  = @CONF_LD_LINKER_OPTS_STAGE2@
 conf-ld-linker-args-stage3  = @CONF_LD_LINKER_OPTS_STAGE3@
 
-conf-merge-objects-args-stage0  = @SettingsMergeObjectsFlags@
-conf-merge-objects-args-stage1  = @SettingsMergeObjectsFlags@
-conf-merge-objects-args-stage2  = @SettingsMergeObjectsFlags@
-conf-merge-objects-args-stage3  = @SettingsMergeObjectsFlags@
+conf-merge-objects-args-stage0  = @MergeObjsArgs@
+conf-merge-objects-args-stage1  = @MergeObjsArgs@
+conf-merge-objects-args-stage2  = @MergeObjsArgs@
+conf-merge-objects-args-stage3  = @MergeObjsArgs@
 
 
 # Settings:


=====================================
hadrian/doc/debugging.md
=====================================
@@ -0,0 +1,104 @@
+## General tips on debugging Haskell
+
+https://wiki.haskell.org/Debugging
+
+## General tips on debugging shake
+
+http://shakebuild.com/debugging
+
+## Make-based old system
+
+1. `make show! VALUE=$(NAME)$` to check the value of variable `NAME`
+
+## Debugging Hadrian
+
+### General thoughts
+
+1. If a build command with some flags doesn't work, will that work on the Make-based old system? (Note that the directory structure is different, so we need to do some conversion)
+2. If you delete something, but run top-level target again doesn't produce that, then it must be that this things is not correctly registered as tracked output
+
+### Verbosity
+
+Adding `-V`, `-VV`, `-VVV` can output more information from Shake and Hadrian for debugging purpose. For example, to print out the complete commands, you can use `-V`.
+
+### Common pitfalls
+
+- Out-of-date `UserSetting.hs`? (may cause compilation errors while building hadrian itself)
+- Path: absolute? relative? platform-dependent?
+- Missing environment variables?
+- The upstream GHC/Cabal/... has updated
+
+### How to read exception message
+
+#### Type 1: `openFile: does not exist`
+
+**Example:** `hadrian: _build/stage1/ghc/GHCi/UI.o: openFile: does not exist (No such file or directory)`
+
+**Cause:** The build system tries to execute some *raw* I/O operation, which is not captured properly by shake build or any other handling mechanism.
+
+**Solution:** Use shake-provided or `Util`-provided I/O actions which can automatically make input files *dependencies*, and throw better exception (like below) when no rule for building these files exists.
+
+#### Type 2: `Error when running Shake build system:`
+
+Example:
+
+```
+Error when running Shake build system:
+* OracleQ (PackageDataKey ("_build/stage1/libraries/unix/package-data.mk","COMPONENT_ID"))
+* _build/stage1/libraries/unix/package-data.mk
+* OracleQ (PackageDataKey ("_build/stage1/libraries/base/package-data.mk","COMPONENT_ID"))
+* _build/stage1/libraries/base/package-data.mk
+* OracleQ (PackageDataKey ("_build/stage1/libraries/ghc-prim/package-data.mk","COMPONENT_ID"))
+* _build/stage1/libraries/ghc-prim/package-data.mk
+* _build/stage1/libraries/ghc-prim/GHC/Prim.hs
+* inplace/bin/genprimopcode
+* OracleQ (PackageDataKey ("_build/stage0/utils/genprimopcode/package-data.mk","C_SRCS"))
+* _build/stage0/utils/genprimopcode/package-data.mk
+user error (Development.Shake.cmd, system command failed
+Command: _build/stage0/utils/ghc-cabal/ghc-cabal configure utils/genprimopcode /Users/zz/Repos/ghc2/_build/stage0/utils/genprimopcode '' --with-ghc=/usr/local/bin/ghc --with-ghc-pkg=/usr/local/bin/ghc-pkg --package-db=_build/stage0/bootstrapping.conf --enable-library-vanilla --enable-library-for-ghci --disable-library-profiling --disable-shared --with-hscolour=/Users/zz/Library/Haskell/bin/HsColour '--configure-option=CFLAGS=-fno-stack-protector -I/Users/zz/Repos/ghc2/_build/generated' --configure-option=CPPFLAGS=-I_build/generated '--gcc-options=-fno-stack-protector -I/Users/zz/Repos/ghc2/_build/generated' --configure-option=--with-cc=/usr/bin/gcc --constraint 'Cabal == 2.0.0.0' --constraint 'binary == 0.8.4.1' --constraint 'ghc-boot == 8.3' --constraint 'ghc-boot-th == 8.3' --constraint 'ghci == 8.3' --constraint 'hoopl == 3.10.2.2' --constraint 'hpc == 0.6.0.3' --constraint 'template-haskell == 2.12.0.0' --constraint 'terminfo == 0.4.1.0' --constraint 'transformers == 0.5.2.0' --with-gcc=/usr/bin/gcc --with-ar=/usr/bin/ar --with-alex=/Users/zz/Library/Haskell/bin/alex --with-happy=/Users/zz/Library/Haskell/bin/happy -v0 --configure-option=--quiet --configure-option=--disable-option-checking
+Exit code: 1
+Stderr:
+ghc-cabal: ghc-pkg dump failed: dieVerbatim: user error (ghc-cabal:
+'/usr/local/bin/ghc-pkg' exited with an error:
+ghc-pkg: _build/stage0/bootstrapping.conf: getDirectoryContents: does not
+exist (No such file or directory)
+)
+)
+```
+
+First, the list of `OracleQ`s is similar to a call trace. Each `OracleQ` line specifies the *target*, and lines without `OracleQ` after it specify dependencies. Each dependency is the *target* of the next level.
+
+The last level's target in the above example is `_build/stage0/utils/genprimopcode/package-data.mk`. Build system tries to build it with the command as shown in `Command` line (this is very useful -- since you can copy & paste and tweak with it directly when trying find the right rule).
+
+The error dumped after the `Command` line can help you identify the potential bug quickly.
+
+### Run some snippets
+
+Sometimes it is useful to run a few lines of code for debugging purpose, for example, print out the dependencies of `cabal`. The fastest way to do this is to modify the `Main.hs`, comment out the heavy-lifting rules, add insert the code you'd like to run.
+
+```haskell
+        Rules.Clean.cleanRules
+        Rules.Oracles.oracleRules
+        -- Rules.SourceDist.sourceDistRules
+        -- Rules.Selftest.selftestRules
+        -- Rules.Test.testRules
+        -- Rules.buildRules
+        -- Rules.topLevelTargets
+        rulesToTest
+```
+
+## How to enable stack trace
+
+first, build shake with profile support:
+
+```
+# inside shake source directory
+cabal install --enable-profiling
+```
+
+```
+# for an example source file
+cabal exec -- ghc -prof -fprof-auto examples/Main.hs
+```
+
+and a work-in-progress [traced fork of shake](https://github.com/monad-systems/shake/tree/traced)


=====================================
hadrian/src/Builder.hs
=====================================
@@ -317,7 +317,7 @@ systemBuilderPath builder = case builder of
     Happy           -> fromKey "happy"
     HsCpp           -> fromKey "hs-cpp"
     Ld _            -> fromKey "ld"
-    MergeObjects _  -> fromKey "settings-merge-objects-command"
+    MergeObjects _  -> fromKey "merge-objects"
     Make _          -> fromKey "make"
     Makeinfo        -> fromKey "makeinfo"
     Nm              -> fromKey "nm"


=====================================
mk/config.mk.in
=====================================
@@ -545,6 +545,16 @@ LD_STAGE1       = $(LD)
 LD_STAGE2       = $(LD)
 LD_STAGE3       = $(LD)
 
+MERGE_OBJS_STAGE0 = @MergeObjsCmd@
+MERGE_OBJS_STAGE1 = @MergeObjsCmd@
+MERGE_OBJS_STAGE2 = @MergeObjsCmd@
+MERGE_OBJS_STAGE3 = @MergeObjsCmd@
+
+MERGE_OBJS_STAGE0_FLAGS = @MergeObjsArgs@
+MERGE_OBJS_STAGE1_FLAGS = @MergeObjsArgs@
+MERGE_OBJS_STAGE2_FLAGS = @MergeObjsArgs@
+MERGE_OBJS_STAGE3_FLAGS = @MergeObjsArgs@
+
 # Cross-compiling options
 # See Note [CrossCompiling vs Stage1Only]
 CrossCompiling        = @CrossCompiling@


=====================================
rts/linker/PEi386.c
=====================================
@@ -735,7 +735,7 @@ addDLL_PEi386( pathchar *dll_name, HINSTANCE *loaded )
 error:
     stgFree(buf);
 
-    char* errormsg = malloc(sizeof(char) * 80);
+    char* errormsg = stgMallocBytes(sizeof(char) * 80, "addDLL_PEi386");
     snprintf(errormsg, 80, "addDLL: %" PATH_FMT " or dependencies not loaded. (Win32 error %lu)", dll_name, GetLastError());
     /* LoadLibrary failed; return a ptr to the error msg. */
     return errormsg;
@@ -745,7 +745,7 @@ pathchar* findSystemLibrary_PEi386( pathchar* dll_name )
 {
     const unsigned int init_buf_size = 1024;
     unsigned int bufsize             = init_buf_size;
-    wchar_t* result = malloc(sizeof(wchar_t) * bufsize);
+    wchar_t* result = stgMallocBytes(sizeof(wchar_t) * bufsize, "findSystemLibrary_PEi386");
     DWORD wResult   = SearchPathW(NULL, dll_name, NULL, bufsize, result, NULL);
 
     if (wResult > bufsize) {
@@ -755,7 +755,7 @@ pathchar* findSystemLibrary_PEi386( pathchar* dll_name )
 
 
     if (!wResult) {
-        free(result);
+        stgFree(result);
         return NULL;
     }
 
@@ -773,7 +773,7 @@ HsPtr addLibrarySearchPath_PEi386(pathchar* dll_path)
     int bufsize                      = init_buf_size;
 
     // Make sure the path is an absolute path
-    WCHAR* abs_path = malloc(sizeof(WCHAR) * init_buf_size);
+    WCHAR* abs_path = stgMallocBytes(sizeof(WCHAR) * init_buf_size, "addLibrarySearchPath_PEi386(1)");
     DWORD wResult = GetFullPathNameW(dll_path, bufsize, abs_path, NULL);
     if (!wResult){
         IF_DEBUG(linker, debugBelch("addLibrarySearchPath[GetFullPathNameW]: %" PATH_FMT " (Win32 error %lu)", dll_path, GetLastError()));
@@ -791,7 +791,7 @@ HsPtr addLibrarySearchPath_PEi386(pathchar* dll_path)
     else
     {
         warnMissingKBLibraryPaths();
-        WCHAR* str = malloc(sizeof(WCHAR) * init_buf_size);
+        WCHAR* str = stgMallocBytes(sizeof(WCHAR) * init_buf_size, "addLibrarySearchPath_PEi386(2)");
         wResult = GetEnvironmentVariableW(L"PATH", str, bufsize);
 
         if (wResult > init_buf_size) {
@@ -804,7 +804,7 @@ HsPtr addLibrarySearchPath_PEi386(pathchar* dll_path)
         }
 
         bufsize = wResult + 2 + pathlen(abs_path);
-        wchar_t* newPath = malloc(sizeof(wchar_t) * bufsize);
+        wchar_t* newPath = stgMallocBytes(sizeof(wchar_t) * bufsize, "addLibrarySearchPath_PEi386(3)");
 
         wcscpy(newPath, abs_path);
         wcscat(newPath, L";");
@@ -813,19 +813,19 @@ HsPtr addLibrarySearchPath_PEi386(pathchar* dll_path)
             sysErrorBelch("addLibrarySearchPath[SetEnvironmentVariableW]: %" PATH_FMT " (Win32 error %lu)", abs_path, GetLastError());
         }
 
-        free(newPath);
-        free(abs_path);
+        stgFree(newPath);
+        stgFree(abs_path);
 
         return str;
     }
 
     if (!result) {
         sysErrorBelch("addLibrarySearchPath: %" PATH_FMT " (Win32 error %lu)", abs_path, GetLastError());
-        free(abs_path);
+        stgFree(abs_path);
         return NULL;
     }
 
-    free(abs_path);
+    stgFree(abs_path);
     return result;
 }
 


=====================================
rts/win32/IOManager.c
=====================================
@@ -265,7 +265,7 @@ IOWorkerProc(PVOID param)
                 }
                 // Free the WorkItem
                 DeregisterWorkItem(iom,work);
-                free(work);
+                stgFree(work);
             } else {
                 fprintf(stderr, "unable to fetch work; fatal.\n");
                 fflush(stderr);
@@ -321,7 +321,7 @@ StartIOManager(void)
     wq = NewWorkQueue();
     if ( !wq ) return false;
 
-    ioMan = (IOManagerState*)malloc(sizeof(IOManagerState));
+    ioMan = (IOManagerState*)stgMallocBytes(sizeof(IOManagerState), "StartIOManager");
 
     if (!ioMan) {
         FreeWorkQueue(wq);
@@ -332,7 +332,7 @@ StartIOManager(void)
     hExit = CreateEvent ( NULL, true, false, NULL );
     if ( !hExit ) {
         FreeWorkQueue(wq);
-        free(ioMan);
+        stgFree(ioMan);
         return false;
     }
 
@@ -440,8 +440,7 @@ AddIORequest ( int   fd,
 {
     ASSERT(ioMan);
 
-    WorkItem* wItem    = (WorkItem*)malloc(sizeof(WorkItem));
-    if (!wItem) return 0;
+    WorkItem* wItem    = (WorkItem*)stgMallocBytse(sizeof(WorkItem), "AddIORequest");
 
     unsigned int reqID = ioMan->requestID++;
 
@@ -471,8 +470,7 @@ AddDelayRequest ( HsInt          usecs,
 {
     ASSERT(ioMan);
 
-    WorkItem* wItem = (WorkItem*)malloc(sizeof(WorkItem));
-    if (!wItem) return false;
+    WorkItem* wItem = (WorkItem*)stgMallocBytes(sizeof(WorkItem), "AddDelayRequest");
 
     unsigned int reqID = ioMan->requestID++;
 
@@ -498,7 +496,7 @@ AddProcRequest ( void* proc,
 {
     ASSERT(ioMan);
 
-    WorkItem* wItem = (WorkItem*)malloc(sizeof(WorkItem));
+    WorkItem* wItem = (WorkItem*)stgMallocBytes(sizeof(WorkItem), "AddProcRequest");
     if (!wItem) return false;
 
     unsigned int reqID = ioMan->requestID++;
@@ -542,7 +540,7 @@ void ShutdownIOManager ( bool wait_threads )
             barf("timeEndPeriod failed");
         }
 
-        free(ioMan);
+        stgFree(ioMan);
         ioMan = NULL;
     }
 }


=====================================
rts/win32/OSThreads.c
=====================================
@@ -171,19 +171,19 @@ void freeThreadingResources (void)
 {
     if (cpuGroupCache)
     {
-        free(cpuGroupCache);
+        stgFree(cpuGroupCache);
         cpuGroupCache = NULL;
     }
 
     if (cpuGroupCumulativeCache)
     {
-        free(cpuGroupCumulativeCache);
+        stgFree(cpuGroupCumulativeCache);
         cpuGroupCumulativeCache = NULL;
     }
 
     if (cpuGroupDistCache)
     {
-        free(cpuGroupDistCache);
+        stgFree(cpuGroupDistCache);
         cpuGroupDistCache = NULL;
     }
 }
@@ -240,7 +240,7 @@ getProcessorsDistribution (void)
     if (!cpuGroupDistCache)
     {
         uint8_t n_groups = getNumberOfProcessorsGroups();
-        cpuGroupDistCache = malloc(n_groups * sizeof(uint8_t));
+        cpuGroupDistCache = stgMallocBytes(n_groups * sizeof(uint8_t), "getProcessorsDistribution");
         memset(cpuGroupDistCache, MAXIMUM_PROCESSORS, n_groups * sizeof(uint8_t));
 
         for (int i = 0; i < n_groups; i++)
@@ -265,7 +265,7 @@ getProcessorsCumulativeSum(void)
     if (!cpuGroupCumulativeCache)
     {
         uint8_t n_groups = getNumberOfProcessorsGroups();
-        cpuGroupCumulativeCache = malloc(n_groups * sizeof(uint32_t));
+        cpuGroupCumulativeCache = stgMallocBytes(n_groups * sizeof(uint32_t), "getProcessorsCumulativeSum");
         memset(cpuGroupCumulativeCache, 0, n_groups * sizeof(uint32_t));
 
 #if defined(x86_64_HOST_ARCH)
@@ -306,7 +306,7 @@ createProcessorGroupMap (void)
 
     uint32_t numProcs = getNumberOfProcessors();
 
-    cpuGroupCache = malloc(numProcs * sizeof(uint8_t));
+    cpuGroupCache = stgMallocBytes(numProcs * sizeof(uint8_t), "createProcessorGroupMap");
     /* For 32bit Windows and 64bit older than Windows 7, create a default mapping. */
     memset(cpuGroupCache, 0, numProcs * sizeof(uint8_t));
 
@@ -386,7 +386,7 @@ setThreadAffinity (uint32_t n, uint32_t m) // cap N of M
     ASSERT(n_groups      > 0);
     ASSERT(n_proc        > 0);
 
-    mask = malloc(n_groups * sizeof(DWORD_PTR));
+    mask = stgMallocBytes(n_groups * sizeof(DWORD_PTR), "setThreadAffinity");
     memset(mask, 0, n_groups * sizeof(DWORD_PTR));
 
     /* The mask for the individual groups are all 0 based
@@ -422,14 +422,14 @@ setThreadAffinity (uint32_t n, uint32_t m) // cap N of M
         {
             r = SetThreadAffinityMask(hThread, mask[i]);
             if (r == 0) {
-                free(mask);
+                stgFree(mask);
                 sysErrorBelch("SetThreadAffinity");
                 stg_exit(EXIT_FAILURE);
             }
         }
     }
 
-    free(mask);
+    stgFree(mask);
 }
 
 void


=====================================
rts/win32/WorkQueue.c
=====================================
@@ -41,12 +41,7 @@ newSemaphore(int initCount, int max)
 WorkQueue*
 NewWorkQueue()
 {
-  WorkQueue* wq = (WorkQueue*)malloc(sizeof(WorkQueue));
-
-  if (!wq) {
-    queue_error("NewWorkQueue", "malloc() failed");
-    return wq;
-  }
+  WorkQueue* wq = (WorkQueue*)stgMallocBytes(sizeof(WorkQueue), "NewWorkQueue");
 
   memset(wq, 0, sizeof *wq);
 


=====================================
rts/xxhash.c
=====================================
@@ -98,9 +98,11 @@
 ***************************************/
 /*! Modify the local functions below should you wish to use some other memory routines
 *   for malloc(), free() */
-#include <stdlib.h>
-static void* XXH_malloc(size_t s) { return malloc(s); }
-static void  XXH_free  (void* p)  { free(p); }
+#include "Rts.h"
+#include "RtsUtils.h"
+
+static void* XXH_malloc(size_t s) { return stgMallocBytes(s, "XXH_malloc"); }
+static void  XXH_free  (void* p)  { stgFree(p); }
 /*! and for memcpy() */
 #include <string.h>
 static void* XXH_memcpy(void* dest, const void* src, size_t size) { return memcpy(dest,src,size); }


=====================================
rules/build-package-way.mk
=====================================
@@ -107,6 +107,7 @@ endif
 endif
 
 # Build the GHCi library
+# See Note [Merging object files for GHCi] in GHC.Driver.Pipeline.
 ifneq "$(filter $3, v p)" ""
 $1_$2_$3_GHCI_LIB = $1/$2/build/HS$$($1_$2_COMPONENT_ID).$$($3_osuf)
 ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
@@ -116,7 +117,7 @@ BINDIST_LIBS += $$($1_$2_$3_GHCI_LIB)
 endif
 endif
 $$($1_$2_$3_GHCI_LIB) : $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS) $$($1_$2_LD_SCRIPT)
-	$$(call cmd,SettingsMergeObjectsCommand) $(SettingsMergeObjectsFlags) $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
+	$$(call cmd,MERGE_OBJS_STAGE$4) $(MERGE_OBJS_STAGE$4_FLAGS) $$(if $$($1_$2_LD_SCRIPT),$$($1_$2_LD_SCRIPT_CMD) $$($1_$2_LD_SCRIPT)) -o $$@ $$(EXTRA_LD_LINKER_OPTS) $$($1_$2_$3_HS_OBJS) $$($1_$2_$3_CMM_OBJS) $$($1_$2_$3_C_OBJS) $$($1_$2_$3_S_OBJS) $$($1_$2_EXTRA_OBJS)
 ifeq "$$($1_$2_BUILD_GHCI_LIB)" "YES"
 # Don't bother making ghci libs for bootstrapping packages
 ifneq "$4" "0"


=====================================
testsuite/tests/ghc-api/annotations/parseTree.stdout-mingw32 deleted
=====================================
@@ -1,160 +0,0 @@
-[(AnnotationTuple.hs:14:20, [p], Solo 1),
- (AnnotationTuple.hs:14:23-29, [p], Solo "hello"),
- (AnnotationTuple.hs:14:35-37, [p], Solo 6.5),
- (AnnotationTuple.hs:14:39, [m], ()),
- (AnnotationTuple.hs:14:41-52, [p], Solo [5, 5, 6, 7]),
- (AnnotationTuple.hs:16:8, [p], Solo 1),
- (AnnotationTuple.hs:16:11-17, [p], Solo "hello"),
- (AnnotationTuple.hs:16:20-22, [p], Solo 6.5),
- (AnnotationTuple.hs:16:24, [m], ()),
- (AnnotationTuple.hs:16:25, [m], ()),
- (AnnotationTuple.hs:16:26, [m], ()), (<no location info>, [m], ())]
-[
-(AK AnnotationTuple.hs:1:1 AnnCloseC = [AnnotationTuple.hs:27:1])
-
-(AK AnnotationTuple.hs:1:1 AnnModule = [AnnotationTuple.hs:3:1-6])
-
-(AK AnnotationTuple.hs:1:1 AnnOpenC = [AnnotationTuple.hs:5:1])
-
-(AK AnnotationTuple.hs:1:1 AnnWhere = [AnnotationTuple.hs:3:30-34])
-
-(AK AnnotationTuple.hs:3:24-28 AnnCloseP = [AnnotationTuple.hs:3:28])
-
-(AK AnnotationTuple.hs:3:24-28 AnnOpenP = [AnnotationTuple.hs:3:24])
-
-(AK AnnotationTuple.hs:6:1-32 AnnAs = [AnnotationTuple.hs:6:28-29])
-
-(AK AnnotationTuple.hs:6:1-32 AnnImport = [AnnotationTuple.hs:6:1-6])
-
-(AK AnnotationTuple.hs:6:1-32 AnnQualified = [AnnotationTuple.hs:6:8-16])
-
-(AK AnnotationTuple.hs:6:1-32 AnnSemi = [AnnotationTuple.hs:7:1])
-
-(AK AnnotationTuple.hs:(8,1)-(11,14) AnnEqual = [AnnotationTuple.hs:8:5])
-
-(AK AnnotationTuple.hs:(8,1)-(11,14) AnnFunId = [AnnotationTuple.hs:8:1-3])
-
-(AK AnnotationTuple.hs:(8,1)-(11,14) AnnSemi = [AnnotationTuple.hs:13:1])
-
-(AK AnnotationTuple.hs:(8,7)-(11,14) AnnIn = [AnnotationTuple.hs:11:7-8])
-
-(AK AnnotationTuple.hs:(8,7)-(11,14) AnnLet = [AnnotationTuple.hs:8:7-9])
-
-(AK AnnotationTuple.hs:9:9-13 AnnEqual = [AnnotationTuple.hs:9:11])
-
-(AK AnnotationTuple.hs:9:9-13 AnnFunId = [AnnotationTuple.hs:9:9])
-
-(AK AnnotationTuple.hs:9:9-13 AnnSemi = [AnnotationTuple.hs:10:9])
-
-(AK AnnotationTuple.hs:10:9-13 AnnEqual = [AnnotationTuple.hs:10:11])
-
-(AK AnnotationTuple.hs:10:9-13 AnnFunId = [AnnotationTuple.hs:10:9])
-
-(AK AnnotationTuple.hs:11:10-14 AnnVal = [AnnotationTuple.hs:11:12])
-
-(AK AnnotationTuple.hs:14:1-72 AnnEqual = [AnnotationTuple.hs:14:5])
-
-(AK AnnotationTuple.hs:14:1-72 AnnFunId = [AnnotationTuple.hs:14:1-3])
-
-(AK AnnotationTuple.hs:14:1-72 AnnSemi = [AnnotationTuple.hs:15:1])
-
-(AK AnnotationTuple.hs:14:7-72 AnnVal = [AnnotationTuple.hs:14:13])
-
-(AK AnnotationTuple.hs:14:19-53 AnnCloseP = [AnnotationTuple.hs:14:53])
-
-(AK AnnotationTuple.hs:14:19-53 AnnOpenP = [AnnotationTuple.hs:14:19])
-
-(AK AnnotationTuple.hs:14:20 AnnComma = [AnnotationTuple.hs:14:21])
-
-(AK AnnotationTuple.hs:14:23-29 AnnComma = [AnnotationTuple.hs:14:33])
-
-(AK AnnotationTuple.hs:14:35-37 AnnComma = [AnnotationTuple.hs:14:38])
-
-(AK AnnotationTuple.hs:14:39 AnnComma = [AnnotationTuple.hs:14:39])
-
-(AK AnnotationTuple.hs:14:41-52 AnnCloseS = [AnnotationTuple.hs:14:52])
-
-(AK AnnotationTuple.hs:14:41-52 AnnOpenS = [AnnotationTuple.hs:14:41])
-
-(AK AnnotationTuple.hs:14:42 AnnComma = [AnnotationTuple.hs:14:43])
-
-(AK AnnotationTuple.hs:14:45 AnnComma = [AnnotationTuple.hs:14:46])
-
-(AK AnnotationTuple.hs:14:48 AnnComma = [AnnotationTuple.hs:14:49])
-
-(AK AnnotationTuple.hs:14:55-72 AnnCloseS = [AnnotationTuple.hs:14:72])
-
-(AK AnnotationTuple.hs:14:55-72 AnnOpenS = [AnnotationTuple.hs:14:55])
-
-(AK AnnotationTuple.hs:14:56-62 AnnComma = [AnnotationTuple.hs:14:63])
-
-(AK AnnotationTuple.hs:14:61-62 AnnCloseP = [AnnotationTuple.hs:14:62])
-
-(AK AnnotationTuple.hs:14:61-62 AnnOpenP = [AnnotationTuple.hs:14:61])
-
-(AK AnnotationTuple.hs:16:1-41 AnnEqual = [AnnotationTuple.hs:16:5])
-
-(AK AnnotationTuple.hs:16:1-41 AnnFunId = [AnnotationTuple.hs:16:1-3])
-
-(AK AnnotationTuple.hs:16:1-41 AnnSemi = [AnnotationTuple.hs:17:1])
-
-(AK AnnotationTuple.hs:16:7-27 AnnCloseP = [AnnotationTuple.hs:16:27])
-
-(AK AnnotationTuple.hs:16:7-27 AnnOpenP = [AnnotationTuple.hs:16:7])
-
-(AK AnnotationTuple.hs:16:8 AnnComma = [AnnotationTuple.hs:16:9])
-
-(AK AnnotationTuple.hs:16:11-17 AnnComma = [AnnotationTuple.hs:16:18])
-
-(AK AnnotationTuple.hs:16:20-22 AnnComma = [AnnotationTuple.hs:16:23])
-
-(AK AnnotationTuple.hs:16:24 AnnComma = [AnnotationTuple.hs:16:24])
-
-(AK AnnotationTuple.hs:16:25 AnnComma = [AnnotationTuple.hs:16:25])
-
-(AK AnnotationTuple.hs:16:26 AnnComma = [AnnotationTuple.hs:16:26])
-
-(AK AnnotationTuple.hs:16:33-41 AnnCloseP = [AnnotationTuple.hs:16:41])
-
-(AK AnnotationTuple.hs:16:33-41 AnnOpenP = [AnnotationTuple.hs:16:33])
-
-(AK AnnotationTuple.hs:16:39-40 AnnCloseP = [AnnotationTuple.hs:16:40])
-
-(AK AnnotationTuple.hs:16:39-40 AnnOpenP = [AnnotationTuple.hs:16:39])
-
-(AK AnnotationTuple.hs:18:1-28 AnnData = [AnnotationTuple.hs:18:1-4])
-
-(AK AnnotationTuple.hs:18:1-28 AnnDcolon = [AnnotationTuple.hs:18:20-21])
-
-(AK AnnotationTuple.hs:18:1-28 AnnFamily = [AnnotationTuple.hs:18:6-11])
-
-(AK AnnotationTuple.hs:18:1-28 AnnSemi = [AnnotationTuple.hs:19:1])
-
-(AK AnnotationTuple.hs:18:23 AnnRarrow = [AnnotationTuple.hs:18:25-26])
-
-(AK AnnotationTuple.hs:18:23-28 AnnRarrow = [AnnotationTuple.hs:18:25-26])
-
-(AK AnnotationTuple.hs:(20,1)-(24,14) AnnFunId = [AnnotationTuple.hs:20:1-5])
-
-(AK AnnotationTuple.hs:(20,1)-(24,14) AnnSemi = [AnnotationTuple.hs:25:1])
-
-(AK AnnotationTuple.hs:(21,7)-(24,14) AnnEqual = [AnnotationTuple.hs:24:7])
-
-(AK AnnotationTuple.hs:(21,7)-(24,14) AnnVbar = [AnnotationTuple.hs:21:7])
-
-(AK AnnotationTuple.hs:21:9-24 AnnComma = [AnnotationTuple.hs:22:7])
-
-(AK AnnotationTuple.hs:21:9-24 AnnLarrow = [AnnotationTuple.hs:21:16-17])
-
-(AK AnnotationTuple.hs:22:9-25 AnnComma = [AnnotationTuple.hs:23:7])
-
-(AK AnnotationTuple.hs:22:9-25 AnnLarrow = [AnnotationTuple.hs:22:16-17])
-
-(AK AnnotationTuple.hs:23:9-24 AnnLarrow = [AnnotationTuple.hs:23:16-17])
-
-(AK AnnotationTuple.hs:26:1-10 AnnDcolon = [AnnotationTuple.hs:26:5-6])
-
-(AK AnnotationTuple.hs:26:1-14 AnnEqual = [AnnotationTuple.hs:26:12])
-]
-
-EOF: Just SrcSpanPoint ".\\AnnotationTuple.hs" 32 1


=====================================
testsuite/tests/ghci/scripts/all.T
=====================================
@@ -141,8 +141,11 @@ test('T5979',
      normalise_slashes,
      normalise_version("transformers")],
     ghci_script, ['T5979.script'])
-test('T5975a', [pre_cmd('touch föøbàr1.hs')], ghci_script, ['T5975a.script'])
-test('T5975b', [pre_cmd('touch föøbàr2.hs'), extra_hc_opts('föøbàr2.hs')],
+test('T5975a',
+     [pre_cmd('touch föøbàr1.hs'), when(opsys('mingw32'), expect_broken(7305))],
+     ghci_script, ['T5975a.script'])
+test('T5975b',
+     [pre_cmd('touch föøbàr2.hs'), extra_hc_opts('föøbàr2.hs'), when(opsys('mingw32'), expect_broken(7305))],
      ghci_script, ['T5975b.script'])
 test('T6027ghci', normal, ghci_script, ['T6027ghci.script'])
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c18e8d7de4da7dc074ecae48de8b62f0fca3d854...2c5f7a35103533495d26d80df30f91f62d6e2650

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c18e8d7de4da7dc074ecae48de8b62f0fca3d854...2c5f7a35103533495d26d80df30f91f62d6e2650
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20200905/95aa8fe1/attachment-0001.html>


More information about the ghc-commits mailing list