Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
147 changes: 137 additions & 10 deletions .github/workflows/reusable-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ env:
TZ: Asia/Singapore
EMSDK_VERSION: 3.1.74
MAKE_VERSION: 4.4
MAKE: gmake

jobs:
tool-output:
Expand Down Expand Up @@ -92,7 +93,8 @@ jobs:
run: |
${{ matrix.platform.installCmd }} curl bash git ${{ matrix.platform.toolRequirements }}

- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand Down Expand Up @@ -137,16 +139,24 @@ jobs:
run: &build |
set -eux

# On windows, we use msys2 shell, which does not by default inherit the windows PATHs.
# So although the ghcup action sets the PATH, it's not visible. We don't want to use
# 'pathtype: inherit', because it pollutes the msys2 paths, possibly leading to linking
# or other issues. So we just hardcode it here.
if [ ${{ runner.os }} = "Windows" ] ; then
export PATH="/c/ghcup/bin:$PATH"
fi

cabal update
if [ -e "emsdk" ] ; then
git config --system --add safe.directory $GITHUB_WORKSPACE
git config --system --add safe.directory '*'
cd emsdk
source ./emsdk_env.sh
cd ..
gmake CABAL=$PWD/_build/stage0/bin/cabal _build/bindist/haskell-toolchain.tar.gz _build/bindist/tests.tar.gz
${{ env.MAKE }} CABAL=$PWD/_build/stage0/bin/cabal _build/bindist/haskell-toolchain.tar.gz _build/bindist/tests.tar.gz
else
gmake CABAL=$PWD/_build/stage0/bin/cabal _build/bindist/ghc.tar.gz _build/bindist/cabal.tar.gz _build/bindist/tests.tar.gz
${{ env.MAKE }} CABAL=$PWD/_build/stage0/bin/cabal _build/bindist/ghc.tar.gz _build/bindist/cabal.tar.gz _build/bindist/tests.tar.gz
fi
cd _build/bindist
mv ghc.tar.gz ghc-$(bin/ghc --numeric-version)-${ARTIFACT}.tar.gz
Expand Down Expand Up @@ -233,7 +243,8 @@ jobs:
ref: ${{ matrix.branch }}
submodules: recursive

- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand Down Expand Up @@ -285,7 +296,8 @@ jobs:
ref: ${{ matrix.branch }}
submodules: recursive

- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand Down Expand Up @@ -317,6 +329,60 @@ jobs:
path: |
./_build/bindist/*.tar.gz

build-windows:
name: Build binary (Windows)
runs-on: windows-latest
env:
ADD_CABAL_ARGS: ""
ARTIFACT: "x86_64-mingw64"
ARCH: 64
CABAL_DIR: "C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
GHCUP_INSTALL_BASE_PREFIX: "C:\\"
GHCUP_MSYS2_ENV: CLANG64
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(inputs.branches) }}
defaults:
run:
shell: msys2 {0}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
submodules: recursive

- id: msys2
uses: msys2/setup-msys2@v2
with:
msystem: CLANG64
update: true
install: &msys2-install git vim winpty git tar bsdtar unzip binutils autoconf make xz curl libtool automake p7zip patch ca-certificates python3 zip mingw-w64-x86_64-gcc mingw-w64-x86_64-python-sphinx mingw-w64-x86_64-python-requests mingw-w64-x86_64-tools-git tar gzip

- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
ghc: ${{ env.GHC_VERSION }}
env:
GHCUP_MSYS2: ${{ steps.msys2.outputs.msys2-location }}

- name: Run build
run: *build
env:
MAKE: "make"

- if: always()
name: Upload artifact
uses: ./.github/actions/upload
with:
if-no-files-found: error
retention-days: 2
name: artifacts-${{ env.ARTIFACT }}-${{ matrix.branch }}
path: |
./_build/bindist/*.tar.gz

build-freebsd-x86_64:
name: Build FreeBSD x86_64
runs-on: [self-hosted, FreeBSD, X64]
Expand All @@ -337,7 +403,8 @@ jobs:
ref: ${{ matrix.branch }}
submodules: recursive

- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand Down Expand Up @@ -506,7 +573,8 @@ jobs:
- name: git clone fix
run: git config --system --add safe.directory $GITHUB_WORKSPACE

- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand All @@ -523,6 +591,14 @@ jobs:

- name: Run test
run: &test |
# On windows, we use msys2 shell, which does not by default inherit the windows PATHs.
# So although the ghcup action sets the PATH, it's not visible. We don't want to use
# 'pathtype: inherit', because it pollutes the msys2 paths, possibly leading to linking
# or other issues. So we just hardcode it here.
if [ ${{ runner.os }} = "Windows" ] ; then
export PATH="/c/ghcup/bin:$PATH"
fi

rm -rf .git
cd _build/bindist
for file in *.tar.gz; do tar xzf "$file"; done
Expand Down Expand Up @@ -587,7 +663,8 @@ jobs:
matrix:
branch: ${{ fromJSON(inputs.branches) }}
steps:
- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand Down Expand Up @@ -624,7 +701,8 @@ jobs:
matrix:
branch: ${{ fromJSON(inputs.branches) }}
steps:
- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand All @@ -645,6 +723,54 @@ jobs:
env:
THREADS: 4

test-windows:
name: Test binary (Windows)
runs-on: windows-latest
needs: ["build-windows"]
if: ${{ inputs.test }}
env:
ADD_CABAL_ARGS: ""
ARTIFACT: "x86_64-mingw64"
ARCH: 64
CABAL_DIR: "C:\\Users\\runneradmin\\AppData\\Roaming\\cabal"
GHCUP_INSTALL_BASE_PREFIX: "C:\\"
GHCUP_MSYS2_ENV: CLANG64
strategy:
fail-fast: false
matrix:
branch: ${{ fromJSON(inputs.branches) }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.branch }}
submodules: recursive

- id: msys2
uses: msys2/setup-msys2@v2
with:
msystem: CLANG64
update: true
install: *msys2-install

- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
ghc: ${{ env.GHC_VERSION }}
env:
GHCUP_MSYS2: ${{ steps.msys2.outputs.msys2-location }}

- uses: ./.github/actions/download
with:
name: artifacts-${{ env.ARTIFACT }}-${{ matrix.branch }}
path: ./_build/bindist

- name: Run test
run: *test
env:
THREADS: 4

test-freebsd-x86_64:
name: Test FreeBSD x86_64
runs-on: [self-hosted, FreeBSD, X64]
Expand All @@ -662,7 +788,8 @@ jobs:
matrix:
branch: ${{ fromJSON(inputs.branches) }}
steps:
- name: Install GHCup
- id: ghcup
name: Install GHCup
uses: haskell/ghcup-setup@v1
with:
cabal: ${{ env.CABAL_VERSION }}
Expand Down
61 changes: 36 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,14 @@ SED ?= sed

LD ?= ld

ifeq ($(OS),Windows_NT)
CC := clang.exe
CXX := clang++.exe
CYGPATH = cygpath --unix -f -
else
CYGPATH = cat
endif

EMCC ?= emcc
EMCXX ?= em++
EMAR ?= emar
Expand Down Expand Up @@ -251,9 +259,12 @@ STAGE2_UTIL_TARGETS := \
ghc-toolchain:ghc-toolchain \
integer-gmp:integer-gmp \
system-cxx-std-lib:system-cxx-std-lib \
terminfo:terminfo \
xhtml:xhtml

ifneq ($(OS),Windows_NT)
STAGE2_UTIL_TARGETS += terminfo:terminfo
endif

# These things should be built on demand.
# hp2ps:hp2ps \
# hpc-bin:hpc \
Expand Down Expand Up @@ -560,7 +571,7 @@ _build/stage0/bin/cabal:
@echo "::group::Building Cabal..."
@mkdir -p _build/stage0/bin _build/logs
cabal build $(BUILD_ARGS) cabal-install:exe:cabal
cp -rfp $(shell cabal list-bin -v0 $(BUILD_ARGS) cabal-install:exe:cabal) _build/stage0/bin/cabal
cp -rfp $(shell cabal list-bin -v0 $(BUILD_ARGS) cabal-install:exe:cabal | $(CYGPATH)) _build/stage0/bin/cabal
@echo "::endgroup::"

# --- Stage 1 build ---
Expand Down Expand Up @@ -618,8 +629,8 @@ $(addprefix _build/stage2/bin/,$(STAGE2_EXECUTABLES)) &: $(CABAL) stage1
@echo "::group::Building stage2 executables ($(STAGE2_EXECUTABLES))..."
# Force cabal to replan
rm -rf _build/stage2/cache
HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
PATH=$(PWD)/_build/stage1/bin:$(PATH) \
GHC=$(GHC) HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
PATH='$(PWD)/_build/stage1/bin:$(PATH)' \
$(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) $(STAGE2_TARGETS)
@echo "::endgroup::"

Expand All @@ -632,8 +643,8 @@ $(addprefix _build/stage2/bin/,$(STAGE2_UTIL_EXECUTABLES)) &: $(CABAL) stage1
@echo "::group::Building stage2 utilities ($(STAGE2_UTIL_EXECUTABLES))..."
# Force cabal to replan
rm -rf _build/stage2/cache
HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
PATH=$(PWD)/_build/stage1/bin:$(PATH) \
GHC=$(GHC) HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
PATH='$(PWD)/_build/stage1/bin:$(PATH)' \
$(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) $(STAGE2_UTIL_TARGETS)
@echo "::endgroup::"

Expand Down Expand Up @@ -705,7 +716,7 @@ _build/stage3/lib/targets/%/lib/ghc-interp.js:

# $1 = TIPLET
define build_cross
HADRIAN_SETTINGS='$(call HADRIAN_SETTINGS)' \
GHC=$(GHC) HADRIAN_SETTINGS='$(call HADRIAN_SETTINGS)' \
PATH=$(PWD)/_build/stage2/bin:$(PWD)/_build/stage3/bin:$(PATH) \
$(CABAL_BUILD) -W $(GHC2) --happy-options="--template=$(abspath _build/stage2/src/happy-lib-2.1.5/data/)" --with-hsc2hs=$1-hsc2hs --hsc2hs-options='-x' --configure-option='--host=$1' \
$(foreach lib,$(CROSS_EXTRA_LIB_DIRS),--extra-lib-dirs=$(lib)) \
Expand Down Expand Up @@ -837,26 +848,26 @@ define patchpackageconf
-e "s|data-dir:.*|data-dir: \"\$${pkgroot}/../lib/$4/$5$${sublib}\"|" \
-e "s|include-dirs:.*|include-dirs: \"\$${pkgroot}/../lib/$4/$5$${sublib}/include\"|" \
-e "s|^ /.*||" \
-e "s|^ [A-Z]:.*||" \
$2
endef

# $1 = triplet
define copycrosslib
@cp -rfp _build/stage3/lib/targets/$1 _build/bindist/lib/targets/
@cd _build/bindist/lib/targets/$1/lib/package.conf.d ; \
@ffi_incdir=`$(CURDIR)/_build/bindist/bin/$1-ghc-pkg field libffi-clib include-dirs | grep '/libffi-clib/src/' | sed 's|.*$(CURDIR)/||'` ; cd _build/bindist/lib/targets/$1/lib/package.conf.d ; \
for pkg in *.conf ; do \
pkgname=`echo $${pkg} | $(SED) 's/-[0-9.]*\(-[0-9a-zA-Z]*\)\?\.conf//'` ; \
pkgnamever=`echo $${pkg} | $(SED) 's/\.conf//'` ; \
mkdir -p $(CURDIR)/_build/bindist/lib/targets/$1/lib/$1/$${pkg%.conf} && \
cp -rfp $(CURDIR)/_build/stage3/$1/build/host/*/ghc-*/$${pkg%.conf}/build/* $(CURDIR)/_build/bindist/lib/targets/$1/lib/$1/$${pkg%.conf}/ && \
if [ $${pkgname} = "libffi-clib" ] ; then \
ffi_incdir=`$(CURDIR)/_build/bindist/bin/$1-ghc-pkg field libffi-clib include-dirs | grep '/libffi-clib/src/' | sed 's|.*$(CURDIR)/||'` ; \
$(call patchpackageconf,$${pkgname},$${pkg},../../..,$1,$${pkgnamever}) ; \
$(call copy_headers,ffitarget.h,$(CURDIR)/$${ffi_incdir},libffi-clib,$(CURDIR)/_build/bindist/bin/$1-ghc-pkg) ; \
else \
$(call patchpackageconf,$${pkgname},$${pkg},../../..,$1,$${pkgnamever}) ; \
fi ; \
done
done ; \
$(call copy_headers,ffitarget.h,$(CURDIR)/$${ffi_incdir},libffi-clib,$(CURDIR)/_build/bindist/bin/$1-ghc-pkg)
endef

# Target for creating the final binary distribution directory
Expand All @@ -870,20 +881,20 @@ _build/bindist: stage2 driver/ghc-usage.txt driver/ghci-usage.txt
# Copy libraries and settings from stage2 lib
@cp -rfp _build/stage2/lib/{package.conf.d,settings,template-hsc.h} $@/lib/
@mkdir -p $@/lib/$(HOST_PLATFORM)
@cd $@/lib/package.conf.d ; \
for pkg in *.conf ; do \
pkgname=`echo $${pkg} | $(SED) 's/-[0-9.]*\(-[0-9a-zA-Z]*\)\?\.conf//'` ; \
pkgnamever=`echo $${pkg} | $(SED) 's/\.conf//'` ; \
mkdir -p $(CURDIR)/$@/lib/$(HOST_PLATFORM)/$${pkg%.conf} ; \
cp -rfp $(CURDIR)/_build/stage2/build/host/*/ghc-*/$${pkg%.conf}/build/* $(CURDIR)/$@/lib/$(HOST_PLATFORM)/$${pkg%.conf} ; \
if [ $${pkgname} = "libffi-clib" ] ; then \
ffi_incdir=`$(CURDIR)/$@/bin/ghc-pkg field libffi-clib include-dirs | grep '/libffi-clib/src/' | sed 's|.*$(CURDIR)/||'` ; \
$(call patchpackageconf,$${pkgname},$${pkg},../../..,$(HOST_PLATFORM),$${pkgnamever}) ; \
$(call copy_headers,ffitarget.h,$(CURDIR)/$${ffi_incdir},libffi-clib,$(CURDIR)/$@/bin/ghc-pkg) ; \
else \
$(call patchpackageconf,$${pkgname},$${pkg},../../..,$(HOST_PLATFORM),$${pkgnamever}) ; \
fi ; \
done
@ffi_incdir=`$(CURDIR)/$@/bin/ghc-pkg field libffi-clib include-dirs | grep 'libffi-clib[/\\]src/' | sed 's/^[ \t]*//' | $(CYGPATH) | sed 's|.*$(CURDIR)/||'` ; \
cd $@/lib/package.conf.d ; \
for pkg in *.conf ; do \
pkgname=`echo $${pkg} | $(SED) 's/-[0-9.]*\(-[0-9a-zA-Z]*\)\?\.conf//'` ; \
pkgnamever=`echo $${pkg} | $(SED) 's/\.conf//'` ; \
mkdir -p $(CURDIR)/$@/lib/$(HOST_PLATFORM)/$${pkg%.conf} ; \
cp -rfp $(CURDIR)/_build/stage2/build/host/*/ghc-*/$${pkg%.conf}/build/* $(CURDIR)/$@/lib/$(HOST_PLATFORM)/$${pkg%.conf} ; \
if [ $${pkgname} = "libffi-clib" ] ; then \
$(call patchpackageconf,$${pkgname},$${pkg},../../..,$(HOST_PLATFORM),$${pkgnamever}) ; \
else \
$(call patchpackageconf,$${pkgname},$${pkg},../../..,$(HOST_PLATFORM),$${pkgnamever}) ; \
fi ; \
done ; \
$(call copy_headers,ffitarget.h,$(CURDIR)/$${ffi_incdir},libffi-clib,$(CURDIR)/$@/bin/ghc-pkg)
# Copy driver usage files
@cp -rfp driver/ghc-usage.txt $@/lib/
@cp -rfp driver/ghci-usage.txt $@/lib/
Expand Down
Loading
Loading