[Git][ghc/ghc][wip/freebsd] 9 commits: testsuite: Unmark T14028 as broken on FreeBSD

Ben Gamari (@bgamari) gitlab at gitlab.haskell.org
Tue Nov 19 02:28:04 UTC 2024



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


Commits:
918d8382 by Ben Gamari at 2024-11-18T21:27:54-05:00
testsuite: Unmark T14028 as broken on FreeBSD

This now appears to pass on FreeBSD 14.

Closes #19723.

- - - - -
d0cca7a2 by Ben Gamari at 2024-11-18T21:27:54-05:00
rts/linker: Fix out-of-bounds mapping logic

Previously the structure of `mmapInRegion` concealed a subtle bug
concerning handling of `mmap` returning mappings below the beginning of
the desired region. Specifically, we would reset `p = result + bytes`
and then again reset `p = region->start` before looping around for
another iteration. This resulted in an infinite loop on FreeBSD.

Fixes #25492.

- - - - -
d6c2bdef by Ben Gamari at 2024-11-18T21:27:55-05:00
rts/linker: Clarify debug output

- - - - -
d87a3a2e by Ben Gamari at 2024-11-18T21:27:55-05:00
gitlab-ci: Migrate FreeBSD runner tag to FreeBSD 14

- - - - -
54d87b9f by Ben Gamari at 2024-11-18T21:27:55-05:00
gitlab-ci: Reintroduce FreeBSD 14 job

- - - - -
aca7c175 by Ben Gamari at 2024-11-18T21:27:55-05:00
gitlab-ci: Allow use of newer cabal-install bindists

Newer cabal-install bindists have internal directory structure.
Here we detect and account for the presence of such structure.

- - - - -
57d5f89a by Ben Gamari at 2024-11-18T21:27:55-05:00
gitlab-ci: Enable documentation build on FreeBSD 14

- - - - -
b1ad635d by Ben Gamari at 2024-11-18T21:27:55-05:00
configure: Implement ld override whitelist

Bring `configure` into alignment with `ghc-toolchain`, ensuring that the
ld-override logic will only take effect on Linux and Windows.

Fixes #25501.

- - - - -
20268354 by Ben Gamari at 2024-11-18T21:27:56-05:00
gitlab-ci: Use system libffi

- - - - -


7 changed files:

- .gitlab/ci.sh
- .gitlab/generate-ci/gen_ci.hs
- .gitlab/jobs.yaml
- m4/find_ld.m4
- rts/Linker.c
- rts/linker/MMap.c
- testsuite/tests/quasiquotation/all.T


Changes:

=====================================
.gitlab/ci.sh
=====================================
@@ -325,13 +325,19 @@ function fetch_cabal() {
           local base_url="https://downloads.haskell.org/~cabal/cabal-install-$v/"
           case "$(uname)" in
             Darwin) cabal_url="$base_url/cabal-install-$v-x86_64-apple-darwin17.7.0.tar.xz" ;;
-            FreeBSD) cabal_url="$base_url/cabal-install-$v-x86_64-freebsd13.tar.xz" ;;
+            FreeBSD) cabal_url="$base_url/cabal-install-$v-x86_64-freebsd14.tar.xz" ;;
             *) fail "don't know where to fetch cabal-install for $(uname)"
           esac
           echo "Fetching cabal-install from $cabal_url"
           curl "$cabal_url" > cabal.tar.xz
+          tmp="$(tar -tJf cabal.tar.xz | head -n1)"
           $TAR -xJf cabal.tar.xz
-          mv cabal "$toolchain/bin"
+          # Check if the bindist has directory structure
+          if [[ "$tmp" = "cabal" ]]; then
+              mv cabal "$toolchain/bin"
+          else
+              mv "$tmp/cabal" "$toolchain/bin"
+          fi
           ;;
       esac
       end_section "fetch cabal"


=====================================
.gitlab/generate-ci/gen_ci.hs
=====================================
@@ -101,7 +101,7 @@ There are two different modes this  script can operate in:
 data Opsys
   = Linux LinuxDistro
   | Darwin
-  | FreeBSD13
+  | FreeBSD14
   | Windows deriving (Eq)
 
 data LinuxDistro
@@ -293,7 +293,7 @@ runnerTag arch (Linux _) =
 runnerTag AArch64 Darwin = "aarch64-darwin"
 runnerTag Amd64 Darwin = "x86_64-darwin-m1"
 runnerTag Amd64 Windows = "new-x86_64-windows"
-runnerTag Amd64 FreeBSD13 = "x86_64-freebsd13"
+runnerTag Amd64 FreeBSD14 = "x86_64-freebsd14"
 runnerTag _ _ = error "Invalid arch/opsys"
 
 tags :: Arch -> Opsys -> BuildConfig -> [String]
@@ -326,7 +326,7 @@ distroName Rocky8     = "rocky8"
 opsysName :: Opsys -> String
 opsysName (Linux distro) = "linux-" ++ distroName distro
 opsysName Darwin = "darwin"
-opsysName FreeBSD13 = "freebsd13"
+opsysName FreeBSD14 = "freebsd14"
 opsysName Windows = "windows"
 
 archName :: Arch -> String
@@ -416,15 +416,16 @@ type Variables = MonoidalMap String [String]
 a =: b = MonoidalMap (Map.singleton a [b])
 
 opsysVariables :: Arch -> Opsys -> Variables
-opsysVariables _ FreeBSD13 = mconcat
+opsysVariables _ FreeBSD14 = mconcat
   [ -- N.B. we use iconv from ports as I see linker errors when we attempt
     -- to use the "native" iconv embedded in libc as suggested by the
     -- porting guide [1].
     -- [1] https://www.freebsd.org/doc/en/books/porters-handbook/using-iconv.html)
-    "CONFIGURE_ARGS" =:  "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib"
-  , "HADRIAN_ARGS" =: "--docs=no-sphinx"
+    "CONFIGURE_ARGS" =: "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib"
+  , "CONFIGURE_ARGS" =: "--with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib"
+  , "CONFIGURE_ARGS" =: "--with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib"
   , "GHC_VERSION" =: "9.6.4"
-  , "CABAL_INSTALL_VERSION" =: "3.10.2.0"
+  , "CABAL_INSTALL_VERSION" =: "3.10.3.0"
   ]
 opsysVariables arch (Linux distro) = distroVariables arch distro
 opsysVariables AArch64 (Darwin {}) =
@@ -1130,6 +1131,11 @@ darwin =
   , fastCI (standardBuilds AArch64 Darwin)
   ]
 
+freebsd_jobs :: [JobGroup Job]
+freebsd_jobs =
+  [ addValidateRule FreeBSDLabel (standardBuilds Amd64 FreeBSD14)
+  ]
+
 alpine_x86 :: [JobGroup Job]
 alpine_x86 =
   [ -- Fully static build, in theory usable on any linux distribution.
@@ -1202,6 +1208,7 @@ job_groups =
   ++ alpine_x86
   ++ alpine_aarch64
   ++ cross_jobs
+  ++ freebsd_jobs
 
 
 mkPlatform :: Arch -> Opsys -> String


=====================================
.gitlab/jobs.yaml
=====================================
@@ -955,6 +955,70 @@
       "ac_cv_func_utimensat": "no"
     }
   },
+  "nightly-x86_64-freebsd14-validate": {
+    "after_script": [
+      ".gitlab/ci.sh save_cache",
+      ".gitlab/ci.sh save_test_output",
+      ".gitlab/ci.sh clean",
+      "cat ci_timings"
+    ],
+    "allow_failure": false,
+    "artifacts": {
+      "expire_in": "8 weeks",
+      "paths": [
+        "ghc-x86_64-freebsd14-validate.tar.xz",
+        "junit.xml",
+        "unexpected-test-output.tar.gz"
+      ],
+      "reports": {
+        "junit": "junit.xml"
+      },
+      "when": "always"
+    },
+    "cache": {
+      "key": "x86_64-freebsd14-$CACHE_REV",
+      "paths": [
+        "cabal-cache",
+        "toolchain"
+      ]
+    },
+    "dependencies": [],
+    "image": null,
+    "needs": [
+      {
+        "artifacts": false,
+        "job": "hadrian-ghc-in-ghci"
+      }
+    ],
+    "rules": [
+      {
+        "if": "(\"true\" == \"true\") && ($RELEASE_JOB != \"yes\") && ($NIGHTLY)",
+        "when": "on_success"
+      }
+    ],
+    "script": [
+      ".gitlab/ci.sh setup",
+      ".gitlab/ci.sh configure",
+      ".gitlab/ci.sh build_hadrian",
+      ".gitlab/ci.sh test_hadrian"
+    ],
+    "stage": "full-build",
+    "tags": [
+      "x86_64-freebsd14"
+    ],
+    "variables": {
+      "BIGNUM_BACKEND": "gmp",
+      "BIN_DIST_NAME": "ghc-x86_64-freebsd14-validate",
+      "BUILD_FLAVOUR": "validate",
+      "CABAL_INSTALL_VERSION": "3.10.3.0",
+      "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
+      "GHC_VERSION": "9.6.4",
+      "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
+      "RUNTEST_ARGS": "",
+      "TEST_ENV": "x86_64-freebsd14-validate",
+      "XZ_OPT": "-9"
+    }
+  },
   "nightly-x86_64-linux-alpine3_12-int_native-validate+fully_static": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
@@ -3651,6 +3715,72 @@
       "ac_cv_func_utimensat": "no"
     }
   },
+  "release-x86_64-freebsd14-release": {
+    "after_script": [
+      ".gitlab/ci.sh save_cache",
+      ".gitlab/ci.sh save_test_output",
+      ".gitlab/ci.sh clean",
+      "cat ci_timings"
+    ],
+    "allow_failure": false,
+    "artifacts": {
+      "expire_in": "1 year",
+      "paths": [
+        "ghc-x86_64-freebsd14-release.tar.xz",
+        "junit.xml",
+        "unexpected-test-output.tar.gz"
+      ],
+      "reports": {
+        "junit": "junit.xml"
+      },
+      "when": "always"
+    },
+    "cache": {
+      "key": "x86_64-freebsd14-$CACHE_REV",
+      "paths": [
+        "cabal-cache",
+        "toolchain"
+      ]
+    },
+    "dependencies": [],
+    "image": null,
+    "needs": [
+      {
+        "artifacts": false,
+        "job": "hadrian-ghc-in-ghci"
+      }
+    ],
+    "rules": [
+      {
+        "if": "(\"true\" == \"true\") && ($RELEASE_JOB == \"yes\") && ($NIGHTLY == null)",
+        "when": "on_success"
+      }
+    ],
+    "script": [
+      ".gitlab/ci.sh setup",
+      ".gitlab/ci.sh configure",
+      ".gitlab/ci.sh build_hadrian",
+      ".gitlab/ci.sh test_hadrian"
+    ],
+    "stage": "full-build",
+    "tags": [
+      "x86_64-freebsd14"
+    ],
+    "variables": {
+      "BIGNUM_BACKEND": "gmp",
+      "BIN_DIST_NAME": "ghc-x86_64-freebsd14-release",
+      "BUILD_FLAVOUR": "release",
+      "CABAL_INSTALL_VERSION": "3.10.3.0",
+      "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
+      "GHC_VERSION": "9.6.4",
+      "HADRIAN_ARGS": "--hash-unit-ids",
+      "IGNORE_PERF_FAILURES": "all",
+      "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
+      "RUNTEST_ARGS": "",
+      "TEST_ENV": "x86_64-freebsd14-release",
+      "XZ_OPT": "-9"
+    }
+  },
   "release-x86_64-linux-alpine3_12-int_native-release+fully_static": {
     "after_script": [
       ".gitlab/ci.sh save_cache",
@@ -5029,6 +5159,69 @@
       "ac_cv_func_utimensat": "no"
     }
   },
+  "x86_64-freebsd14-validate": {
+    "after_script": [
+      ".gitlab/ci.sh save_cache",
+      ".gitlab/ci.sh save_test_output",
+      ".gitlab/ci.sh clean",
+      "cat ci_timings"
+    ],
+    "allow_failure": false,
+    "artifacts": {
+      "expire_in": "2 weeks",
+      "paths": [
+        "ghc-x86_64-freebsd14-validate.tar.xz",
+        "junit.xml",
+        "unexpected-test-output.tar.gz"
+      ],
+      "reports": {
+        "junit": "junit.xml"
+      },
+      "when": "always"
+    },
+    "cache": {
+      "key": "x86_64-freebsd14-$CACHE_REV",
+      "paths": [
+        "cabal-cache",
+        "toolchain"
+      ]
+    },
+    "dependencies": [],
+    "image": null,
+    "needs": [
+      {
+        "artifacts": false,
+        "job": "hadrian-ghc-in-ghci"
+      }
+    ],
+    "rules": [
+      {
+        "if": "((($ONLY_JOBS) && ($ONLY_JOBS =~ /.*\\bx86_64-freebsd14-validate(\\s|$).*/)) || (($ONLY_JOBS == null) && ((($CI_MERGE_REQUEST_LABELS =~ /.*full-ci.*/) || ($CI_MERGE_REQUEST_LABELS =~ /.*marge_bot_batch_merge_job.*/) || ($CI_COMMIT_BRANCH == \"master\") || ($CI_COMMIT_BRANCH =~ /ghc-[0-9]+\\.[0-9]+/)) || ($CI_MERGE_REQUEST_LABELS =~ /.*FreeBSD.*/)))) && ($RELEASE_JOB != \"yes\") && ($NIGHTLY == null)",
+        "when": "on_success"
+      }
+    ],
+    "script": [
+      ".gitlab/ci.sh setup",
+      ".gitlab/ci.sh configure",
+      ".gitlab/ci.sh build_hadrian",
+      ".gitlab/ci.sh test_hadrian"
+    ],
+    "stage": "full-build",
+    "tags": [
+      "x86_64-freebsd14"
+    ],
+    "variables": {
+      "BIGNUM_BACKEND": "gmp",
+      "BIN_DIST_NAME": "ghc-x86_64-freebsd14-validate",
+      "BUILD_FLAVOUR": "validate",
+      "CABAL_INSTALL_VERSION": "3.10.3.0",
+      "CONFIGURE_ARGS": "--with-iconv-includes=/usr/local/include --with-iconv-libraries=/usr/local/lib --with-system-libffi --with-ffi-includes=/usr/local/include --with-ffi-libraries=/usr/local/lib --with-gmp-includes=/usr/local/include --with-gmp-libraries=/usr/local/lib --enable-strict-ghc-toolchain-check",
+      "GHC_VERSION": "9.6.4",
+      "INSTALL_CONFIGURE_ARGS": "--enable-strict-ghc-toolchain-check",
+      "RUNTEST_ARGS": "",
+      "TEST_ENV": "x86_64-freebsd14-validate"
+    }
+  },
   "x86_64-linux-alpine3_12-int_native-validate+fully_static": {
     "after_script": [
       ".gitlab/ci.sh save_cache",


=====================================
m4/find_ld.m4
=====================================
@@ -79,13 +79,16 @@ AC_DEFUN([FIND_LD],[
         dnl See #21712.
         AC_CHECK_TARGET_TOOL([LD], [ld])
         ;;
-    *)
+    *-linux|*-mingw32)
         if test "x$enable_ld_override" = "xyes"; then
             find_ld
         else
             AC_CHECK_TARGET_TOOL([LD], [ld])
         fi
         ;;
+    *)
+        AC_CHECK_TARGET_TOOL([LD], [ld])
+        ;;
     esac
     CHECK_LD_COPY_BUG([$1])
 ])


=====================================
rts/Linker.c
=====================================
@@ -1111,7 +1111,7 @@ freePreloadObjectFile (ObjectCode *oc)
  */
 void freeObjectCode (ObjectCode *oc)
 {
-    IF_DEBUG(linker, ocDebugBelch(oc, "start\n"));
+    IF_DEBUG(linker, ocDebugBelch(oc, "freeObjectCode: start\n"));
 
     // Run finalizers
     if (oc->type == STATIC_OBJECT &&


=====================================
rts/linker/MMap.c
=====================================
@@ -345,12 +345,7 @@ mmapInRegion (
         if (result == NULL) {
             // The mapping failed
             return NULL;
-        } else if (result < region->start) {
-            // Uh oh, we assume that mmap() will only give us a
-            // an address at or after the requested address.
-            // Try again.
-            p = (uint8_t *) result + bytes;
-        } else if (result < region->end) {
+        } else if (result >= region->start && result < region->end) {
             // Success!
             region->last = (uint8_t *) result + bytes;
             return result;
@@ -358,17 +353,23 @@ mmapInRegion (
             // We failed to find a suitable mapping
             munmap(result, bytes);
             reportMemoryMap();
-            errorBelch("mmapForLinker: failed to mmap() memory below 2Gb; "
+            errorBelch("mmapForLinker: failed to mmap() memory between %p and %p; "
                        "asked for %zu bytes at %p. "
                        "Try specifying an address with +RTS -xm<addr> -RTS",
-                       bytes, p);
+                       region->start, region->end, bytes, p);
             return NULL;
-        }
+        } else if (result < region->start) {
+            // Uh oh, we assume that mmap() will only give us a
+            // an address at or after the requested address.
+            // Try again.
+            p = (uint8_t *) result + bytes;
+        } else if (result >= region->end) {
+            // mmap() gave us too high an address; wrap around and try again
+            wrapped = true;
+            p = region->start;
+       }
 
-        // mmap() gave us too high an address; wrap around and try again
         munmap(result, bytes);
-        wrapped = true;
-        p = region->start;
     }
 }
 


=====================================
testsuite/tests/quasiquotation/all.T
=====================================
@@ -8,6 +8,5 @@ test('T7918',
 test('T14028',
      [req_interp, req_rts_linker,
       only_ways([config.ghc_th_way]),
-      unless(config.have_ext_interp, skip),
-      when(opsys('freebsd'), expect_broken(19723))],
+      unless(config.have_ext_interp, skip)],
      makefile_test, ['T14028 ghcThWayFlags=' + config.ghc_th_way_flags])



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3b79cd0bb4de55b3e88679913c28b9513a3c4e9a...202683543bde9edb3267ff61b0f990dd61f88b33

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/3b79cd0bb4de55b3e88679913c28b9513a3c4e9a...202683543bde9edb3267ff61b0f990dd61f88b33
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/20241118/0a2420a7/attachment-0001.html>


More information about the ghc-commits mailing list