Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f918fec
ci: add dynamic build/test matrix (DYNAMIC=0/1) and restrict push tri…
angerman Sep 4, 2025
6131ef0
ci: trigger also on stable-master branch
angerman Sep 4, 2025
9d770e4
Add the geenrated stage2.settings file to .gitignore.
angerman Sep 12, 2025
86f0f57
makefile: Stop rebuilding everything when running the test-suite
angerman Sep 12, 2025
66e260c
Do not auto-link unlit (which is effectively a .c only utility.
angerman Sep 15, 2025
b103d82
compiler/rts: prelink archive threshold
angerman Sep 15, 2025
81b1580
Revert "compiler/rts: prelink archive threshold"
angerman Sep 15, 2025
20f14f1
rts: move cmm sources into common section, and move them into sublibs
angerman Sep 15, 2025
26a1007
rts: Add no-ghc-internal flag
angerman Sep 15, 2025
b60cbda
rts: Better AutoApply logic
angerman Sep 15, 2025
38af39d
Makefile: symlink dylibs
angerman Sep 16, 2025
aed1df3
rts.cabal: double all the flags to ensure we definetly get them set
angerman Sep 16, 2025
f270d6e
testsuite: Make sure we prefix the ghcconfig with a hash
angerman Sep 16, 2025
1967f08
testsuite: Add explicit flushs [WRONG!]
angerman Sep 16, 2025
41b298d
fixup! rts.cabal: double all the flags to ensure we definetly get the…
angerman Sep 17, 2025
49ce37f
makefile: symlink ghc-iserv-dyn <- ghc-iserv
angerman Sep 17, 2025
9e4cf80
fixup! makefile: symlink ghc-iserv-dyn <- ghc-iserv
angerman Sep 17, 2025
0c7e99d
testsuite: improve logging; also check non-inplace libraries.
angerman Sep 17, 2025
6a9fa8a
fixup! testsuite: improve logging; also check non-inplace libraries.
angerman Sep 17, 2025
b54cf12
testsuite: disable rts test, which is invalid since the rts split.
angerman Sep 19, 2025
cf05f6e
testsuite: T2228 does not appear broken.
angerman Sep 19, 2025
a03584d
compiler: inject rpath for the rts as needed.
angerman Sep 19, 2025
8c7a84c
fixup! compiler: inject rpath for the rts as needed.
angerman Sep 19, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 37 additions & 22 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
name: CI
name: Nix CI

# Trigger the workflow on push or pull request, but only for the master branch
on:
pull_request:
types:
- opened
- synchronize
types: [opened, synchronize]
push:
branches: [master]

branches: [stable-ghc-9.14, stable-master]
workflow_dispatch:

jobs:
cabal:
name: ${{ matrix.plat }} / ghc ${{ matrix.ghc }}
runs-on: "${{ fromJSON('{\"x86_64-linux\": \"ubuntu-24.04\", \"aarch64-linux\": \"ubuntu-24.04-arm\", \"x86_64-darwin\": \"macos-latest\", \"aarch64-darwin\": \"macos-latest\"}')[matrix.plat] }}"

strategy:
fail-fast: false
matrix:
plat:
- x86_64-linux
# - aarch64-linux # disabled: waiting for devx images to be fixed
# - x86_64-darwin # disabled: waiting for devx images to be fixed
- aarch64-darwin
ghc: ['98'] # bootstrapping compiler
include:
- plat: x86_64-linux
runner: ubuntu-24.04
ghc: '98'
dynamic: 0
- plat: x86_64-linux
runner: ubuntu-24.04
ghc: '98'
dynamic: 1
# - plat: aarch64-linux # disabled: waiting for devx images to be fixed
# runner: ubuntu-24.04-arm
# ghc: '98'
# dynamic: 0
# - plat: aarch64-linux
# runner: ubuntu-24.04-arm
# ghc: '98'
# dynamic: 1
- plat: aarch64-darwin
runner: macos-latest
ghc: '98'
dynamic: 0
- plat: aarch64-darwin
runner: macos-latest
ghc: '98'
dynamic: 1

name: "${{ matrix.plat }} / ghc ${{ matrix.ghc }} / dynamic=${{ matrix.dynamic }}"
runs-on: ${{ matrix.runner }}

steps:
- uses: actions/checkout@v4
Expand All @@ -50,25 +65,25 @@ jobs:
# shell: devx {0}
# run: ./configure

- name: Build the bindist
- name: Build the bindist (dynamic=${{ matrix.dynamic }})
shell: devx {0}
run: make CABAL=$PWD/_build/stage0/bin/cabal
run: make CABAL=$PWD/_build/stage0/bin/cabal DYNAMIC=${{ matrix.dynamic }}

- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.plat }}-bindist
name: ${{ matrix.plat }}-dynamic${{ matrix.dynamic }}-bindist
path: _build/bindist

- name: Run the testsuite
- name: Run the testsuite (dynamic=${{ matrix.dynamic }})
shell: devx {0}
run: make test CABAL=$PWD/_build/stage0/bin/cabal
run: make test CABAL=$PWD/_build/stage0/bin/cabal DYNAMIC=${{ matrix.dynamic }}

- name: Upload test results
uses: actions/upload-artifact@v4
if: ${{ !cancelled() }} # upload test results even if the testsuite failed to pass
with:
name: ${{ matrix.plat }}-testsuite-results
name: ${{ matrix.plat }}-dynamic${{ matrix.dynamic }}-testsuite-results
path: |
_build/test-perf.csv
_build/test-summary.txt
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,4 @@ ghc.nix/
# clangd
.clangd
dist-newstyle/
cabal.project.stage2.settings
23 changes: 19 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -879,6 +879,16 @@ _build/bindist: stage2 driver/ghc-usage.txt driver/ghci-usage.txt
$@/bin/ghc-pkg recache
# Copy headers
@$(call copy_all_stage2_h,$@/bin/ghc-pkg)
# Add basename symlinks for nested shared libs (.dylib, .so) in lib/$(HOST_PLATFORM)
@if [ -d "$@/lib/$(HOST_PLATFORM)" ]; then \
cd "$@/lib/$(HOST_PLATFORM)" ; \
for lib in $$(find . -mindepth 2 \( -name "*.dylib" -o -name "*.so" \) -type f) ; do \
ln -sf "$$lib" "$$(basename "$$lib")" ; \
done ; \
fi
# Create -dyn iserv executable. #FIXME: THIS IS IDIOTIC!
@cd "$@/bin"
@ln -sf ghc-iserv ghc-iserv-dyn
@echo "::endgroup::"

_build/bindist/ghc.tar.gz: _build/bindist
Expand All @@ -903,6 +913,13 @@ _build/bindist/lib/targets/%: _build/bindist driver/ghc-usage.txt driver/ghci-us
# Copy libraries and settings
@if [ -e $(CURDIR)/_build/bindist/lib/targets/$(@F)/lib/$(@F) ] ; then find $(CURDIR)/_build/bindist/lib/targets/$(@F)/lib/$(@F)/ -mindepth 1 -type f -name "*.so" -execdir mv '{}' $(CURDIR)/_build/bindist/lib/targets/$(@F)/lib/$(@F)/'{}' \; ; fi
$(call copycrosslib,$(@F))
# Add basename symlinks for nested shared libs (.dylib, .so) in lib/$(@F)
@if [ -d $(CURDIR)/_build/bindist/lib/targets/$(@F)/lib/$(@F) ] ; then \
cd $(CURDIR)/_build/bindist/lib/targets/$(@F)/lib/$(@F) ; \
for lib in $$(find . -mindepth 2 \( -name "*.dylib" -o -name "*.so" \) -type f) ; do \
ln -sf "$$lib" "$$(basename "$$lib")" ; \
done ; \
fi
# --help
@cp -rfp driver/ghc-usage.txt _build/bindist/lib/targets/$(@F)/lib/
@cp -rfp driver/ghci-usage.txt _build/bindist/lib/targets/$(@F)/lib/
Expand Down Expand Up @@ -1033,13 +1050,11 @@ CANONICAL_TEST_HC_OPTS = \
-Werror=compat -dno-debug-output

# Build timeout utility (needed for some tests) if not already built.
.PHONY: testsuite-timeout
testsuite-timeout:
testsuite/timeout/install-inplace/bin/timeout:
$(MAKE) -C testsuite/timeout


# --- Test Target ---
test: _build/bindist testsuite-timeout
test: $(TEST_GHC) $(TEST_GHC_PKG) $(TEST_HP2PS) $(TEST_HPC) $(TEST_RUN_GHC) testsuite/timeout/install-inplace/bin/timeout
@echo "::group::Running tests with THREADS=$(THREADS)" >&2
# If any required tool is missing, testsuite logic will skip related tests.
TEST_HC='$(TEST_GHC)' \
Expand Down
3 changes: 2 additions & 1 deletion compiler/GHC/Driver/DynFlags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,8 @@ packageFlagsChanged idflags1 idflags0 =
[ Opt_HideAllPackages
, Opt_HideAllPluginPackages
, Opt_AutoLinkPackages
, Opt_NoRts ]
, Opt_NoRts
, Opt_NoGhcInternal ]

instance Outputable PackageFlag where
ppr (ExposePackage n arg rn) = text n <> braces (ppr arg <+> ppr rn)
Expand Down
1 change: 1 addition & 0 deletions compiler/GHC/Driver/Flags.hs
Original file line number Diff line number Diff line change
Expand Up @@ -863,6 +863,7 @@ data GeneralFlag
-- temporary flags
| Opt_AutoLinkPackages
| Opt_NoRts
| Opt_NoGhcInternal
| Opt_ImplicitImportQualified

-- keeping stuff
Expand Down
2 changes: 2 additions & 0 deletions compiler/GHC/Driver/Session.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1314,6 +1314,8 @@ dynamic_flags_deps = [
(NoArg (setGeneralFlag Opt_NoHsMain))
, make_ord_flag defGhcFlag "no-rts"
(NoArg (setGeneralFlag Opt_NoRts))
, make_ord_flag defGhcFlag "no-ghc-internal"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this needed now?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have the following dependeny as visible to cabal:

ghc-internal
+ rts

however, ghc will try to insert:

ghc-internal
+ rts-sublib (based on the -threaded / -debug flag)
  + rts

If we try to build the rts-sublib with ghc, we can end up trying to load ghc-internal, due to auto-injection of libraries.

Maybe a better solution is to add a flag to outright disable ghc's auto population of libs, instead of having separate ones for each lib 😅

(NoArg (setGeneralFlag Opt_NoGhcInternal))
, make_ord_flag defGhcFlag "fno-state-hack"
(NoArg (setGeneralFlag Opt_G_NoStateHack))
, make_ord_flag defGhcFlag "fno-opt-coercion"
Expand Down
19 changes: 15 additions & 4 deletions compiler/GHC/Linker/Static.hs
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,22 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
-- explicit packages with the auto packages and all of their
-- dependencies, and eliminating duplicates.
pkgs <- mayThrowUnitErr (preloadUnitsInfo' unit_env dep_units)

-- Collect per-package library dirs (deduplicated, non-empty)
let pkg_lib_paths = collectLibraryDirs ways_ pkgs
let pkg_lib_path_opts = concatMap get_pkg_lib_path_opts pkg_lib_paths
get_pkg_lib_path_opts l
-- Until: https://github.com/haskell/cabal/issues/11221 is in cabal,
-- we have to deal with cabal passing -dyload deploy, and manually
-- inject rpaths for the rts.
-- Build linker options per (pkg, libdir)
let pkg_lib_path_opts =
concat
[ get_pkg_lib_path_opts pkg l
| pkg <- pkgs
, l <- collectLibraryDirs ways_ [pkg]
]
get_pkg_lib_path_opts pkg l
| osElfTarget (platformOS platform) &&
dynLibLoader dflags == SystemDependent &&
(dynLibLoader dflags == SystemDependent || unitPackageNameString pkg == "rts") &&
ways_ `hasWay` WayDyn
= let libpath = if gopt Opt_RelativeDynlibPaths dflags
then "$ORIGIN" </>
Expand All @@ -125,7 +136,7 @@ linkBinary' staticLink logger tmpfs dflags unit_env o_files dep_units = do
else ["-Xlinker", "-rpath-link", "-Xlinker", l]
in ["-L" ++ l] ++ rpathlink ++ rpath
| osMachOTarget (platformOS platform) &&
dynLibLoader dflags == SystemDependent &&
(dynLibLoader dflags == SystemDependent || unitPackageNameString pkg == "rts") &&
ways_ `hasWay` WayDyn &&
useXLinkerRPath dflags (platformOS platform)
= let libpath = if gopt Opt_RelativeDynlibPaths dflags
Expand Down
11 changes: 9 additions & 2 deletions compiler/GHC/Unit/State.hs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,7 +1636,11 @@ mkUnitState logger dflags cfg = do
-- it modifies the unit ids of wired in packages, but when we process
-- package arguments we need to key against the old versions.
--
(pkgs2, wired_map) <- findWiredInUnits logger (rtsWayUnitId dflags:wiredInUnitIds) prec_map pkgs1 vis_map2
let wired_ids_all = rtsWayUnitId dflags : wiredInUnitIds
wired_ids
| gopt Opt_NoGhcInternal dflags = filter (/= ghcInternalUnitId) wired_ids_all
| otherwise = wired_ids_all
(pkgs2, wired_map) <- findWiredInUnits logger wired_ids prec_map pkgs1 vis_map2

--
-- Sanity check. If the rtsWayUnitId is not in the database, then we have a
Expand All @@ -1648,6 +1652,7 @@ mkUnitState logger dflags cfg = do
, nest 2 $ vcat
[ text "pkgs1_count =" <+> ppr (length pkgs1)
, text "Opt_NoRts =" <+> ppr (gopt Opt_NoRts dflags)
, text "Opt_NoGhcInternal =" <+> ppr (gopt Opt_NoGhcInternal dflags)
, text "ghcLink =" <+> text (show (ghcLink dflags))
, text "platform =" <+> text (show (targetPlatform dflags))
, text "rtsWayUnitId=" <+> ppr (rtsWayUnitId dflags)
Expand All @@ -1664,7 +1669,9 @@ mkUnitState logger dflags cfg = do
<> text " Please check your installation."
<> text " If this target doesn't need the RTS (e.g. building a shared library), you can add -no-rts to the relevant package's ghc-options in cabal.project to bypass this check."

let pkgs3 = if gopt Opt_NoRts dflags && not (anyUniqMap (== ghcInternalUnitId) wired_map)
let pkgs3 = if gopt Opt_NoGhcInternal dflags
then pkgs2
else if gopt Opt_NoRts dflags && not (anyUniqMap (== ghcInternalUnitId) wired_map)
then pkgs2
else
-- At this point we should have `ghcInternalUnitId`, and the `rtsWiredUnitId dflags`.
Expand Down
1 change: 1 addition & 0 deletions rts/AutoApply.cmm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <rts/AutoApply.cmm.h>
1 change: 1 addition & 0 deletions rts/AutoApply_V16.cmm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <rts/AutoApply_V16.cmm.h>
1 change: 1 addition & 0 deletions rts/AutoApply_V32.cmm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <rts/AutoApply_V32.cmm.h>
1 change: 1 addition & 0 deletions rts/AutoApply_V64.cmm
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include <rts/AutoApply_V64.cmm.h>
24 changes: 12 additions & 12 deletions rts/configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -583,36 +583,36 @@ else
AC_MSG_ERROR([Failed to run $DERIVE_CONSTANTS --gen-header ...])
fi

AC_MSG_CHECKING([for AutoApply.cmm])
if $GENAPPLY include/DerivedConstants.h > AutoApply.cmm; then
AC_MSG_CHECKING([for include/rts/AutoApply.cmm.h])
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h > include/rts/AutoApply.cmm.h; then
AC_MSG_RESULT([created])
else
AC_MSG_RESULT([failed to create])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h > AutoApply.cmm])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h > include/rts/AutoApply.cmm.h])
fi

AC_MSG_CHECKING([for AutoApply_V16.cmm])
if $GENAPPLY include/DerivedConstants.h -V16 > AutoApply_V16.cmm; then
AC_MSG_CHECKING([for include/rts/AutoApply_V16.cmm.h])
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h -V16 > include/rts/AutoApply_V16.cmm.h; then
AC_MSG_RESULT([created])
else
AC_MSG_RESULT([failed to create])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V16 > AutoApply_V16.cmm])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V16 > include/rts/AutoApply_V16.cmm.h])
fi

AC_MSG_CHECKING([for AutoApply_V32.cmm])
if $GENAPPLY include/DerivedConstants.h -V32 > AutoApply_V32.cmm; then
AC_MSG_CHECKING([for include/rts/AutoApply_V32.cmm.h])
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h -V32 > include/rts/AutoApply_V32.cmm.h; then
AC_MSG_RESULT([created])
else
AC_MSG_RESULT([failed to create])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V32 > AutoApply_V32.cmm])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V32 > include/rts/AutoApply_V32.cmm.h])
fi

AC_MSG_CHECKING([for AutoApply_V64.cmm])
if $GENAPPLY include/DerivedConstants.h -V64 > AutoApply_V64.cmm; then
AC_MSG_CHECKING([for include/rts/AutoApply_V64.cmm.h])
if mkdir -p include/rts && $GENAPPLY include/DerivedConstants.h -V64 > include/rts/AutoApply_V64.cmm.h; then
AC_MSG_RESULT([created])
else
AC_MSG_RESULT([failed to create])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V64 > AutoApply_V64.cmm])
AC_MSG_ERROR([Failed to run $GENAPPLY include/DerivedConstants.h -V64 > include/rts/AutoApply_V64.cmm.h])
fi

AC_MSG_CHECKING([for include/rts/EventLogConstants.h])
Expand Down
Loading
Loading