Skip to content

Commit 3cac14d

Browse files
committed
nativeGen: Explicitly set flags of text sections on Windows
The binutils documentation (for COFF) claims, > If no flags are specified, the default flags depend upon the section > name. If the section name is not recognized, the default will be for the > section to be loaded and writable. We previously assumed that this would do the right thing for split sections (e.g. a section named `.text$foo` would be correctly inferred to be a text section). However, we have observed that this is not the case (at least under the clang toolchain used on Windows): when split-sections is enabled, text sections are treated by the assembler as data (matching the "default" behavior specified by the documentation). Avoid this by setting section flags explicitly. This should fix split sections on Windows. Fixes #22834. (cherry picked from commit 3ece985)
1 parent f0b9bfa commit 3cac14d

File tree

5 files changed

+18
-15
lines changed

5 files changed

+18
-15
lines changed

.gitlab-ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -505,7 +505,7 @@ doc-tarball:
505505
optional: true
506506
- job: nightly-x86_64-windows-validate
507507
optional: true
508-
- job: release-x86_64-windows-release+no_split_sections
508+
- job: release-x86_64-windows-release
509509
optional: true
510510

511511
tags:
@@ -529,7 +529,7 @@ doc-tarball:
529529
|| mv "ghc-x86_64-linux-deb10-release.tar.xz" "$LINUX_BINDIST" \
530530
|| true
531531
mv "ghc-x86_64-windows-validate.tar.xz" "$WINDOWS_BINDIST" \
532-
|| mv "ghc-x86_64-windows-release+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \
532+
|| mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \
533533
|| true
534534
if [ ! -f "$LINUX_BINDIST" ]; then
535535
echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"

.gitlab/gen_ci.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ job_groups =
907907
-- This job is only for generating head.hackage docs
908908
, hackage_doc_job (disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) releaseConfig))
909909
, disableValidate (standardBuildsWithConfig Amd64 (Linux Fedora33) dwarf)
910-
, fastCI (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla))
911-
, disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt))
910+
, fastCI (standardBuildsWithConfig Amd64 Windows vanilla)
911+
, disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt)
912912
, standardBuilds Amd64 Darwin
913913
, allowFailureGroup (addValidateRule FreeBSDLabel (validateBuilds Amd64 FreeBSD13 vanilla))
914914
, standardBuilds AArch64 Darwin

.gitlab/jobs.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3349,7 +3349,7 @@
33493349
"XZ_OPT": "-9"
33503350
}
33513351
},
3352-
"release-x86_64-windows-int_native-release+no_split_sections": {
3352+
"release-x86_64-windows-int_native-release": {
33533353
"after_script": [
33543354
"bash .gitlab/ci.sh save_cache",
33553355
"bash .gitlab/ci.sh clean"
@@ -3358,7 +3358,7 @@
33583358
"artifacts": {
33593359
"expire_in": "1 year",
33603360
"paths": [
3361-
"ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz",
3361+
"ghc-x86_64-windows-int_native-release.tar.xz",
33623362
"junit.xml"
33633363
],
33643364
"reports": {
@@ -3396,20 +3396,20 @@
33963396
],
33973397
"variables": {
33983398
"BIGNUM_BACKEND": "native",
3399-
"BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections",
3400-
"BUILD_FLAVOUR": "release+no_split_sections",
3399+
"BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release",
3400+
"BUILD_FLAVOUR": "release",
34013401
"CABAL_INSTALL_VERSION": "3.8.1.0",
34023402
"CONFIGURE_ARGS": "",
34033403
"GHC_VERSION": "9.4.3",
34043404
"HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
34053405
"IGNORE_PERF_FAILURES": "all",
34063406
"LANG": "en_US.UTF-8",
34073407
"MSYSTEM": "CLANG64",
3408-
"TEST_ENV": "x86_64-windows-int_native-release+no_split_sections",
3408+
"TEST_ENV": "x86_64-windows-int_native-release",
34093409
"XZ_OPT": "-9"
34103410
}
34113411
},
3412-
"release-x86_64-windows-release+no_split_sections": {
3412+
"release-x86_64-windows-release": {
34133413
"after_script": [
34143414
"bash .gitlab/ci.sh save_cache",
34153415
"bash .gitlab/ci.sh clean"
@@ -3418,7 +3418,7 @@
34183418
"artifacts": {
34193419
"expire_in": "1 year",
34203420
"paths": [
3421-
"ghc-x86_64-windows-release+no_split_sections.tar.xz",
3421+
"ghc-x86_64-windows-release.tar.xz",
34223422
"junit.xml"
34233423
],
34243424
"reports": {
@@ -3456,16 +3456,16 @@
34563456
],
34573457
"variables": {
34583458
"BIGNUM_BACKEND": "gmp",
3459-
"BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections",
3460-
"BUILD_FLAVOUR": "release+no_split_sections",
3459+
"BIN_DIST_NAME": "ghc-x86_64-windows-release",
3460+
"BUILD_FLAVOUR": "release",
34613461
"CABAL_INSTALL_VERSION": "3.8.1.0",
34623462
"CONFIGURE_ARGS": "",
34633463
"GHC_VERSION": "9.4.3",
34643464
"HADRIAN_ARGS": "--hash-unit-ids --docs=no-sphinx",
34653465
"IGNORE_PERF_FAILURES": "all",
34663466
"LANG": "en_US.UTF-8",
34673467
"MSYSTEM": "CLANG64",
3468-
"TEST_ENV": "x86_64-windows-release+no_split_sections",
3468+
"TEST_ENV": "x86_64-windows-release",
34693469
"XZ_OPT": "-9"
34703470
}
34713471
},

compiler/GHC/CmmToAsm/Ppr.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,9 @@ pprGNUSectionHeader config t suffix =
245245
OtherSection _ ->
246246
panic "PprBase.pprGNUSectionHeader: unknown section type"
247247
flags = case t of
248+
Text
249+
| OSMinGW32 <- platformOS platform
250+
-> text ",\"xr\""
248251
CString
249252
| OSMinGW32 <- platformOS platform
250253
-> empty

nofib

Submodule nofib updated from 274cc3f to 2cee928

0 commit comments

Comments
 (0)