[Git][ghc/ghc][wip/T22834] 2 commits: nativeGen: Explicitly set flags of text sections on Windows

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Wed Jan 25 17:36:09 UTC 2023



Ben Gamari pushed to branch wip/T22834 at Glasgow Haskell Compiler / GHC


Commits:
93414617 by Ben Gamari at 2023-01-25T12:36:02-05:00
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.

- - - - -
6496a458 by Ben Gamari at 2023-01-25T12:36:02-05:00
nativeGen: Explicitly set section types

TODO

- - - - -


4 changed files:

- .gitlab-ci.yml
- .gitlab/gen_ci.hs
- .gitlab/jobs.yaml
- compiler/GHC/CmmToAsm/Ppr.hs


Changes:

=====================================
.gitlab-ci.yml
=====================================
@@ -498,7 +498,7 @@ doc-tarball:
       optional: true
     - job: nightly-x86_64-windows-validate
       optional: true
-    - job: release-x86_64-windows-release+no_split_sections
+    - job: release-x86_64-windows-release
       optional: true
 
   tags:
@@ -522,7 +522,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+no_split_sections.tar.xz" "$WINDOWS_BINDIST" \
+        || mv "ghc-x86_64-windows-release.tar.xz" "$WINDOWS_BINDIST" \
         || true
       if [ ! -f "$LINUX_BINDIST" ]; then
         echo "Error: $LINUX_BINDIST does not exist. Did the Debian 9 job fail?"


=====================================
.gitlab/gen_ci.hs
=====================================
@@ -196,9 +196,6 @@ vanilla = BuildConfig
   , noSplitSections = False
   }
 
-splitSectionsBroken :: BuildConfig -> BuildConfig
-splitSectionsBroken bc = bc { noSplitSections = True }
-
 nativeInt :: BuildConfig
 nativeInt = vanilla { bignumBackend = Native }
 
@@ -859,25 +856,25 @@ job_groups =
      , 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 (standardBuildsWithConfig Amd64 (Linux Debian9) (splitSectionsBroken vanilla))
+     , disableValidate (standardBuildsWithConfig Amd64 (Linux Debian9) vanilla)
      , disableValidate (standardBuilds Amd64 (Linux Ubuntu2004))
      , disableValidate (standardBuilds Amd64 (Linux Rocky8))
-     , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) (splitSectionsBroken vanilla))
+     , disableValidate (standardBuildsWithConfig Amd64 (Linux Centos7) 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 (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken vanilla))
-     , disableValidate (standardBuildsWithConfig Amd64 Windows (splitSectionsBroken nativeInt))
+     , fastCI (standardBuildsWithConfig Amd64 Windows vanilla)
+     , disableValidate (standardBuildsWithConfig Amd64 Windows nativeInt)
      , standardBuilds Amd64 Darwin
      , allowFailureGroup (addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD13))
      , standardBuilds AArch64 Darwin
-     , standardBuildsWithConfig AArch64 (Linux Debian10) (splitSectionsBroken vanilla)
+     , standardBuildsWithConfig AArch64 (Linux Debian10) vanilla
      , disableValidate (validateBuilds AArch64 (Linux Debian10) llvm)
-     , standardBuildsWithConfig I386 (Linux Debian9) (splitSectionsBroken vanilla)
-     , standardBuildsWithConfig Amd64 (Linux Alpine) (splitSectionsBroken static)
+     , standardBuildsWithConfig I386 (Linux Debian9) vanilla
+     , standardBuildsWithConfig Amd64 (Linux Alpine) 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
=====================================
@@ -2113,7 +2113,7 @@
       "XZ_OPT": "-9"
     }
   },
-  "release-aarch64-linux-deb10-release+no_split_sections": {
+  "release-aarch64-linux-deb10-release": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh clean",
@@ -2123,7 +2123,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-aarch64-linux-deb10-release+no_split_sections.tar.xz",
+        "ghc-aarch64-linux-deb10-release.tar.xz",
         "junit.xml"
       ],
       "reports": {
@@ -2165,15 +2165,15 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release+no_split_sections",
-      "BUILD_FLAVOUR": "release+no_split_sections",
+      "BIN_DIST_NAME": "ghc-aarch64-linux-deb10-release",
+      "BUILD_FLAVOUR": "release",
       "CONFIGURE_ARGS": "",
       "IGNORE_PERF_FAILURES": "all",
-      "TEST_ENV": "aarch64-linux-deb10-release+no_split_sections",
+      "TEST_ENV": "aarch64-linux-deb10-release",
       "XZ_OPT": "-9"
     }
   },
-  "release-i386-linux-deb9-release+no_split_sections": {
+  "release-i386-linux-deb9-release": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh clean",
@@ -2183,7 +2183,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-i386-linux-deb9-release+no_split_sections.tar.xz",
+        "ghc-i386-linux-deb9-release.tar.xz",
         "junit.xml"
       ],
       "reports": {
@@ -2225,11 +2225,11 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-i386-linux-deb9-release+no_split_sections",
-      "BUILD_FLAVOUR": "release+no_split_sections",
+      "BIN_DIST_NAME": "ghc-i386-linux-deb9-release",
+      "BUILD_FLAVOUR": "release",
       "CONFIGURE_ARGS": "",
       "IGNORE_PERF_FAILURES": "all",
-      "TEST_ENV": "i386-linux-deb9-release+no_split_sections",
+      "TEST_ENV": "i386-linux-deb9-release",
       "XZ_OPT": "-9"
     }
   },
@@ -2425,7 +2425,7 @@
       "XZ_OPT": "-9"
     }
   },
-  "release-x86_64-linux-alpine3_12-release+fully_static+no_split_sections": {
+  "release-x86_64-linux-alpine3_12-release+fully_static": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh clean",
@@ -2435,7 +2435,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections.tar.xz",
+        "ghc-x86_64-linux-alpine3_12-release+fully_static.tar.xz",
         "junit.xml"
       ],
       "reports": {
@@ -2478,18 +2478,18 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static+no_split_sections",
+      "BIN_DIST_NAME": "ghc-x86_64-linux-alpine3_12-release+fully_static",
       "BROKEN_TESTS": "encoding004 T10458 ghcilink002 linker_unload_native",
-      "BUILD_FLAVOUR": "release+fully_static+no_split_sections",
+      "BUILD_FLAVOUR": "release+fully_static",
       "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+no_split_sections",
+      "TEST_ENV": "x86_64-linux-alpine3_12-release+fully_static",
       "XZ_OPT": "-9"
     }
   },
-  "release-x86_64-linux-centos7-release+no_split_sections": {
+  "release-x86_64-linux-centos7-release": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh clean",
@@ -2499,7 +2499,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-x86_64-linux-centos7-release+no_split_sections.tar.xz",
+        "ghc-x86_64-linux-centos7-release.tar.xz",
         "junit.xml"
       ],
       "reports": {
@@ -2541,12 +2541,12 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release+no_split_sections",
-      "BUILD_FLAVOUR": "release+no_split_sections",
+      "BIN_DIST_NAME": "ghc-x86_64-linux-centos7-release",
+      "BUILD_FLAVOUR": "release",
       "CONFIGURE_ARGS": "",
       "HADRIAN_ARGS": "--docs=no-sphinx",
       "IGNORE_PERF_FAILURES": "all",
-      "TEST_ENV": "x86_64-linux-centos7-release+no_split_sections",
+      "TEST_ENV": "x86_64-linux-centos7-release",
       "XZ_OPT": "-9"
     }
   },
@@ -2730,7 +2730,7 @@
       "XZ_OPT": "-9"
     }
   },
-  "release-x86_64-linux-deb9-release+no_split_sections": {
+  "release-x86_64-linux-deb9-release": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
       ".gitlab/ci.sh clean",
@@ -2740,7 +2740,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-x86_64-linux-deb9-release+no_split_sections.tar.xz",
+        "ghc-x86_64-linux-deb9-release.tar.xz",
         "junit.xml"
       ],
       "reports": {
@@ -2782,11 +2782,11 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release+no_split_sections",
-      "BUILD_FLAVOUR": "release+no_split_sections",
+      "BIN_DIST_NAME": "ghc-x86_64-linux-deb9-release",
+      "BUILD_FLAVOUR": "release",
       "CONFIGURE_ARGS": "",
       "IGNORE_PERF_FAILURES": "all",
-      "TEST_ENV": "x86_64-linux-deb9-release+no_split_sections",
+      "TEST_ENV": "x86_64-linux-deb9-release",
       "XZ_OPT": "-9"
     }
   },
@@ -3098,7 +3098,7 @@
       "XZ_OPT": "-9"
     }
   },
-  "release-x86_64-windows-int_native-release+no_split_sections": {
+  "release-x86_64-windows-int_native-release": {
     "after_script": [
       "bash .gitlab/ci.sh save_cache",
       "bash .gitlab/ci.sh clean"
@@ -3107,7 +3107,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-x86_64-windows-int_native-release+no_split_sections.tar.xz",
+        "ghc-x86_64-windows-int_native-release.tar.xz",
         "junit.xml"
       ],
       "reports": {
@@ -3145,8 +3145,8 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "native",
-      "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release+no_split_sections",
-      "BUILD_FLAVOUR": "release+no_split_sections",
+      "BIN_DIST_NAME": "ghc-x86_64-windows-int_native-release",
+      "BUILD_FLAVOUR": "release",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
       "CONFIGURE_ARGS": "",
       "GHC_VERSION": "9.4.3",
@@ -3154,11 +3154,11 @@
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
       "MSYSTEM": "CLANG64",
-      "TEST_ENV": "x86_64-windows-int_native-release+no_split_sections",
+      "TEST_ENV": "x86_64-windows-int_native-release",
       "XZ_OPT": "-9"
     }
   },
-  "release-x86_64-windows-release+no_split_sections": {
+  "release-x86_64-windows-release": {
     "after_script": [
       "bash .gitlab/ci.sh save_cache",
       "bash .gitlab/ci.sh clean"
@@ -3167,7 +3167,7 @@
     "artifacts": {
       "expire_in": "1 year",
       "paths": [
-        "ghc-x86_64-windows-release+no_split_sections.tar.xz",
+        "ghc-x86_64-windows-release.tar.xz",
         "junit.xml"
       ],
       "reports": {
@@ -3205,8 +3205,8 @@
     ],
     "variables": {
       "BIGNUM_BACKEND": "gmp",
-      "BIN_DIST_NAME": "ghc-x86_64-windows-release+no_split_sections",
-      "BUILD_FLAVOUR": "release+no_split_sections",
+      "BIN_DIST_NAME": "ghc-x86_64-windows-release",
+      "BUILD_FLAVOUR": "release",
       "CABAL_INSTALL_VERSION": "3.8.1.0",
       "CONFIGURE_ARGS": "",
       "GHC_VERSION": "9.4.3",
@@ -3214,7 +3214,7 @@
       "IGNORE_PERF_FAILURES": "all",
       "LANG": "en_US.UTF-8",
       "MSYSTEM": "CLANG64",
-      "TEST_ENV": "x86_64-windows-release+no_split_sections",
+      "TEST_ENV": "x86_64-windows-release",
       "XZ_OPT": "-9"
     }
   },


=====================================
compiler/GHC/CmmToAsm/Ppr.hs
=====================================
@@ -245,6 +245,10 @@ pprGNUSectionHeader config t suffix =
       OtherSection _ ->
         panic "PprBase.pprGNUSectionHeader: unknown section type"
     flags = case t of
+      Text
+        | OSMinGW32 <- platformOS platform
+                    -> text ",\"xr\""
+        | otherwise -> text ",\"ax\"," <> sectionType platform "progbits"
       CString
         | OSMinGW32 <- platformOS platform
                     -> empty



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16336e05d88f08be08fefd106cd0aa9bf3b22504...6496a458aeb04e3e4e08a616b7c10f25f666091b

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/16336e05d88f08be08fefd106cd0aa9bf3b22504...6496a458aeb04e3e4e08a616b7c10f25f666091b
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/20230125/cbb7005d/attachment-0001.html>


More information about the ghc-commits mailing list