[Git][ghc/ghc][wip/various-hadrian-fixes] 8 commits: compiler: Add -f[no-]split-sections flags
Ben Gamari (@bgamari)
gitlab at gitlab.haskell.org
Fri Dec 16 14:53:16 UTC 2022
Ben Gamari pushed to branch wip/various-hadrian-fixes at Glasgow Haskell Compiler / GHC
Commits:
551e0ecf by Matthew Pickering at 2022-12-16T09:52:50-05:00
compiler: Add -f[no-]split-sections flags
Here we add a `-fsplit-sections` flag which may some day replace
`-split-sections`. This has the advantage of automatically providing a
`-fno-split-sections` flag, which is useful for our packaging because we
enable `-split-sections` by default but want to disable it in certain
configurations.
- - - - -
ffd60fd8 by Matthew Pickering at 2022-12-16T09:52:50-05:00
hadrian: Fix computation of tables_next_to_code for outOfTreeCompiler
This copy-pasto was introduced in de5fb3489f2a9bd6dc75d0cb8925a27fe9b9084b
- - - - -
30f6d97e by Matthew Pickering at 2022-12-16T09:52:50-05:00
hadrian: Add test:all_deps to build just testsuite dependencies
Fixes #22534
- - - - -
4b3be317 by Matthew Pickering at 2022-12-16T09:52:50-05:00
hadrian: Add no_split_sections tranformer
This transformer reverts the effect of `split_sections`, which we intend
to use for platforms which don't support split sections.
- - - - -
b8c9383c by Matthew Pickering at 2022-12-16T09:52:50-05:00
check-exact: Fix build with -Werror
- - - - -
45f9bac3 by Matthew Pickering at 2022-12-16T09:52:50-05:00
ci: Build all test dependencies with in-tree compiler
This means that these executables will honour flavour transformers such
as "werror".
Fixes #22555
- - - - -
7c97ff24 by Matthew Pickering at 2022-12-16T09:52:50-05:00
hadrian: Document using GHC environment variable to select boot compiler
Fixes #22340
- - - - -
ca836a37 by Matthew Pickering at 2022-12-16T09:52:50-05:00
packaging: Build perf builds with -split-sections
In 8f71d958 the make build system was made to use split-sections on
linux systems but it appears this logic never made it to hadrian.
There is the split_sections flavour transformer but this doesn't appear
to be used for perf builds on linux.
This is disbled on deb9 and windows due to #21670
Closes #21135
- - - - -
15 changed files:
- .gitlab-ci.yml
- .gitlab/ci.sh
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/Driver/Session.hs
- docs/users_guide/phases.rst
- hadrian/README.md
- hadrian/doc/flavours.md
- hadrian/doc/testsuite.md
- hadrian/src/Flavour.hs
- hadrian/src/Oracles/TestSettings.hs
- hadrian/src/Rules/Test.hs
- hadrian/src/Settings/Builders/RunTest.hs
- hadrian/src/Settings/Flavours/Performance.hs
- utils/check-exact/ExactPrint.hs
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -501,7 +501,7 @@ doc-tarball:
optional: true
- job: nightly-x86_64-windows-validate
optional: true
- - job: release-x86_64-windows-release
+ - job: release-x86_64-windows-release+no_split_sections
optional: true
tags:
@@ -525,7 +525,7 @@ doc-tarball:
|| mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \
|| true
mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \
- || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \
+ || mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \
|| true
if [ ! -f "$LINUX_BINDIST" ]; then
echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"
=====================================
.gitlab/ci.sh
=====================================
@@ -518,7 +518,7 @@ function build_hadrian() {
if [[ -n "${REINSTALL_GHC:-}" ]]; then
run_hadrian build-cabal -V
else
- run_hadrian binary-dist -V
+ run_hadrian test:all_deps binary-dist -V
mv _build/bindist/ghc*.tar.xz "$BIN_DIST_NAME.tar.xz"
fi
=====================================
.gitlab/gen_ci.hs
=====================================
@@ -130,6 +130,7 @@ data BuildConfig
, fullyStatic :: Bool
, tablesNextToCode :: Bool
, threadSanitiser :: Bool
+ , noSplitSections :: Bool
}
-- Extra arguments to pass to ./configure due to the BuildConfig
@@ -146,13 +147,14 @@ mkJobFlavour BuildConfig{..} = Flavour buildFlavour opts
opts = [Llvm | llvmBootstrap] ++
[Dwarf | withDwarf] ++
[FullyStatic | fullyStatic] ++
- [ThreadSanitiser | threadSanitiser]
+ [ThreadSanitiser | threadSanitiser] ++
+ [NoSplitSections | noSplitSections, buildFlavour == Release ]
data Flavour = Flavour BaseFlavour [FlavourTrans]
-data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser
+data FlavourTrans = Llvm | Dwarf | FullyStatic | ThreadSanitiser | NoSplitSections
-data BaseFlavour = Release | Validate | SlowValidate
+data BaseFlavour = Release | Validate | SlowValidate deriving Eq
-----------------------------------------------------------------------------
-- Build Configs
@@ -174,8 +176,12 @@ vanilla = BuildConfig
, fullyStatic = False
, tablesNextToCode = True
, threadSanitiser = False
+ , noSplitSections = False
}
+splitSectionsBroken :: BuildConfig -> BuildConfig
+splitSectionsBroken bc = bc { noSplitSections = True }
+
nativeInt :: BuildConfig
nativeInt = vanilla { bignumBackend = Native }
@@ -290,6 +296,7 @@ flavourString (Flavour base trans) = baseString base ++ concatMap (("+" ++) . fl
flavourString Dwarf = "debug_info"
flavourString FullyStatic = "fully_static"
flavourString ThreadSanitiser = "thread_sanitizer"
+ flavourString NoSplitSections = "no_split_sections"
-- The path to the docker image (just for linux builders)
dockerImage :: Arch -> Opsys -> Maybe String
@@ -792,23 +799,23 @@ jobs = Map.fromList $ concatMap flattenJobGroup $
, disableValidate (standardBuilds Amd64 (Linux Debian11))
-- We still build Deb9 bindists for now due to Ubuntu 18 and Linux Mint 19
-- not being at EOL until April 2023 and they still need tinfo5.
- , disableValidate (standardBuilds Amd64 (Linux Debian9))
+ , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla))
, disableValidate (standardBuilds Amd64 (Linux Ubuntu2004))
- , disableValidate (standardBuilds Amd64 (Linux Centos7))
+ , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) (splitSectionsBroken vanilla))
-- Fedora33 job is always built with perf so there's one job in the normal
-- validate pipeline which is built with perf.
, (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig)
-- This job is only for generating head.hackage docs
, hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig))
, disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf)
- , fastCI (standardBuilds Amd64 Windows)
- , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt)
+ , fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla))
+ , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt))
, standardBuilds Amd64 Darwin
, allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13))
, standardBuilds AArch64 Darwin
, standardBuilds AArch64 (Linux Debian10)
- , standardBuilds I386 (Linux Debian9)
- , standardBuildsWithConfig Amd64 (Linux Alpine) static
+ , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla)
+ , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static)
, disableValidate (allowFailureGroup (standardBuildsWithConfig Amd64 (Linux Alpine) staticNativeInt))
, validateBuilds Amd64 (Linux Debian11) (crossConfig "aarch64-linux-gnu" (Emulator "qemu-aarch64 -L /usr/aarch64-linux-gnu") Nothing)
, validateBuilds Amd64 (Linux Debian11) (crossConfig "js-unknown-ghcjs" NoEmulatorNeeded (Just "emconfigure")
=====================================
.gitlab/jobs.yaml
=====================================
@@ -1869,7 +1869,7 @@
"XZ_OPT": "-9"
}
},
- "release-i386-linux-deb9-release": {
+ "release-i386-linux-deb9-release+no_split_sections": {
"after_script": [
".gitlab/ci.sh save_cache",
".gitlab/ci.sh clean",
@@ -1879,7 +1879,7 @@
"artifacts": {
"expire_in": "1 year",
"paths": [
- "ghc-i386-linux-deb9-release.tar.xz",
+ "ghc-i386-linux-deb9-release+no_split_sections.tar.xz",
"junit.xml"
],
"reports": {
@@ -1921,11 +1921,11 @@
],
"variables": {
"BIGNUM_BACKEND": "gmp",
- "BIN_DIST_NAME": "ghc-i386-linux-deb9-release",
- "BUILD_FLAVOUR": "release",
+ "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections",
+ "BUILD_FLAVOUR": "release+no_split_sections",
"CONFIGURE_ARGS": "",
"IGNORE_PERF_FAILURES": "all",
- "TEST_ENV": "i386-linux-deb9-release",
+ "TEST_ENV": "i386-linux-deb9-release+no_split_sections",
"XZ_OPT": "-9"
}
},
@@ -2120,7 +2120,7 @@
"XZ_OPT": "-9"
}
},
- "release-x86_64-linux-alpine3_12-release+fully_static": {
+ "release-x86_64-linux-alpine3_12-release+fully_static+no_split_sections": {
"after_script": [
".gitlab/ci.sh save_cache",
".gitlab/ci.sh clean",
@@ -2130,7 +2130,7 @@
"artifacts": {
"expire_in": "1 year",
"paths": [
- "ghc-x86_64-linux-alpine3_12-release+fully_static.tar.xz",
+ "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections.tar.xz",
"junit.xml"
],
"reports": {
@@ -2172,18 +2172,18 @@
],
"variables": {
"BIGNUM_BACKEND": "gmp",
- "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static",
+ "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections",
"BROKEN_TESTS": "encoding004 T10458 ghcilink002 linker_unload_native",
- "BUILD_FLAVOUR": "release+fully_static",
+ "BUILD_FLAVOUR": "release+fully_static+no_split_sections",
"CONFIGURE_ARGS": "--disable-ld-override ",
"HADRIAN_ARGS": "--docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
"INSTALL_CONFIGURE_ARGS": "--disable-ld-override",
- "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static",
+ "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static+no_split_sections",
"XZ_OPT": "-9"
}
},
- "release-x86_64-linux-centos7-release": {
+ "release-x86_64-linux-centos7-release+no_split_sections": {
"after_script": [
".gitlab/ci.sh save_cache",
".gitlab/ci.sh clean",
@@ -2193,7 +2193,7 @@
"artifacts": {
"expire_in": "1 year",
"paths": [
- "ghc-x86_64-linux-centos7-release.tar.xz",
+ "ghc-x86_64-linux-centos7-release+no_split_sections.tar.xz",
"junit.xml"
],
"reports": {
@@ -2235,12 +2235,12 @@
],
"variables": {
"BIGNUM_BACKEND": "gmp",
- "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release",
- "BUILD_FLAVOUR": "release",
+ "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release+no_split_sections",
+ "BUILD_FLAVOUR": "release+no_split_sections",
"CONFIGURE_ARGS": "",
"HADRIAN_ARGS": "--docs=no-sphinx",
"IGNORE_PERF_FAILURES": "all",
- "TEST_ENV": "x86_64-linux-centos7-release",
+ "TEST_ENV": "x86_64-linux-centos7-release+no_split_sections",
"XZ_OPT": "-9"
}
},
@@ -2424,7 +2424,7 @@
"XZ_OPT": "-9"
}
},
- "release-x86_64-linux-deb9-release": {
+ "release-x86_64-linux-deb9-release+no_split_sections": {
"after_script": [
".gitlab/ci.sh save_cache",
".gitlab/ci.sh clean",
@@ -2434,7 +2434,7 @@
"artifacts": {
"expire_in": "1 year",
"paths": [
- "ghc-x86_64-linux-deb9-release.tar.xz",
+ "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz",
"junit.xml"
],
"reports": {
@@ -2476,11 +2476,11 @@
],
"variables": {
"BIGNUM_BACKEND": "gmp",
- "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release",
- "BUILD_FLAVOUR": "release",
+ "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections",
+ "BUILD_FLAVOUR": "release+no_split_sections",
"CONFIGURE_ARGS": "",
"IGNORE_PERF_FAILURES": "all",
- "TEST_ENV": "x86_64-linux-deb9-release",
+ "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections",
"XZ_OPT": "-9"
}
},
@@ -2731,7 +2731,7 @@
"XZ_OPT": "-9"
}
},
- "release-x86_64-windows-int_native-release": {
+ "release-x86_64-windows-int_native-release+no_split_sections": {
"after_script": [
"bash .gitlab/ci.sh save_cache",
"bash .gitlab/ci.sh clean"
@@ -2740,7 +2740,7 @@
"artifacts": {
"expire_in": "1 year",
"paths": [
- "ghc-x86_64-windows-int_native-release.tar.xz",
+ "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz",
"junit.xml"
],
"reports": {
@@ -2778,8 +2778,8 @@
],
"variables": {
"BIGNUM_BACKEND": "native",
- "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release",
- "BUILD_FLAVOUR": "release",
+ "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections",
+ "BUILD_FLAVOUR": "release+no_split_sections",
"CABAL_INSTALL_VERSION": "3.2.0.0",
"CONFIGURE_ARGS": "",
"GHC_VERSION": "9.2.2",
@@ -2787,11 +2787,11 @@
"IGNORE_PERF_FAILURES": "all",
"LANG": "en_US.UTF-8",
"MSYSTEM": "MINGW64",
- "TEST_ENV": "x86_64-windows-int_native-release",
+ "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections",
"XZ_OPT": "-9"
}
},
- "release-x86_64-windows-release": {
+ "release-x86_64-windows-release+no_split_sections": {
"after_script": [
"bash .gitlab/ci.sh save_cache",
"bash .gitlab/ci.sh clean"
@@ -2800,7 +2800,7 @@
"artifacts": {
"expire_in": "1 year",
"paths": [
- "ghc-x86_64-windows-release.tar.xz",
+ "ghc-x86_64-windows-release+no_split_sections.tar.xz",
"junit.xml"
],
"reports": {
@@ -2838,8 +2838,8 @@
],
"variables": {
"BIGNUM_BACKEND": "gmp",
- "BIN_DIST_NAME": "ghc-x86_64-windows-release",
- "BUILD_FLAVOUR": "release",
+ "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections",
+ "BUILD_FLAVOUR": "release+no_split_sections",
"CABAL_INSTALL_VERSION": "3.2.0.0",
"CONFIGURE_ARGS": "",
"GHC_VERSION": "9.2.2",
@@ -2847,7 +2847,7 @@
"IGNORE_PERF_FAILURES": "all",
"LANG": "en_US.UTF-8",
"MSYSTEM": "MINGW64",
- "TEST_ENV": "x86_64-windows-release",
+ "TEST_ENV": "x86_64-windows-release+no_split_sections",
"XZ_OPT": "-9"
}
},
=====================================
compiler/GHC/Driver/Session.hs
=====================================
@@ -2192,14 +2192,10 @@ dynamic_flags_deps = [
, make_ord_flag defGhcFlag "split-objs"
(NoArg $ addWarn "ignoring -split-objs")
+ -- N.B. We may someday deprecate this in favor of -fsplit-sections,
+ -- which has the benefit of also having a negating -fno-split-sections.
, make_ord_flag defGhcFlag "split-sections"
- (noArgM (\dflags -> do
- if platformHasSubsectionsViaSymbols (targetPlatform dflags)
- then do addWarn $
- "-split-sections is not useful on this platform " ++
- "since it always uses subsections via symbols. Ignoring."
- return dflags
- else return (gopt_set dflags Opt_SplitSections)))
+ (NoArg $ setGeneralFlag Opt_SplitSections)
-------- ghc -M -----------------------------------------------------
, make_ord_flag defGhcFlag "dep-suffix" (hasArg addDepSuffix)
@@ -3514,7 +3510,8 @@ fFlagsDeps = [
(addWarn "-compact-unwind is only implemented by the darwin platform. Ignoring.")
return dflags)),
flagSpec "show-error-context" Opt_ShowErrorContext,
- flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer
+ flagSpec "cmm-thread-sanitizer" Opt_CmmThreadSanitizer,
+ flagSpec "split-sections" Opt_SplitSections
]
++ fHoleFlags
@@ -4800,6 +4797,13 @@ makeDynFlagsConsistent dflags
warn = "-dynamic-too is ignored when using -dynamic"
in loop dflags' warn
+ | gopt Opt_SplitSections dflags
+ , platformHasSubsectionsViaSymbols (targetPlatform dflags)
+ = let dflags' = gopt_unset dflags Opt_SplitSections
+ warn = "-fsplit-sections is not useful on this platform " ++
+ "since it uses subsections-via-symbols. Ignoring."
+ in loop dflags' warn
+
-- Via-C backend only supports unregisterised ABI. Switch to a backend
-- supporting it if possible.
| backendUnregisterisedAbiOnly (backend dflags) &&
=====================================
docs/users_guide/phases.rst
=====================================
@@ -909,10 +909,12 @@ for example).
option for Apple's Linker (``-F`` already means something else for
GHC).
-.. ghc-flag:: -split-sections
+.. ghc-flag:: -fsplit-sections
+ -split-sections
:shortdesc: Split sections for link-time dead-code stripping
:type: dynamic
:category: linking
+ :reverse: -fno-split-sections
Place each generated function or data item into its own section in the
output file if the target supports arbitrary sections. The name of the
=====================================
hadrian/README.md
=====================================
@@ -164,6 +164,18 @@ build stage2:lib:text
build stage1:exe:haddock
```
+#### Choosing the compiler used to build Hadrian
+
+The `GHC` environment variable can be used to control which GHC is used to build hadrian. By
+default the version of GHC on your path is used to build hadrian.
+This can be a different version of GHC to the one you want to use as the boot compiler (which
+is selected during ./configure).
+
+```
+GHC=$(which ghc-9.4.2) ./hadrian/build
+-- hadrian is built using ghc-9.4.2
+```
+
#### Fast feedback using ghci
Running the `./hadrian/ghci` script will load the main compiler into
=====================================
hadrian/doc/flavours.md
=====================================
@@ -15,6 +15,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
<table>
<tr>
<th rowspan="3">Flavour</th>
+ <th rowspan="3">Split Sections</th>
<th colspan="8">Extra arguments</th>
</tr>
<tr>
@@ -35,6 +36,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>default<br></td>
+ <td> </td>
<td>-O<br>-H32m<br></td>
<td>-O2<br>-H32m</td>
<td></td>
@@ -46,6 +48,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>quick</td>
+ <td> </td>
<td>-O0<br>-H64m</td>
<td>-O0<br>-H64m</td>
<td></td>
@@ -57,6 +60,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>quick-validate</td>
+ <td></td>
<td>-O0<br>-H64m<br>-Werror</td>
<td>-O0<br>-H64m<br>-Werror</td>
<td></td>
@@ -68,6 +72,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>quick-debug</td>
+ <td></td>
<td>-O0<br>-H64m</td>
<td>-O0<br>-H64m</td>
<td></td>
@@ -79,6 +84,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>quickest</td>
+ <td></td>
<td>-O0<br>-H64m</td>
<td>-O0<br>-H64m</td>
<td></td>
@@ -90,6 +96,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>perf</td>
+ <td> Yes (on supported platforms) </td>
<td>-O<br>-H64m</td>
<td>-O<br>-H64m</td>
<td></td>
@@ -112,6 +119,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>bench</td>
+ <td></td>
<td>-O<br>-H64m</td>
<td>-O<br>-H64m</td>
<td></td>
@@ -123,6 +131,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>devel1</td>
+ <td></td>
<td>-O<br>-H64m</td>
<td>-O<br>-H64m</td>
<td></td>
@@ -134,6 +143,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>devel2</td>
+ <td></td>
<td>-O<br>-H64m</td>
<td>-O<br>-H64m</td>
<td></td>
@@ -145,6 +155,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>validate</td>
+ <td></td>
<td>-O0<br>-H64m</td>
<td>-fllvm-fill-undef-with-garbage</td>
<td></td>
@@ -156,6 +167,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>slow-validate</td>
+ <td></td>
<td>-O0<br>-H64m</td>
<td>-fllvm-fill-undef-with-garbage</td>
<td></td>
@@ -167,6 +179,7 @@ when compiling the `compiler` library, and `hsGhc` when compiling/linking the GH
</tr>
<tr>
<th>static</td>
+ <td></td>
<td>-O<br>-H64m<br>-fPIC -static</td>
<td>-O<br>-H64m<br>-fPIC -static</td>
<td></td>
@@ -216,6 +229,10 @@ The supported transformers are listed below:
<td>Enable section splitting for all libraries (except for the GHC
library due to the long linking times that this causes).</td>
</tr>
+ <tr>
+ <td><code>no_split_sections</code></td>
+ <td>Disable section splitting for all libraries.</td>
+ </tr>
<tr>
<td><code>thread_sanitizer</code></td>
<td>Build the runtime system with ThreadSanitizer support</td>
=====================================
hadrian/doc/testsuite.md
=====================================
@@ -22,6 +22,19 @@ tested in CI. If you use an untested flavour such as "Quick" then you run the
risk that not all tests will pass. In particular you can rely on the `validate`
and `perf` flavours being tested but no others.
+## Building just the dependencies needed for the testsuite
+
+By default the testsuite is queried to work out what specific dependencies need to
+be built for tests. For example, some linter tests don't require anything to be built.
+If you wish to build all the targets for the testsuite before running any tests there is
+a special meta-target which builds all the dependencies you might need when running the testsuite.
+
+```
+build test:all_deps
+```
+
+
+
## Running only a subset of the testsuite
### Specific tests
=====================================
hadrian/src/Flavour.hs
=====================================
@@ -5,7 +5,7 @@ module Flavour
-- * Flavour transformers
, flavourTransformers
, addArgs
- , splitSections, splitSectionsIf
+ , splitSections
, enableThreadSanitizer
, enableDebugInfo, enableTickyGhc
, viaLlvmBackend
@@ -24,6 +24,7 @@ module Flavour
import Expression
import Data.Either
+import Data.Functor
import Data.Map (Map)
import qualified Data.Map as M
import qualified Data.Set as Set
@@ -46,6 +47,7 @@ flavourTransformers = M.fromList
, "debug_info" =: enableDebugInfo
, "ticky_ghc" =: enableTickyGhc
, "split_sections" =: splitSections
+ , "no_split_sections" =: noSplitSections
, "thread_sanitizer" =: enableThreadSanitizer
, "llvm" =: viaLlvmBackend
, "profiled_ghc" =: enableProfiledGhc
@@ -111,6 +113,15 @@ parseFlavour baseFlavours transformers str =
addArgs :: Args -> Flavour -> Flavour
addArgs args' fl = fl { args = args fl <> args' }
+-- | Optionally pass the given argument to all GHC invocations.
+addGhcArg :: Expr (Maybe String) -> Flavour -> Flavour
+addGhcArg f = addArgs $ do
+ mbOpt <- f
+ case mbOpt of
+ Nothing -> return []
+ Just opt ->
+ builder (Ghc CompileHs) ? arg opt
+
-- | Turn on -Werror for packages built with the stage1 compiler.
-- It mimics the CI settings so is useful to turn on when developing.
@@ -180,28 +191,29 @@ enableHaddock =
[ arg "-haddock"
]
--- | Transform the input 'Flavour' so as to build with
--- @-split-sections@ whenever appropriate. You can
--- select which package gets built with split sections
--- by passing a suitable predicate. If the predicate holds
--- for a given package, then @split-sections@ is used when
--- building it. Note that this transformer doesn't do anything
--- on darwin because on darwin platforms we always enable subsections
--- via symbols.
-splitSectionsIf :: (Package -> Bool) -> Flavour -> Flavour
-splitSectionsIf pkgPredicate = addArgs $ do
- pkg <- getPackage
- osx <- expr isOsxTarget
- not osx ? -- osx doesn't support split sections
- pkgPredicate pkg ? -- Only apply to these packages
- builder (Ghc CompileHs) ? arg "-split-sections"
-
--- | Like 'splitSectionsIf', but with a fixed predicate: use
--- split sections for all packages but the GHC library.
-splitSections :: Flavour -> Flavour
-splitSections = splitSectionsIf (/=ghc)
--- Disable section splitting for the GHC library. It takes too long and
--- there is little benefit.
+-- | Does it make sense to enable or disable split sections?
+splitSectionsRelevant :: Expr Bool
+splitSectionsRelevant = do
+ pkg <- getPackage
+ osx <- expr isOsxTarget
+ notSt0 <- notStage0
+ return $
+ not osx
+ -- OS X doesn't support split sections
+ && notSt0
+ -- Disable for stage 0 because we aren't going to ship
+ -- the resulting binaries and consequently there is no
+ -- reason to minimize size.
+ && (pkg /= ghc)
+ -- Disable section splitting for the GHC library.
+ -- It takes too long and there is little benefit.
+
+splitSectionsArg :: String -> Flavour -> Flavour
+splitSectionsArg opt = addGhcArg ( splitSectionsRelevant <&> \ rel -> guard rel $> opt )
+
+splitSections, noSplitSections :: Flavour -> Flavour
+splitSections = splitSectionsArg "-fsplit-sections"
+noSplitSections = splitSectionsArg "-fno-split-sections"
-- | Build GHC and libraries with ThreadSanitizer support. You likely want to
-- configure with @--disable-large-address-space@ when using this.
=====================================
hadrian/src/Oracles/TestSettings.hs
=====================================
@@ -31,6 +31,7 @@ data TestSetting = TestHostOS
| TestGhcWithInterpreter
| TestGhcWithRtsLinker
| TestGhcUnregisterised
+ | TestGhcTablesNextToCode
| TestGhcWithSMP
| TestGhcDynamic
| TestGhcProfiled
@@ -61,6 +62,7 @@ testSetting key = do
TestGhcWithInterpreter -> "GhcWithInterpreter"
TestGhcWithRtsLinker -> "GhcWithRtsLinker"
TestGhcUnregisterised -> "GhcUnregisterised"
+ TestGhcTablesNextToCode -> "GhcTablesNextToCode"
TestGhcWithSMP -> "GhcWithSMP"
TestGhcDynamic -> "GhcDynamic"
TestGhcProfiled -> "GhcProfiled"
=====================================
hadrian/src/Rules/Test.hs
=====================================
@@ -82,6 +82,9 @@ inTreeOutTree inTree outTree = do
testsuiteDeps :: Rules ()
testsuiteDeps = do
root <- buildRootRules
+ "test:all_deps" ~> do
+ need ("test:ghc" : map cp_target checkPrograms)
+
"test:ghc" ~> inTreeOutTree
(\stg -> do
needTestsuitePackages stg
=====================================
hadrian/src/Settings/Builders/RunTest.hs
=====================================
@@ -145,7 +145,7 @@ outOfTreeCompilerArgs = do
withNativeCodeGen <- getBooleanSetting TestGhcWithNativeCodeGen
withInterpreter <- getBooleanSetting TestGhcWithInterpreter
unregisterised <- getBooleanSetting TestGhcUnregisterised
- tables_next_to_code <- getBooleanSetting TestGhcUnregisterised
+ tables_next_to_code <- getBooleanSetting TestGhcTablesNextToCode
withSMP <- getBooleanSetting TestGhcWithSMP
debugAssertions <- getBooleanSetting TestGhcDebugged
=====================================
hadrian/src/Settings/Flavours/Performance.hs
=====================================
@@ -6,7 +6,7 @@ import {-# SOURCE #-} Settings.Default
-- Please update doc/flavours.md when changing this file.
performanceFlavour :: Flavour
-performanceFlavour = defaultFlavour
+performanceFlavour = splitSections $ defaultFlavour
{ name = "perf"
, args = defaultBuilderArgs <> performanceArgs <> defaultPackageArgs }
=====================================
utils/check-exact/ExactPrint.hs
=====================================
@@ -15,6 +15,7 @@
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE UndecidableInstances #-} -- For the (StmtLR GhcPs GhcPs (LocatedA (body GhcPs))) ExactPrint instance
+{-# OPTIONS_GHC -Wno-incomplete-uni-patterns #-}
module ExactPrint
(
@@ -2933,7 +2934,7 @@ instance ExactPrint (HsExpr GhcPs) where
exact (HsUntypedBracket an (DecBrL a e)) = do
an0 <- markEpAnnLMS an lidl AnnOpen (Just "[d|")
- an1 <- markEpAnnL an lidl AnnOpenC
+ an1 <- markEpAnnL an0 lidl AnnOpenC
e' <- markAnnotated e
an2 <- markEpAnnL an1 lidl AnnCloseC
an3 <- markEpAnnL an2 lidl AnnCloseQ -- "|]"
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c6a4a06ba483139beac68f9cbb2ef4627bbd79db...ca836a37b4ad45576452c09456ab57794fa797b1
--
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/c6a4a06ba483139beac68f9cbb2ef4627bbd79db...ca836a37b4ad45576452c09456ab57794fa797b1
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/20221216/2935822a/attachment-0001.html>
More information about the ghc-commits
mailing list