diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000000..9c4b65f3c273 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,75 @@ +name: CI + +# Trigger the workflow on push or pull request, but only for the master branch +on: + pull_request: + types: + - opened + - synchronize + push: + branches: [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 + + steps: + - uses: actions/checkout@v4 + with: + submodules: "recursive" + + - uses: input-output-hk/actions/devx@latest + with: + platform: ${{ matrix.plat }} + compiler-nix-name: 'ghc98' + minimal: true + ghc: true + + - name: Update hackage + shell: devx {0} + run: cabal update + + # The Makefile will run configure (and boot ๐Ÿ˜ž), we also need to create a + # synthetic package before running configure. Once this nuissance is fixed + # we can do proper configure + make again. Until then... we have to live + # with the hack of running everything from the make target. + # - name: Configure the build + # shell: devx {0} + # run: ./configure + + - name: Build the bindist + shell: devx {0} + run: make CABAL=$PWD/_build/stage0/bin/cabal + + - name: Upload artifacts + uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.plat }}-bindist + path: _build/bindist + + - name: Run the testsuite + shell: devx {0} + run: make test CABAL=$PWD/_build/stage0/bin/cabal + + - 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 + path: | + _build/test-perf.csv + _build/test-summary.txt + _build/test-junit.xml diff --git a/.gitignore b/.gitignore index a96f6c05bb1b..f6d6b0bc9006 100644 --- a/.gitignore +++ b/.gitignore @@ -221,6 +221,9 @@ missing-win32-tarballs VERSION GIT_COMMIT_ID +/libraries/ghc-boot-th-next/.synth-stamp +/libraries/ghc-boot-th-next/ghc-boot-th-next.cabal.in + # ------------------------------------------------------------------------------------- # when using a docker image, one can mount the source code directory as the home folder # ------------------------------------------------------------------------------------- diff --git a/Makefile b/Makefile new file mode 100644 index 000000000000..20837cbea965 --- /dev/null +++ b/Makefile @@ -0,0 +1,1063 @@ +# Top-level Makefile +# +# This file is still _TOO_ large (should be < 100L). There are too many moving +# _global_ parts, most of this should be relegated to the respective packages. +# The whole version replacement therapy is utterly ridiculous. It should be done +# in the respective packages. + +# โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” +# โ”‚ GHC Bootstrapping Stages โ”‚ +# โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค +# โ”‚ โ”‚ +# โ”‚ Stage 0 (Bootstrap) โ”‚ +# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +# โ”‚ โ”‚ ghc0 โ”‚ โ”‚ pkg0 โ”‚ (initial boot packages) โ”‚ +# โ”‚ โ”‚ (binary)โ”‚ โ”‚ โ”‚ โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ”‚ โ”‚ โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ–ผ โ”‚ +# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +# โ”‚ โ”‚ pkg0+ โ”‚ (augmented boot packages) โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ”‚ โ”‚ +# โ”‚ ยทยทยทยทยทยทยทยทยทยทยทยทโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท โ”‚ +# โ”‚ โ–ผ โ”‚ +# โ”‚ Stage 1 โ”‚ โ”‚ +# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ +# โ”‚ โ”‚ ghc1 โ”‚โ—„โ”˜ (built with ghc0, linked with rts0) โ”‚ +# โ”‚ โ”‚ โ”‚ โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ”‚ โ”‚ +# โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ–บโ”‚ pkg1 โ”‚ (initially empty, then populated) โ”‚ +# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”‚ โ”‚ (built with ghc1) โ”‚ +# โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ”‚ โ–ฒ โ”‚ +# โ”‚ โ”‚ โ”‚ (mutual dependency; ghc1 needs to sees pkg1) โ”‚ +# โ”‚ โ–ผ โ”‚ โ”‚ +# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ +# โ”‚ โ”‚ ghc1 โ”‚โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ”‚ (uses) โ”‚ โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ”‚ โ”‚ +# โ”‚ ยทยทยทยทยทโ”‚ยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยทยท โ”‚ +# โ”‚ โ–ผ โ”‚ +# โ”‚ Stage 2 โ”‚ +# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +# โ”‚ โ”‚ ghc2 โ”‚ โ”‚ ghc-pkg2 โ”‚ โ”‚ ... โ”‚ โ”‚ +# โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ (built with ghc1, linked with rts1) โ”‚ +# โ”‚ โ”‚ +# โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ +# โ”‚ โ”‚ SHIPPED RESULT โ”‚ โ”‚ +# โ”‚ โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ +# โ”‚ โ”‚ โ”‚ pkg1 โ”‚ + โ”‚ ghc2 โ”‚ โ”‚ โ”‚ +# โ”‚ โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ โ”‚ +# โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚ +# โ”‚ โ”‚ +# โ”‚ Notes: โ”‚ +# โ”‚ โ€ข Binaries: one stage ahead (ghc1 builds pkg1, ghc2 ships with pkg1) โ”‚ +# โ”‚ โ€ข Libraries: one stage below (pkg1 ships with ghc2) โ”‚ +# โ”‚ โ€ข ghc1 and ghc2 are ABI compatible | +# | โ€ข ghc0 and ghc1 are not guaruateed to be ABI compatible | +# โ”‚ โ€ข ghc1 is linked against rts0, ghc2 against rts1 โ”‚ +# | โ€ข augmented packages are needed because ghc1 may require newer | +# | versions or even new pacakges, not shipped with the boot compiler | +# โ”‚ โ”‚ +# โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ + + +# ISSUES: +# - [ ] Where do we get the version number from? The configure script _does_ contain +# one and sets it, but should it come from the last release tag this branch is +# contains? +# - [ ] HADRIAN_SETTINGS needs to be removed. +# - [ ] The hadrian folder needs to be removed. +# - [ ] All sublibs should be SRPs in the relevant cabal.project files. No more +# submodules. + +SHELL := bash +.SHELLFLAGS := -eu -o pipefail -c + +VERBOSE ?= 0 + +# Enable dynamic runtime/linking support when DYNAMIC=1 is passed on the make +# command line. This will build shared libraries, a dynamic RTS (defining +# -DDYNAMIC) and allow tests requiring dynamic linking (e.g. plugins-external) +# to run. The default remains static to keep rebuild cost low. +DYNAMIC ?= 0 + +# If using autoconf feature toggles you can instead run: +# ./configure --enable-dynamic --enable-profiling --enable-debug +# which generates cabal.project.stage2.settings (imported by cabal.project.stage2). +# The legacy DYNAMIC=1 path still appends flags directly; if both are used the +# configure-generated settings file (import) and these args should agree. + +ROOT_DIR := $(patsubst %/,%,$(dir $(realpath $(lastword $(MAKEFILE_LIST))))) + +GHC0 ?= ghc-9.8.4 +PYTHON ?= python3 +CABAL ?= cabal + +LD ?= ld + +EMCC ?= emcc +EMCXX ?= em++ +EMAR ?= emar +EMRANLIB ?= emranlib + +GHC_CONFIGURE_ARGS ?= + +EXTRA_LIB_DIRS ?= +EXTRA_INCLUDE_DIRS ?= + +MUSL_EXTRA_LIB_DIRS ?= +MUSL_EXTRA_INCLUDE_DIRS ?= + +JS_EXTRA_LIB_DIRS ?= +JS_EXTRA_INCLUDE_DIRS ?= + +WASM_EXTRA_LIB_DIRS ?= +WASM_EXTRA_INCLUDE_DIRS ?= +WASM_CC_OPTS = -fno-strict-aliasing -Wno-error=int-conversion -Oz -msimd128 -mnontrapping-fptoint -msign-ext -mbulk-memory -mmutable-globals -mmultivalue -mreference-types +WASM_CXX_OPTS = -fno-exceptions -fno-strict-aliasing -Wno-error=int-conversion -Oz -msimd128 -mnontrapping-fptoint -msign-ext -mbulk-memory -mmutable-globals -mmultivalue -mreference-types + +# :exploding-head: It turns out override doesn't override the command-line +# value but it overrides Make's normal behavior of ignoring assignments to +# command-line variables. This allows the += operations to append to whatever +# was passed from the command line. + +override CABAL_ARGS += \ + --remote-repo-cache _build/packages \ + --store-dir=_build/$(STAGE)/$(TARGET_PLATFORM)/store \ + --logs-dir=_build/$(STAGE)/logs + +override CABAL_BUILD_ARGS += \ + -j -w $(GHC) --with-gcc=$(CC) --with-ld=$(LD) \ + --project-file=cabal.project.$(STAGE) \ + $(foreach lib,$(EXTRA_LIB_DIRS),--extra-lib-dirs=$(lib)) \ + $(foreach include,$(EXTRA_INCLUDE_DIRS),--extra-include-dirs=$(include)) \ + --builddir=_build/$(STAGE)/$(TARGET_PLATFORM) \ + --ghc-options="-fhide-source-paths" + +ifeq ($(DYNAMIC),1) +GHC_CONFIGURE_ARGS += --enable-dynamic +endif + +GHC_TOOLCHAIN_ARGS ?= --disable-ld-override + +# just some defaults +STAGE ?= stage1 +GHC ?= $(GHC0) + +CABAL_BUILD = $(CABAL) $(CABAL_ARGS) build $(CABAL_BUILD_ARGS) + +GHC1 = _build/stage1/bin/ghc +GHC2 = _build/stage2/bin/ghc + +define GHC_INFO +$(shell sh -c "$(GHC) --info | $(GHC0) -e 'getContents >>= foldMap putStrLn . lookup \"$1\" . read'") +endef + +HOST_PLATFORM = $(call GHC_INFO,Host platform) +TARGET_PLATFORM = $(call GHC_INFO,target platform string) +TARGET_ARCH = $(call GHC_INFO,target arch) +TARGET_OS = $(call GHC_INFO,target os) +TARGET_TRIPLE = $(call GHC_INFO,Target platform) +GIT_COMMIT_ID := $(shell git rev-parse HEAD) + +define HADRIAN_SETTINGS +[ ("hostPlatformArch", "$(TARGET_ARCH)") \ +, ("hostPlatformOS", "$(TARGET_OS)") \ +, ("cProjectGitCommitId", "$(GIT_COMMIT_ID)") \ +, ("cProjectVersion", "9.14") \ +, ("cProjectVersionInt", "914") \ +, ("cProjectPatchLevel", "0") \ +, ("cProjectPatchLevel1", "0") \ +, ("cProjectPatchLevel2", "0") \ +] +endef + +# Handle CPUS and THREADS +CPUS_DETECT_SCRIPT := ./mk/detect-cpu-count.sh +CPUS := $(shell if [ -x $(CPUS_DETECT_SCRIPT) ]; then $(CPUS_DETECT_SCRIPT); else echo 2; fi) +THREADS ?= $(shell echo $$(( $(CPUS) + 1 ))) + +# Files that will be generated by config.status from their .in counterparts +# FIXME: This is stupid. Why do we patch versions across multiple libraries? Idiotic. +# also, why on earth do we use a non standard SnakeCase convention for substitutions +# when CAPITAL_CASE is the standard? +CONFIGURED_FILES := \ + ghc/ghc-bin.cabal \ + compiler/ghc.cabal \ + libraries/ghc-boot/ghc-boot.cabal \ + libraries/ghc-boot-th/ghc-boot-th.cabal \ + libraries/ghc-heap/ghc-heap.cabal \ + libraries/template-haskell/template-haskell.cabal \ + libraries/ghci/ghci.cabal \ + utils/ghc-pkg/ghc-pkg.cabal \ + utils/ghc-iserv/ghc-iserv.cabal \ + utils/runghc/runghc.cabal \ + libraries/ghc-internal/ghc-internal.cabal \ + libraries/ghc-experimental/ghc-experimental.cabal \ + libraries/base/base.cabal \ + rts/include/ghcversion.h + +# --- Main Targets --- +all: _build/bindist # booted will depend on prepare-sources + +STAGE_UTIL_TARGETS := \ + deriveConstants:deriveConstants \ + genapply:genapply \ + genprimopcode:genprimopcode \ + ghc-pkg:ghc-pkg \ + hsc2hs:hsc2hs \ + rts-headers:rts-headers \ + unlit:unlit + +STAGE1_TARGETS := $(STAGE_UTIL_TARGETS) ghc-bin:ghc ghc-toolchain-bin:ghc-toolchain-bin + +# TODO: dedup +STAGE1_EXECUTABLES := \ + deriveConstants \ + genapply \ + genprimopcode \ + ghc \ + ghc-pkg \ + ghc-toolchain-bin \ + hsc2hs \ + unlit + +# We really want to work towards `cabal build/instsall ghc-bin:ghc`. +STAGE2_TARGETS := \ + ghc-bin:ghc + +# rts:threaded-nodebug need it for compiling Setup.hs +STAGE2_UTIL_TARGETS := \ + $(STAGE_UTIL_TARGETS) \ + ghc-iserv:ghc-iserv \ + rts:nonthreaded-debug \ + rts:nonthreaded-nodebug \ + rts:threaded-nodebug \ + hp2ps:hp2ps \ + hpc-bin:hpc \ + runghc:runghc \ + ghc-bignum:ghc-bignum \ + ghc-compact:ghc-compact \ + ghc-experimental:ghc-experimental \ + ghc-toolchain:ghc-toolchain \ + integer-gmp:integer-gmp \ + system-cxx-std-lib:system-cxx-std-lib \ + terminfo:terminfo \ + xhtml:xhtml + +# These things should be built on demand. +# hp2ps:hp2ps \ +# hpc-bin:hpc \ +# ghc-iserv:ghc-iserv \ +# runghc:runghc \ + +# This package is just utterly retarded +# I don't understand why this following line somehow breaks the build... +# STAGE2_TARGETS += system-cxx-std-lib:system-cxx-std-lib + +# TODO: dedup +STAGE2_EXECUTABLES := \ + ghc + +STAGE2_UTIL_EXECUTABLES := \ + deriveConstants \ + genapply \ + genprimopcode \ + hsc2hs \ + ghc-iserv \ + ghc-pkg \ + hp2ps \ + hpc \ + runghc \ + unlit + +BINDIST_EXECTUABLES := \ + ghc \ + ghc-iserv \ + ghc-pkg \ + hp2ps \ + hpc \ + hsc2hs \ + runghc + +STAGE3_LIBS := \ + rts:nonthreaded-nodebug \ + Cabal \ + Cabal-syntax \ + array \ + base \ + binary \ + bytestring \ + containers \ + deepseq \ + directory \ + exceptions \ + file-io \ + filepath \ + ghc-bignum \ + ghci \ + hpc \ + integer-gmp \ + mtl \ + os-string \ + parsec \ + pretty \ + process \ + stm \ + template-haskell \ + text \ + time \ + transformers \ + xhtml + +# --- Source headers --- +# TODO: this is a hack, because of https://github.com/haskell/cabal/issues/11172 +# +# $1 = headers +# $2 = source base dirs +# $3 = pkgname +# $4 = ghc-pkg +define copy_headers + set -e; \ + dest=`$4 field $3 include-dirs | awk '{ print $$2 }'` ;\ + for h in $1 ; do \ + mkdir -p "$$dest/`dirname $$h`" ; \ + for sdir in $2 ; do \ + if [ -e "$$sdir/$$h" ] ; then \ + cp -frp "$$sdir/$$h" "$$dest/$$h" ; \ + break ; \ + fi ; \ + done ; \ + [ -e "$$dest/$$h" ] || { echo "Copying $$dest/$$h failed... tried source dirs $2" >&2 ; exit 2 ; } ; \ + done +endef + +RTS_HEADERS_H := \ + rts/Bytecodes.h \ + rts/storage/ClosureTypes.h \ + rts/storage/FunTypes.h \ + stg/MachRegs.h \ + stg/MachRegs/arm32.h \ + stg/MachRegs/arm64.h \ + stg/MachRegs/loongarch64.h \ + stg/MachRegs/ppc.h \ + stg/MachRegs/riscv64.h \ + stg/MachRegs/s390x.h \ + stg/MachRegs/wasm32.h \ + stg/MachRegs/x86.h + +define copy_rts_headers_h + $(call copy_headers,$(RTS_HEADERS_H),rts-headers/include/,rts-headers,$1) +endef + +RTS_FS_H := \ + fs.h + +define copy_rts_fs_h + $(call copy_headers,$(RTS_FS_H),rts-fs/,rts-fs,$1) +endef + +RTS_H := \ + Cmm.h \ + HsFFI.h \ + MachDeps.h \ + Jumps.h \ + Rts.h \ + RtsAPI.h \ + RtsSymbols.h \ + Stg.h \ + ghcconfig.h \ + ghcversion.h \ + rts/ghc_ffi.h \ + rts/Adjustor.h \ + rts/ExecPage.h \ + rts/BlockSignals.h \ + rts/Config.h \ + rts/Constants.h \ + rts/EventLogFormat.h \ + rts/EventLogWriter.h \ + rts/FileLock.h \ + rts/Flags.h \ + rts/ForeignExports.h \ + rts/GetTime.h \ + rts/Globals.h \ + rts/Hpc.h \ + rts/IOInterface.h \ + rts/Libdw.h \ + rts/LibdwPool.h \ + rts/Linker.h \ + rts/Main.h \ + rts/Messages.h \ + rts/NonMoving.h \ + rts/OSThreads.h \ + rts/Parallel.h \ + rts/PrimFloat.h \ + rts/Profiling.h \ + rts/IPE.h \ + rts/PosixSource.h \ + rts/Signals.h \ + rts/SpinLock.h \ + rts/StableName.h \ + rts/StablePtr.h \ + rts/StaticPtrTable.h \ + rts/TTY.h \ + rts/Threads.h \ + rts/Ticky.h \ + rts/Time.h \ + rts/Timer.h \ + rts/TSANUtils.h \ + rts/Types.h \ + rts/Utils.h \ + rts/prof/CCS.h \ + rts/prof/Heap.h \ + rts/prof/LDV.h \ + rts/storage/Block.h \ + rts/storage/ClosureMacros.h \ + rts/storage/Closures.h \ + rts/storage/Heap.h \ + rts/storage/HeapAlloc.h \ + rts/storage/GC.h \ + rts/storage/InfoTables.h \ + rts/storage/MBlock.h \ + rts/storage/TSO.h \ + stg/DLL.h \ + stg/MiscClosures.h \ + stg/Prim.h \ + stg/Regs.h \ + stg/SMP.h \ + stg/Ticky.h \ + stg/MachRegsForHost.h \ + stg/Types.h + +RTS_H_DIRS := \ + rts/ \ + rts/include/ + +define copy_rts_h + $(call copy_headers,$(RTS_H),$(RTS_H_DIRS),rts,$1) +endef + +RTS_JS_H := \ + HsFFI.h \ + MachDeps.h \ + Rts.h \ + RtsAPI.h \ + Stg.h \ + ghcconfig.h \ + ghcversion.h \ + stg/MachRegsForHost.h \ + stg/Types.h + +define copy_rts_js_h + $(call copy_headers,$(RTS_JS_H),rts/include/,rts,$1) +endef + +HASKELINE_H := \ + win_console.h + +define copy_haskeline_h + $(call copy_headers,$(HASKELINE_H),libraries/haskeline/includes,haskeline,$1) +endef + +WIN32_H := \ + HsWin32.h \ + HsGDI.h \ + WndProc.h \ + windows_cconv.h \ + alphablend.h \ + wincon_compat.h \ + winternl_compat.h \ + winuser_compat.h \ + winreg_compat.h \ + tlhelp32_compat.h \ + winnls_compat.h \ + winnt_compat.h \ + namedpipeapi_compat.h + +define copy_win32_h + $(call copy_headers,$(WIN32_H),libraries/Win32/include/,Win32,$1) +endef + +GHC_INTERNAL_H := \ + HsBase.h \ + consUtils.h + +define copy_ghc_internal_h + $(call copy_headers,$(GHC_INTERNAL_H),libraries/ghc-internal/include/,ghc-internal,$1) +endef + +PROCESS_H := \ + runProcess.h \ + processFlags.h + +define copy_process_h + $(call copy_headers,$(PROCESS_H),libraries/process/include/,process,$1) +endef + +BYTESTRING_H := \ + fpstring.h \ + bytestring-cpp-macros.h + +define copy_bytestring_h + $(call copy_headers,$(BYTESTRING_H),libraries/bytestring/include/,bytestring,$1) +endef + +TIME_H := \ + HsTime.h + +define copy_time_h + $(call copy_headers,$(TIME_H),libraries/time/lib/include/,time,$1) +endef + +UNIX_H := \ + HsUnix.h \ + execvpe.h + +define copy_unix_h + $(call copy_headers,$(UNIX_H),libraries/unix/include/,unix,$1) +endef + +define copy_all_stage3_h + $(call copy_rts_headers_h,$1) + $(call copy_rts_fs_h,$1) + $(call copy_rts_h,$1) + if [ "$2" = "javascript-unknown-ghcjs" ] ; then $(call copy_rts_js_h,$1) ; fi + $(call copy_ghc_internal_h,$1) + $(call copy_process_h,$1) + $(call copy_bytestring_h,$1) + $(call copy_time_h,$1) + if [ "$(OS)" = "Windows_NT" ] ; then $(call copy_win32_h,$1) ; else $(call copy_unix_h,$1) ; fi +endef + +define copy_all_stage2_h + $(call copy_all_stage3_h,$1,none) + $(call copy_haskeline_h,$1) +endef + + +# --- Bootstrapping and stage 0 --- + +# export CABAL := $(shell cabal update 2>&1 >/dev/null && cabal build cabal-install -v0 --disable-tests --project-dir libraries/Cabal && cabal list-bin -v0 --project-dir libraries/Cabal cabal-install:exe:cabal) +$(abspath _build/stage0/bin/cabal): _build/stage0/bin/cabal + +# --- Stage 0 build --- + +# This just builds cabal-install, which is used to build the rest of the project. + +# We need an absolute path here otherwise cabal will consider the path relative to `the project directory +_build/stage0/bin/cabal: BUILD_ARGS=-j -w $(GHC0) --disable-tests --project-dir libraries/Cabal --builddir=$(abspath _build/stage0) --ghc-options="-fhide-source-paths" +_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 + @echo "::endgroup::" + +# --- Stage 1 build --- + +_build/stage1/%: private STAGE=stage1 +_build/stage1/%: private GHC=$(GHC0) + +.PHONY: $(addprefix _build/stage1/bin/,$(STAGE1_EXECUTABLES)) +$(addprefix _build/stage1/bin/,$(STAGE1_EXECUTABLES)) &: private TARGET_PLATFORM= +$(addprefix _build/stage1/bin/,$(STAGE1_EXECUTABLES)) &: $(CABAL) configure rts/configure libraries/ghc-internal/configure + @echo "::group::Building stage1 executables ($(STAGE1_EXECUTABLES))..." + # Force cabal to replan + rm -rf _build/stage1/cache + HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' $(CABAL_BUILD) $(STAGE1_TARGETS) + @echo "::endgroup::" + +_build/stage1/lib/settings: _build/stage1/bin/ghc-toolchain-bin + @echo "::group::Creating settings for $(TARGET_TRIPLE)..." + @mkdir -p $(@D) + _build/stage1/bin/ghc-toolchain-bin $(GHC_TOOLCHAIN_ARGS) --triple $(TARGET_TRIPLE) --output-settings -o $@ --cc $(CC) --cxx $(CXX) + @echo "::endgroup::" + +# The somewhat strange thing is, we might not even need this at all now anymore. cabal seems to +# pass all the necessary flags correctly. Thus even with an _empty_ package-db here (and it will +# stay empty until we are done with the build), the build succeeds. +# +# For now, we are tying the knot here by making sure the stage1 compiler (stage1/bin/ghc) sees +# the packages it builds (to build stage2/bin/ghc), by symlining cabal's target package-db into +# the compilers global package-db. Another maybe even better solution might be to set the +# Global Package DB in the settings file to the absolute path where cabal will place the +# package db. This would elminate this rule outright. +_build/stage1/lib/package.conf.d/package.cache: _build/stage1/bin/ghc-pkg _build/stage1/lib/settings + @echo "::group::Creating stage1 package cache..." + @mkdir -p _build/stage1/lib/package.conf.d +# @mkdir -p _build/stage2/packagedb/host +# ln -s $(abspath ./_build/stage2/packagedb/host/ghc-9.14) _build/stage1/lib/package.conf.d +# _build/stage1/bin/ghc-pkg init $(abspath ./_build/stage2/packagedb/host/ghc-9.14) + @echo "::endgroup::" + +_build/stage1/lib/template-hsc.h: utils/hsc2hs/data/template-hsc.h + @mkdir -p $(@D) + cp -rfp $< $@ + +.PHONY: stage1 +stage1: $(addprefix _build/stage1/bin/,$(STAGE1_EXECUTABLES)) _build/stage1/lib/settings _build/stage1/lib/package.conf.d/package.cache _build/stage1/lib/template-hsc.h + +# --- Stage 2 build --- + +_build/stage2/%: private STAGE=stage2 +_build/stage2/%: private GHC=$(realpath _build/stage1/bin/ghc) + +.PHONY: $(addprefix _build/stage2/bin/,$(STAGE2_EXECUTABLES)) +$(addprefix _build/stage2/bin/,$(STAGE2_EXECUTABLES)) &: private TARGET_PLATFORM= +$(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) \ + $(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) $(STAGE2_TARGETS) + @echo "::endgroup::" + +# Do we want to build these with the stage2 GHC or the stage1 GHC? +# Traditionally we build them with the stage1 ghc, but we could just as well +# build them with the stage2 ghc; seems like a better/cleaner idea to me (moritz). +.PHONY: $(addprefix _build/stage2/bin/,$(STAGE2_UTIL_EXECUTABLES)) +$(addprefix _build/stage2/bin/,$(STAGE2_UTIL_EXECUTABLES)) &: private TARGET_PLATFORM= +$(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) \ + $(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) $(STAGE2_UTIL_TARGETS) + @echo "::endgroup::" + +_build/stage2/lib/settings: _build/stage1/lib/settings + @mkdir -p $(@D) + cp -rfp _build/stage1/lib/settings _build/stage2/lib/settings + +_build/stage2/lib/package.conf.d/package.cache: _build/stage2/bin/ghc-pkg _build/stage2/lib/settings + @echo "::group::Creating stage2 package cache..." + @mkdir -p _build/stage2/lib/package.conf.d + @rm -rf _build/stage2/lib/package.conf.d/* + cp -rfp _build/stage2/packagedb/host/*/* _build/stage2/lib/package.conf.d + _build/stage2/bin/ghc-pkg recache + @echo "::endgroup::" + +_build/stage2/lib/template-hsc.h: utils/hsc2hs/data/template-hsc.h + @mkdir -p $(@D) + cp -rfp $< $@ + +.PHONY: stage2 +stage2: $(addprefix _build/stage2/bin/,$(STAGE2_EXECUTABLES)) _build/stage2/lib/settings _build/stage2/lib/package.conf.d/package.cache _build/stage2/lib/template-hsc.h + +# --- Stage 3 generic --- + +_build/stage2/lib/targets/%: + @mkdir -p _build/stage3/lib/targets/$(@F) + @rm -f _build/stage2/lib/targets/$(@F) + @mkdir -p _build/stage2/lib/targets/ + @ln -sf ../../../stage3/lib/targets/$(@F) _build/stage2/lib/targets/$(@F) + +_build/stage3/bin/%-ghc-pkg: _build/stage2/bin/ghc-pkg + @mkdir -p $(@D) + @ln -sf ../../stage2/bin/ghc-pkg $@ + +_build/stage3/bin/%-ghc: _build/stage2/bin/ghc + @mkdir -p $(@D) + @ln -sf ../../stage2/bin/ghc $@ + +_build/stage3/bin/%-hsc2hs: _build/stage2/bin/hsc2hs + @mkdir -p $(@D) + @ln -sf ../../stage2/bin/hsc2hs $@ + +_build/stage3/lib/targets/%/lib/package.conf.d: _build/stage3/lib/targets/% + @mkdir -p $@ + +# ghc-toolchain borks unlit +_build/stage3/lib/targets/%/bin/unlit: _build/stage2/bin/unlit + @mkdir -p $(@D) + cp -rfp $< $@ + +_build/stage3/lib/targets/%/lib/dyld.mjs: + @mkdir -p $(@D) + @cp -f utils/jsffi/dyld.mjs $@ + @chmod +x $@ + +_build/stage3/lib/targets/%/lib/post-link.mjs: + @mkdir -p $(@D) + @cp -f utils/jsffi/post-link.mjs $@ + @chmod +x $@ + +_build/stage3/lib/targets/%/lib/prelude.mjs: + @mkdir -p $(@D) + @cp -f utils/jsffi/prelude.mjs $@ + @chmod +x $@ + +_build/stage3/lib/targets/%/lib/ghc-interp.js: + @mkdir -p $(@D) + @cp -f ghc-interp.js $@ + +# $1 = TIPLET +define build_cross + 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)) \ + $(foreach include,$(CROSS_EXTRA_INCLUDE_DIRS),--extra-include-dirs=$(include)) \ + $(STAGE3_LIBS) +endef + +# --- Stage 3 javascript build --- + +.PHONY: stage3-javascript-unknown-ghcjs +stage3-javascript-unknown-ghcjs: _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/settings javascript-unknown-ghcjs-libs _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/dyld.mjs _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/post-link.mjs _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/prelude.mjs _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/ghc-interp.js + +_build/stage3/lib/targets/javascript-unknown-ghcjs/lib/settings: _build/stage2/lib/targets/javascript-unknown-ghcjs _build/stage1/bin/ghc-toolchain-bin + @mkdir -p $(@D) + _build/stage1/bin/ghc-toolchain-bin $(GHC_TOOLCHAIN_ARGS) --triple javascript-unknown-ghcjs --output-settings -o $@ --cc $(EMCC) --cxx $(EMCXX) --ar $(EMAR) --ranlib $(EMRANLIB) + +_build/stage3/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache: _build/stage3/bin/javascript-unknown-ghcjs-ghc-pkg _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/settings javascript-unknown-ghcjs-libs + @mkdir -p $(@D) + @rm -rf $(@D)/* + cp -rfp _build/stage3/javascript-unknown-ghcjs/packagedb/host/*/* $(@D) + _build/stage3/bin/javascript-unknown-ghcjs-ghc-pkg recache + +.PHONY: javascript-unknown-ghcjs-libs +javascript-unknown-ghcjs-libs: private GHC=$(abspath _build/stage3/bin/javascript-unknown-ghcjs-ghc) +javascript-unknown-ghcjs-libs: private GHC2=$(abspath _build/stage2/bin/ghc) +javascript-unknown-ghcjs-libs: private STAGE=stage3 +javascript-unknown-ghcjs-libs: private CC=emcc +javascript-unknown-ghcjs-libs: private CROSS_EXTRA_LIB_DIRS=$(JS_EXTRA_LIB_DIRS) +javascript-unknown-ghcjs-libs: private CROSS_EXTRA_INCLUDE_DIRS=$(JS_EXTRA_INCLUDE_DIRS) +javascript-unknown-ghcjs-libs: _build/stage3/bin/javascript-unknown-ghcjs-ghc-pkg _build/stage3/bin/javascript-unknown-ghcjs-ghc _build/stage3/bin/javascript-unknown-ghcjs-hsc2hs _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/settings _build/stage3/lib/targets/javascript-unknown-ghcjs/bin/unlit _build/stage3/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d + $(call build_cross,javascript-unknown-ghcjs) + +# --- Stage 3 musl build --- + +.PHONY: stage3-x86_64-musl-linux +stage3-x86_64-musl-linux: x86_64-musl-linux-libs _build/stage3/lib/targets/x86_64-musl-linux/lib/package.conf.d/package.cache + +_build/stage3/lib/targets/x86_64-musl-linux/lib/settings: _build/stage2/lib/targets/x86_64-musl-linux _build/stage1/bin/ghc-toolchain-bin + @mkdir -p $(@D) + _build/stage1/bin/ghc-toolchain-bin $(GHC_TOOLCHAIN_ARGS) --triple x86_64-musl-linux --output-settings -o $@ --cc x86_64-unknown-linux-musl-cc --cxx x86_64-unknown-linux-musl-c++ --ar x86_64-unknown-linux-musl-ar --ranlib x86_64-unknown-linux-musl-ranlib --ld x86_64-unknown-linux-musl-ld + +_build/stage3/lib/targets/x86_64-musl-linux/lib/package.conf.d/package.cache: _build/stage3/bin/x86_64-musl-linux-ghc-pkg _build/stage3/lib/targets/x86_64-musl-linux/lib/settings x86_64-musl-linux-libs + @mkdir -p $(@D) + @rm -rf $(@D)/* + cp -rfp _build/stage3/x86_64-musl-linux/packagedb/host/*/* $(@D) + _build/stage3/bin/x86_64-musl-linux-ghc-pkg recache + +.PHONY: x86_64-musl-linux-libs +x86_64-musl-linux-libs: private GHC=$(abspath _build/stage3/bin/x86_64-musl-linux-ghc) +x86_64-musl-linux-libs: private GHC2=$(abspath _build/stage2/bin/ghc) +x86_64-musl-linux-libs: private STAGE=stage3 +x86_64-musl-linux-libs: private CC=x86_64-unknown-linux-musl-cc +x86_64-musl-linux-libs: private CROSS_EXTRA_LIB_DIRS=$(MUSL_EXTRA_LIB_DIRS) +x86_64-musl-linux-libs: private CROSS_EXTRA_INCLUDE_DIRS=$(MUSL_EXTRA_INCLUDE_DIRS) +x86_64-musl-linux-libs: _build/stage3/bin/x86_64-musl-linux-ghc-pkg _build/stage3/bin/x86_64-musl-linux-ghc _build/stage3/bin/x86_64-musl-linux-hsc2hs _build/stage3/lib/targets/x86_64-musl-linux/lib/settings _build/stage3/lib/targets/x86_64-musl-linux/bin/unlit _build/stage3/lib/targets/x86_64-musl-linux/lib/package.conf.d + $(call build_cross,x86_64-musl-linux) + +# --- Stage 3 wasm build --- + +.PHONY: stage3-wasm32-unknown-wasi +stage3-wasm32-unknown-wasi: wasm32-unknown-wasi-libs _build/stage3/lib/targets/wasm32-unknown-wasi/lib/package.conf.d/package.cache _build/stage3/lib/targets/wasm32-unknown-wasi/lib/dyld.mjs _build/stage3/lib/targets/wasm32-unknown-wasi/lib/post-link.mjs _build/stage3/lib/targets/wasm32-unknown-wasi/lib/prelude.mjs _build/stage3/lib/targets/wasm32-unknown-wasi/lib/ghc-interp.js + +_build/stage3/lib/targets/wasm32-unknown-wasi/lib/settings: _build/stage2/lib/targets/wasm32-unknown-wasi _build/stage1/bin/ghc-toolchain-bin + @mkdir -p $(@D) + PATH=/home/hasufell/.ghc-wasm/wasi-sdk/bin:$(PATH) _build/stage1/bin/ghc-toolchain-bin $(GHC_TOOLCHAIN_ARGS) --triple wasm32-unknown-wasi --output-settings -o $@ --cc wasm32-wasi-clang --cxx wasm32-wasi-clang++ --ar ar --ranlib ranlib --ld wasm-ld --merge-objs wasm-ld --merge-objs-opt="-r" --disable-ld-override --disable-tables-next-to-code $(foreach opt,$(WASM_CC_OPTS),--cc-opt=$(opt)) $(foreach opt,$(WASM_CXX_OPTS),--cxx-opt=$(opt)) + +_build/stage3/lib/targets/wasm32-unknown-wasi/lib/package.conf.d/package.cache: _build/stage3/bin/wasm32-unknown-wasi-ghc-pkg _build/stage3/lib/targets/wasm32-unknown-wasi/lib/settings wasm32-unknown-wasi-libs + @mkdir -p $(@D) + @rm -rf $(@D)/* + cp -rfp _build/stage3/wasm32-unknown-wasi/packagedb/host/*/* $(@D) + _build/stage3/bin/wasm32-unknown-wasi-ghc-pkg recache + +.PHONY: wasm32-unknown-wasi-libs +wasm32-unknown-wasi-libs: private GHC=$(abspath _build/stage3/bin/wasm32-unknown-wasi-ghc) +wasm32-unknown-wasi-libs: private GHC2=$(abspath _build/stage2/bin/ghc) +wasm32-unknown-wasi-libs: private STAGE=stage3 +wasm32-unknown-wasi-libs: private CC=wasm32-wasi-clang +wasm32-unknown-wasi-libs: private CROSS_EXTRA_LIB_DIRS=$(WASM_EXTRA_LIB_DIRS) +wasm32-unknown-wasi-libs: private CROSS_EXTRA_INCLUDE_DIRS=$(WASM_EXTRA_INCLUDE_DIRS) +wasm32-unknown-wasi-libs: _build/stage3/bin/wasm32-unknown-wasi-ghc-pkg _build/stage3/bin/wasm32-unknown-wasi-ghc _build/stage3/bin/wasm32-unknown-wasi-hsc2hs _build/stage3/lib/targets/wasm32-unknown-wasi/lib/settings _build/stage3/lib/targets/wasm32-unknown-wasi/bin/unlit _build/stage3/lib/targets/wasm32-unknown-wasi/lib/package.conf.d + $(call build_cross,wasm32-unknown-wasi) + +# --- Bindist --- + +RTS_SUBLIBS := \ + nonthreaded-nodebug \ + nonthreaded-debug \ + threaded-nodebug \ + threaded-debug + +# patchpackageconf +# +# Hacky function to patch up the paths in the package .conf files +# +# $1 = package name (ex: 'bytestring') +# TODO: package name is borked for sublibs +# $2 = path to .conf file +# $3 = (relative) path from $${pkgroot} to docs directory +# $4 = host triple +# $5 = package name and version (ex: bytestring-0.13) +# +# NOTE: We must make sure we keep sub-folder structures alive. There might be +# references to $5/build/FOO, we must keep /FOO at the end. One thing not +# retaining this that will break are pubilc sublibraries. +# +# FIXME: cabal should just be able to create .conf file properly relocated. And +# allow us to install them into a pre-defined package-db, this would +# eliminate this nonsense. +define patchpackageconf + case $5 in \ + rts-*-nonthreaded-nodebug) \ + sublib="/nonthreaded-nodebug" ;; \ + rts-*-nonthreaded-debug) \ + sublib="/nonthreaded-debug" ;; \ + rts-*-threaded-nodebug) \ + sublib="/threaded-nodebug" ;; \ + rts-*-threaded-debug) \ + sublib="/threaded-debug" ;; \ + *) \ + sublib="" ;; \ + esac ; \ + sed -i \ + -e "s|haddock-interfaces:.*|haddock-interfaces: \"\$${pkgroot}/$3/html/libraries/$5/$1.haddock\"|" \ + -e "s|haddock-html:.*|haddock-html: \"\$${pkgroot}/$3/html/libraries/$5\"|" \ + -e "s|import-dirs:.*|import-dirs: \"\$${pkgroot}/../lib/$4/$5$${sublib}\"|" \ + -e "s|library-dirs:.*|library-dirs: \"\$${pkgroot}/../lib/$4/$5$${sublib}\"|" \ + -e "s|library-dirs-static:.*|library-dirs-static: \"\$${pkgroot}/../lib/$4/$5$${sublib}\"|" \ + -e "s|dynamic-library-dirs:.*|dynamic-library-dirs: \"\$${pkgroot}/../lib/$4\"|" \ + -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|^ $(CURDIR).*||" \ + $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 ; \ + 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}/ && \ + $(call patchpackageconf,$${pkgname},$${pkg},../../..,$1,$${pkgnamever}) ; \ + done +endef + +# Target for creating the final binary distribution directory +#_build/bindist: stage2 driver/ghc-usage.txt driver/ghci-usage.txt +_build/bindist: stage2 driver/ghc-usage.txt driver/ghci-usage.txt + @echo "::group::Creating binary distribution in $@" + @mkdir -p $@/bin + @mkdir -p $@/lib + # Copy executables from stage2 bin + @cp -rfp _build/stage2/bin/* $@/bin/ + # 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} ; \ + $(call patchpackageconf,$${pkgname},$${pkg},../../..,$(HOST_PLATFORM),$${pkgnamever}) ; \ + done + # Copy driver usage files + @cp -rfp driver/ghc-usage.txt $@/lib/ + @cp -rfp driver/ghci-usage.txt $@/lib/ + @echo "FIXME: Changing 'Support SMP' from YES to NO in settings file" + @sed 's/("Support SMP","YES")/("Support SMP","NO")/' -i.bck $@/lib/settings + # Recache + $@/bin/ghc-pkg recache + # Copy headers + @$(call copy_all_stage2_h,$@/bin/ghc-pkg) + @echo "::endgroup::" + +_build/bindist/ghc.tar.gz: _build/bindist + @tar czf $@ \ + --directory=_build/bindist \ + $(foreach exe,$(BINDIST_EXECTUABLES),bin/$(exe)) \ + lib/ghc-usage.txt \ + lib/ghci-usage.txt \ + lib/package.conf.d \ + lib/settings \ + lib/template-hsc.h \ + lib/$(HOST_PLATFORM) + +_build/bindist/lib/targets/%: _build/bindist driver/ghc-usage.txt driver/ghci-usage.txt stage3-% + @echo "::group::Creating binary distribution in $@" + @mkdir -p _build/bindist/bin + @mkdir -p _build/bindist/lib/targets + # Symlinks + @cd _build/bindist/bin ; for binary in * ; do \ + test -L $$binary || ln -sf $$binary $(@F)-$$binary \ + ; done + # 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)) + # --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/ + # Recache + @_build/bindist/bin/$(@F)-ghc-pkg recache + # Copy headers + @$(call copy_all_stage3_h,_build/bindist/bin/$(@F)-ghc-pkg,$(@F)) + @echo "::endgroup::" + +_build/bindist/ghc-%.tar.gz: _build/bindist/lib/targets/% _build/bindist/ghc.tar.gz + @triple=`basename $<` ; \ + tar czf $@ \ + --directory=_build/bindist \ + $(foreach exe,$(BINDIST_EXECTUABLES),bin/$${triple}-$(exe)) \ + lib/targets/$${triple} + +_build/bindist/cabal.tar.gz: _build/stage0/bin/cabal + @mkdir -p _build/bindist/bin + @cp $^ _build/bindist/bin/cabal + @tar czf $@ \ + --directory=_build/bindist \ + bin/cabal + +_build/bindist/haskell-toolchain.tar.gz: _build/bindist/cabal.tar.gz _build/bindist/ghc.tar.gz _build/bindist/ghc-javascript-unknown-ghcjs.tar.gz + @tar czf $@ \ + --directory=_build/bindist \ + $(foreach exe,$(BINDIST_EXECTUABLES),bin/$(exe)) \ + lib/ghc-usage.txt \ + lib/ghci-usage.txt \ + lib/package.conf.d \ + lib/settings \ + lib/template-hsc.h \ + lib/$(HOST_PLATFORM) \ + $(foreach exe,$(BINDIST_EXECTUABLES),bin/javascript-unknown-ghcjs-$(exe)) \ + lib/targets/javascript-unknown-ghcjs \ + bin/cabal + +# --- Configuration --- + +$(GHC1) $(GHC2): | hackage +hackage: _build/packages/hackage.haskell.org/01-index.tar.gz +_build/packages/hackage.haskell.org/01-index.tar.gz: | $(CABAL) + @mkdir -p $(@D) + $(CABAL) $(CABAL_ARGS) update --index-state @1745256340 + +# booted depends on successful source preparation +configure rts/configure libraries/ghc-internal/configure: configure.ac rts/configure.ac libraries/ghc-internal/configure.ac libraries/ghc-boot-th-next/.synth-stamp + @echo "::group::Running ./boot script..." + @mkdir -p _build/logs + ./boot + @echo ">>> Running ./configure script..." + ./configure $(GHC_CONFIGURE_ARGS) + touch $@ + @echo "::endgroup::" + +# --- Clean Targets --- +clean: + @echo "::group::Cleaning build artifacts..." + rm -rf _build + rm -f libraries/ghc-boot-th-next/ghc-boot-th-next.cabal + rm -f libraries/ghc-boot-th-next/ghc-boot-th-next.cabal.in + rm -f libraries/ghc-boot-th-next/.synth-stamp + @echo "::endgroup::" + +clean-stage1: + @echo "::group::Cleaning stage1 build artifacts..." + rm -rf _build/stage1 + @echo "::endgroup::" + +clean-stage2: + @echo "::group::Cleaning stage2 build artifacts..." + rm -rf _build/stage2 + @echo "::endgroup::" + +clean-stage3: + @echo "::group::Cleaning stage3 build artifacts..." + rm -rf _build/stage3 + rm -rf _build/stage2/lib/targets + @echo "::endgroup::" + +distclean: clean + @echo "::group::Cleaning all generated files (distclean)..." + rm -rf autom4te.cache + rm -f config.status config.log config.h configure aclocal.m4 + rm -rf build-aux/config.guess build-aux/config.sub build-aux/install-sh build-aux/missing build-aux/compile depcomp + find . -name 'Makefile.in' -delete + rm -f $(CONFIGURED_FILES) + rm -rf libraries/ghc-boot-th-next/ghc-boot-th-next.cabal + rm -f libraries/ghc-boot-th-next/ghc-boot-th-next.cabal.in + rm -f libraries/ghc-boot-th-next/.synth-stamp + @echo "::endgroup::" + +# --- Synthesis Targets --- +# This is such a hack ๐Ÿ˜ฑ +libraries/ghc-boot-th-next/.synth-stamp: + @echo "::group::Synthesizing ghc-boot-th-next (copy & sed from ghc-boot-th)..." + @mkdir -p libraries/ghc-boot-th-next + @src=libraries/ghc-boot-th/ghc-boot-th.cabal.in; \ + dst=libraries/ghc-boot-th-next/ghc-boot-th-next.cabal.in; \ + if [ ! -f $$src ]; then echo "Source $$src not found" >&2; exit 1; fi; \ + cp -f $$src $$dst.tmp; \ + sed -e 's/^name:[[:space:]]*ghc-boot-th$$/name: ghc-boot-th-next/' \ + -e 's/ ghc-boot-th/ ghc-boot-th-next/g' \ + $$dst.tmp > $$dst; \ + rm -f $$dst.tmp; \ + touch $@ + @echo "::endgroup::" + +# Default: skip performance tests (can override with SKIP_PERF_TESTS=NO) +SKIP_PERF_TESTS ?= YES +export SKIP_PERF_TESTS + +# --- Test Suite Helper Tool Paths & Flags (Hadrian parity light) --- +# We approximate Hadrian's test invocation without depending on Hadrian. +# Bindist places test tools in _build/bindist/bin (created by the bindist target). +TEST_TOOLS_DIR := _build/bindist/bin +TEST_GHC := $(abspath $(TEST_TOOLS_DIR)/ghc) +TEST_GHC_PKG := $(abspath $(TEST_TOOLS_DIR)/ghc-pkg) +TEST_HP2PS := $(abspath $(TEST_TOOLS_DIR)/hp2ps) +TEST_HPC := $(abspath $(TEST_TOOLS_DIR)/hpc) +TEST_RUN_GHC := $(abspath $(TEST_TOOLS_DIR)/runghc) + +# Canonical GHC flags used by the testsuite (mirrors testsuite/mk/test.mk & Hadrian runTestGhcFlags) +CANONICAL_TEST_HC_OPTS = \ + -dcore-lint -dstg-lint -dcmm-lint -no-user-package-db -fno-dump-with-ways \ + -fprint-error-index-links=never -rtsopts -fno-warn-missed-specialisations \ + -fshow-warning-groups -fdiagnostics-color=never -fno-diagnostics-show-caret \ + -Werror=compat -dno-debug-output + +# Build timeout utility (needed for some tests) if not already built. +.PHONY: testsuite-timeout +testsuite-timeout: + $(MAKE) -C testsuite/timeout + + +# --- Test Target --- +test: _build/bindist testsuite-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)' \ + GHC_PKG='$(TEST_GHC_PKG)' \ + HP2PS_ABS='$(TEST_HP2PS)' \ + HPC='$(TEST_HPC)' \ + RUNGHC='$(TEST_RUN_GHC)' \ + TEST_CC='$(CC)' \ + TEST_CXX='$(CXX)' \ + TEST_HC_OPTS='$(CANONICAL_TEST_HC_OPTS)' \ + METRICS_FILE='$(CURDIR)/_build/test-perf.csv' \ + SUMMARY_FILE='$(CURDIR)/_build/test-summary.txt' \ + JUNIT_FILE='$(CURDIR)/_build/test-junit.xml' \ + SKIP_PERF_TESTS='$(SKIP_PERF_TESTS)' \ + THREADS='$(THREADS)' \ + $(MAKE) -C testsuite/tests test + @echo "::endgroup::" + +# Inform Make that these are not actual files if they get deleted by other means +.PHONY: clean clean-stage1 clean-stage2 clean-stage3 distclean test all + diff --git a/cabal.project.stage1 b/cabal.project.stage1 new file mode 100644 index 000000000000..db46d78bb9ac --- /dev/null +++ b/cabal.project.stage1 @@ -0,0 +1,70 @@ +packages: + -- NOTE: we need rts-headers, because the _newly_ built compiler depends + -- on these potentially _new_ headers, we must not rely on those from + -- the rts as shipped with the bootstrap compiler. For the stage2 + -- compiler we have the `rts` available, which would have the correct + -- headers around, now it has them through the rts -> rts-headers + -- dependency. + rts-headers + rts-fs + + -- other packages. + ghc + compiler + libraries/directory + libraries/file-io + libraries/filepath + libraries/ghc-platform + libraries/ghc-boot + libraries/ghc-boot-th-next + libraries/ghc-heap + libraries/ghci + libraries/os-string + libraries/process + libraries/semaphore-compat +-- libraries/time + libraries/unix + libraries/Win32 + libraries/Cabal/Cabal-syntax + libraries/Cabal/Cabal + utils/ghc-pkg + utils/hsc2hs + utils/unlit + utils/genprimopcode + utils/genapply + utils/deriveConstants + utils/ghc-toolchain + utils/ghc-toolchain/exe + +benchmarks: False +tests: False +allow-boot-library-installs: True + +package * + library-vanilla: True + shared: False + executable-profiling: False + executable-dynamic: False + executable-static: False + +package ghc + flags: +bootstrap + +package ghci + flags: +bootstrap + +package ghc-boot + flags: +bootstrap + +package ghc-boot-th-next + flags: +bootstrap + +-- TODO: What is this? Why do we need _in-ghc-tree_ here? +package hsc2hs + flags: +in-ghc-tree + +constraints: + template-haskell <= 2.22 + +program-options + ghc-options: -fhide-source-paths -j diff --git a/cabal.project.stage2 b/cabal.project.stage2 new file mode 100644 index 000000000000..54a7276572d2 --- /dev/null +++ b/cabal.project.stage2 @@ -0,0 +1,211 @@ +package-dbs: clear, global + +-- Import configure/generated feature toggles (dynamic, etc.) if present. +-- A default file is kept in-tree; configure will overwrite with substituted values. +import: cabal.project.stage2.settings + +packages: + rts-headers + rts-fs + rts + + libraries/ghc-prim + libraries/ghc-internal + libraries/ghc-experimental + libraries/base + compiler + ghc + libraries/ghc-platform + libraries/ghc-compact + libraries/ghc-bignum + libraries/integer-gmp + libraries/ghc-boot + libraries/ghc-boot-th + libraries/ghc-heap + libraries/ghci + libraries/stm + libraries/template-haskell + libraries/hpc + libraries/system-cxx-std-lib + libraries/array + libraries/binary + libraries/bytestring + libraries/containers/containers + libraries/deepseq + libraries/directory + libraries/exceptions + libraries/file-io + libraries/filepath + libraries/mtl + libraries/os-string + libraries/parsec + libraries/pretty + libraries/process + libraries/semaphore-compat + libraries/text + libraries/time + libraries/transformers + libraries/unix + libraries/xhtml + libraries/Win32 + + libraries/Cabal/Cabal-syntax + libraries/Cabal/Cabal + https://hackage.haskell.org/package/alex-3.5.2.0/alex-3.5.2.0.tar.gz + https://hackage.haskell.org/package/happy-2.1.5/happy-2.1.5.tar.gz + https://hackage.haskell.org/package/happy-lib-2.1.5/happy-lib-2.1.5.tar.gz + + utils/genprimopcode + utils/deriveConstants + utils/ghc-pkg + utils/hsc2hs + utils/unlit + utils/ghc-toolchain + + libraries/haskeline + libraries/terminfo + utils/hp2ps + utils/hpc + utils/ghc-iserv + utils/genapply + utils/runghc + +-- project-rts +-- project-ghc +benchmarks: False +tests: False +allow-boot-library-installs: True +active-repositories: :none + +constraints: + -- we do not want to use the rts-headers from stage1 + rts-headers source, rts-fs source + -- All build dependencies should be installed, i.e. from stage1. + -- I cannot write build:* but ghc-internal is enough to do the job. + , build:any.ghc-internal installed + +package * + library-vanilla: True + library-for-ghci: True + -- shared/executable-dynamic now controlled by Makefile (DYNAMIC variable) + -- so we do not pin them here; default (static) remains when DYNAMIC=0. + executable-profiling: False + executable-static: False + +-- Maybe we should fix this with some import +if os(linux) + package rts + ghc-options: "-optc-DProjectVersion=\"914\"" + ghc-options: "-optc-DRtsWay=\"v\"" + ghc-options: "-optc-DHostPlatform=\"x86_64-unknown-linux\"" + ghc-options: "-optc-DHostArch=\"x86_64\"" + ghc-options: "-optc-DHostOS=\"linux\"" + ghc-options: "-optc-DHostVendor=\"unknown\"" + ghc-options: "-optc-DBuildPlatform=\"FIXME\"" + ghc-options: "-optc-DBuildArch=\"FIXME\"" + ghc-options: "-optc-DBuildOS=\"FIXME\"" + ghc-options: "-optc-DBuildVendor=\"FIXME\"" + ghc-options: "-optc-DGhcUnregisterised=\"FIXME\"" + ghc-options: "-optc-DTablesNextToCode=\"FIXME\"" + ghc-options: "-optc-DFS_NAMESPACE=rts" + flags: +tables-next-to-code + +if os(darwin) + package rts + ghc-options: "-optc-DProjectVersion=\"914\"" + ghc-options: "-optc-DRtsWay=\"v\"" + ghc-options: "-optc-DHostPlatform=\"aarch64-apple-darwin\"" + ghc-options: "-optc-DHostArch=\"aarch64\"" + ghc-options: "-optc-DHostOS=\"darwin\"" + ghc-options: "-optc-DHostVendor=\"unknown\"" + ghc-options: "-optc-DBuildPlatform=\"FIXME\"" + ghc-options: "-optc-DBuildArch=\"FIXME\"" + ghc-options: "-optc-DBuildOS=\"FIXME\"" + ghc-options: "-optc-DBuildVendor=\"FIXME\"" + ghc-options: "-optc-DGhcUnregisterised=\"FIXME\"" + ghc-options: "-optc-DTablesNextToCode=\"FIXME\"" + ghc-options: "-optc-DFS_NAMESPACE=rts" + flags: +tables-next-to-code +leading-underscore + ld-options: -undefined warning + + +program-options + ghc-options: -fhide-source-paths -j + +-- project-boot-libs +benchmarks: False +tests: False +allow-boot-library-installs: True +active-repositories: :none + +-- (removed duplicate global package * stanza; first one applies already) + +package rts-headers + ghc-options: -no-rts + +package rts-fs + ghc-options: -no-rts + +package rts + ghc-options: -no-rts + +-- We end up injecting the following depednency: +-- +-- ghc-internal +-- '- rts: +-- '- rts +-- +-- Because the ghc-internal package depends on the +-- rts implementation (in the sublib), however GHC +-- is responsible for dependency injecting the right +-- implementation. +-- +-- During the bootsrap phase of building GHC, there +-- is a race condition where ghc-bin depends on +-- the rts: and also on ghc-internal, hence +-- we can occationally end up in the state where we +-- try to build the ghc-internal library, while the +-- rts: isn't yet built. +-- +-- Modelling this in cabal properly is hard. Relying +-- on chance to build it in the right sequence is +-- also bad. Disabling this check outright in ghc +-- is bad because under all circumstances (except +-- bootstrapping) this is an essential dependency that +-- must exist. +-- +-- MAYBE: a better option is to push this check to +-- the link time only. However we then don't +-- have the ghc-internal available earlier +-- throughout the session. See +-- GHC.Unit.State:mkUnitState +-- +package ghc-internal + ghc-options: -no-rts + +package ghc + flags: +build-tool-depends +internal-interpreter + +package ghci + flags: +internal-interpreter + +package ghc-internal + flags: +bignum-native + +package text + flags: -simdutf + +program-options + ghc-options: -fhide-source-paths -j + +package ghc-bin + flags: +internal-interpreter -threaded + +package hsc2hs + flags: +in-ghc-tree + +package haskeline + flags: -terminfo + +program-options + ghc-options: -fhide-source-paths -j diff --git a/cabal.project.stage2.settings b/cabal.project.stage2.settings new file mode 100644 index 000000000000..9fe41967a9dc --- /dev/null +++ b/cabal.project.stage2.settings @@ -0,0 +1,10 @@ +-- cabal.project.stage2.settings - generated by configure from .in template +-- Do not edit this file directly; edit cabal.project.stage2.settings.in instead. +-- Empty (or comment-only) blocks are fine if features are disabled. + +package * + shared: False + executable-dynamic: False + +constraints: + -- (none) diff --git a/cabal.project.stage2.settings.in b/cabal.project.stage2.settings.in new file mode 100644 index 000000000000..521585a67fdd --- /dev/null +++ b/cabal.project.stage2.settings.in @@ -0,0 +1,9 @@ +-- cabal.project.stage2.settings - generated by configure from .in template +-- Do not edit this file directly; edit cabal.project.stage2.settings.in instead. +-- Empty (or comment-only) blocks are fine if features are disabled. + +package * +@ALL_PACKAGES@ + +constraints: +@CONSTRAINTS@ diff --git a/cabal.project.stage3 b/cabal.project.stage3 new file mode 100644 index 000000000000..2bba363befa9 --- /dev/null +++ b/cabal.project.stage3 @@ -0,0 +1,223 @@ +package-dbs: clear, global + + +packages: + rts-headers + rts-fs + rts + + libraries/ghc-prim + libraries/ghc-internal + libraries/ghc-experimental + libraries/base + compiler + libraries/ghc-platform + libraries/ghc-compact + libraries/ghc-bignum + libraries/integer-gmp + libraries/ghc-boot + libraries/ghc-boot-th + libraries/ghc-heap + libraries/ghci + libraries/stm + libraries/template-haskell + libraries/hpc + libraries/system-cxx-std-lib + libraries/array + libraries/binary + libraries/bytestring + libraries/containers/containers + libraries/deepseq + libraries/directory + libraries/exceptions + libraries/file-io + libraries/filepath + libraries/mtl + libraries/os-string + libraries/parsec + libraries/pretty + libraries/process + libraries/semaphore-compat + libraries/text + libraries/time + libraries/transformers + libraries/unix + libraries/xhtml + libraries/Win32 + + libraries/Cabal/Cabal-syntax + libraries/Cabal/Cabal + https://hackage.haskell.org/package/alex-3.5.2.0/alex-3.5.2.0.tar.gz + https://hackage.haskell.org/package/happy-2.1.5/happy-2.1.5.tar.gz + https://hackage.haskell.org/package/happy-lib-2.1.5/happy-lib-2.1.5.tar.gz + + utils/genprimopcode + utils/deriveConstants + +-- project-rts +benchmarks: False +tests: False +allow-boot-library-installs: True +active-repositories: :none + +constraints: + build:any.ghc-internal installed, + -- for some reason cabal things these are already installed for the target, + -- although they only exist in the build compiler package db + Cabal source, + Cabal-syntax source, + array source, + base source, + binary source, + bytestring source, + containers source, + deepseq source, + directory source, + exceptions source, + file-io source, + filepath source, + ghc-bignum source, + hpc source, + integer-gmp source, + mtl source, + os-string source, + parsec source, + pretty source, + process source, + rts source, + rts-headers source, + rts-fs source, + stm source, + system-cxx-std-lib source, + template-haskell source, + text source, + time source, + transformers source, + unix source, + xhtml source, + Win32 source + + +package * + library-vanilla: True + shared: False + executable-profiling: False + executable-dynamic: False + executable-static: False + -- library-for-ghci will cause a `ld -r` call to create pre-linked objects. + -- This helps the internal linker when trying to link (.a) archives with massive + -- displacements. In that case the displacement can be in excess of what + -- is possible to relocate, and the linker fails. Pre-linking the objects helps with + -- this (and linking performance, as we need to process fewer relocations). + -- + -- For some cross targets like JavaScript, this will fail as the $LD -r invocation + -- might not be properly supported. + -- + -- fs.o: file not recognized: file format not recognized + -- + -- Thus for cross compilers, we outright disable this here. The primary offending + -- library is libHSghc, which can easily be 150MB+ + -- + -- TODO: this is rather fragile, and should be fixed properly by making pre-linked + -- objects of have GHC pre-link excessively large archives on-demand. + library-for-ghci: False + +if os(wasi) + package * + shared: True + package rts + ghc-options: "-optc-DProjectVersion=\"913\"" + ghc-options: "-optc-DRtsWay=\"v\"" + ghc-options: "-optc-DHostPlatform=\"wasm32-wasi\"" + ghc-options: "-optc-DHostArch=\"wasm32\"" + ghc-options: "-optc-DHostOS=\"unknown\"" + ghc-options: "-optc-DHostVendor=\"unknown\"" + ghc-options: "-optc-DBuildPlatform=\"FIXME\"" + ghc-options: "-optc-DBuildArch=\"FIXME\"" + ghc-options: "-optc-DBuildOS=\"FIXME\"" + ghc-options: "-optc-DBuildVendor=\"FIXME\"" + ghc-options: "-optc-DGhcUnregisterised=\"FIXME\"" + ghc-options: "-optc-DTablesNextToCode=\"FIXME\"" + ghc-options: "-optc-DFS_NAMESPACE=rts" + ghc-options: "-optl-Wl,--export-dynamic" + ghc-options: "-optc-fvisibility=default" + ghc-options: "-optc-fvisibility-inlines-hidden" + flags: -tables-next-to-code + +-- Maybe we should fix this with some import +if os(linux) + package rts + ghc-options: "-optc-DProjectVersion=\"913\"" + ghc-options: "-optc-DRtsWay=\"v\"" + ghc-options: "-optc-DHostPlatform=\"x86_64-unknown-linux\"" + ghc-options: "-optc-DHostArch=\"x86_64\"" + ghc-options: "-optc-DHostOS=\"linux\"" + ghc-options: "-optc-DHostVendor=\"unknown\"" + ghc-options: "-optc-DBuildPlatform=\"FIXME\"" + ghc-options: "-optc-DBuildArch=\"FIXME\"" + ghc-options: "-optc-DBuildOS=\"FIXME\"" + ghc-options: "-optc-DBuildVendor=\"FIXME\"" + ghc-options: "-optc-DGhcUnregisterised=\"FIXME\"" + ghc-options: "-optc-DTablesNextToCode=\"FIXME\"" + ghc-options: "-optc-DFS_NAMESPACE=rts" + flags: +tables-next-to-code + +if os(darwin) + package rts + ghc-options: "-optc-DProjectVersion=\"913\"" + ghc-options: "-optc-DRtsWay=\"v\"" + ghc-options: "-optc-DHostPlatform=\"aarch64-apple-darwin\"" + ghc-options: "-optc-DHostArch=\"aarch64\"" + ghc-options: "-optc-DHostOS=\"darwin\"" + ghc-options: "-optc-DHostVendor=\"unknown\"" + ghc-options: "-optc-DBuildPlatform=\"FIXME\"" + ghc-options: "-optc-DBuildArch=\"FIXME\"" + ghc-options: "-optc-DBuildOS=\"FIXME\"" + ghc-options: "-optc-DBuildVendor=\"FIXME\"" + ghc-options: "-optc-DGhcUnregisterised=\"FIXME\"" + ghc-options: "-optc-DTablesNextToCode=\"FIXME\"" + ghc-options: "-optc-DFS_NAMESPACE=rts" + flags: +tables-next-to-code +leading-underscore + +program-options + ghc-options: -fhide-source-paths -j + +-- project-boot-libs +benchmarks: False +tests: False +allow-boot-library-installs: True +active-repositories: :none + +package rts-headers + ghc-options: -no-rts + +package rts-fs + ghc-options: -no-rts + +package rts + ghc-options: -no-rts + +package ghc + flags: +build-tool-depends +internal-interpreter + +package ghci + flags: +internal-interpreter + +package ghc-internal + flags: +bignum-native + +package text + flags: -simdutf + +program-options + ghc-options: -fhide-source-paths -j + +-- project-ghc +benchmarks: False +tests: False + +package hsc2hs + flags: +in-ghc-tree + +program-options + ghc-options: -fhide-source-paths -j diff --git a/configure.ac b/configure.ac index ca394eb4baab..e924cf8c147a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,1125 +1,97 @@ -dnl == autoconf source for the Glasgow FP tools == -dnl (run "grep '^dnl \*' configure.ac | sed -e 's/dnl / /g; s/\*\*/ +/g;'" -dnl (or some such) to see the outline of this file) -dnl -# -# (c) The University of Glasgow 1994-2012 -# -# Configure script template for GHC -# -# Process with 'autoreconf' to get a working configure script. -# -# For the generated configure script, do "./configure --help" to -# see what flags are available. (Better yet, read the documentation!) -# - -AC_INIT([The Glorious Glasgow Haskell Compilation System], [9.15], [glasgow-haskell-bugs@haskell.org], [ghc-AC_PACKAGE_VERSION]) - # Version on master must be X.Y (not X.Y.Z) for ProjectVersionMunged variable - # to be useful (cf #19058). However, the version must have three components - # (X.Y.Z) on stable branches (e.g. ghc-9.2) to ensure that pre-releases are - # versioned correctly. - -AC_CONFIG_MACRO_DIRS([m4]) - -# Set this to YES for a released version, otherwise NO -: ${RELEASE=NO} - -# The primary version (e.g. 7.5, 7.4.1) is set in the AC_INIT line -# above. If this is not a released version, then we will append the -# date to the version number (e.g. 7.4.20111220). The date is -# constructed by finding the date of the most recent patch in the -# git repository. If this is a source distribution (not a git -# checkout), then we ship a file 'VERSION' containing the full version -# when the source distribution was created. - -if test ! -f rts/ghcautoconf.h.autoconf.in; then - echo "rts/ghcautoconf.h.autoconf.in doesn't exist: perhaps you haven't run 'python3 boot'?" - exit 1 -fi - -dnl this makes sure `./configure --target=` -dnl works as expected, since we're slightly modifying how Autoconf -dnl interprets build/host/target and how this interacts with $CC tests -test -n "$target_alias" && ac_tool_prefix=$target_alias- - -dnl ---------------------------------------------------------- -dnl ** Store USER specified environment variables to pass them on to -dnl ** ghc-toolchain (in m4/ghc-toolchain.m4) -USER_CFLAGS="$CFLAGS" -USER_LDFLAGS="$LDFLAGS" -USER_LIBS="$LIBS" -USER_CXXFLAGS="$CXXFLAGS" -dnl The lower-level/not user-facing environment variables that may still be set -dnl by developers such as in ghc-wasm-meta -USER_CONF_CC_OPTS_STAGE2="$CONF_CC_OPTS_STAGE2" -USER_CONF_CXX_OPTS_STAGE2="$CONF_CXX_OPTS_STAGE2" -USER_CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2" - -USER_LD="$LD" - -dnl ---------------------------------------------------------- -dnl ** Find unixy sort and find commands, -dnl ** which are needed by FP_SETUP_PROJECT_VERSION - -dnl ** Find find command (for Win32's benefit) -FP_PROG_FIND -FP_PROG_SORT - -dnl ---------------------------------------------------------- -FP_SETUP_PROJECT_VERSION - -# Hmmm, we fix the RPM release number to 1 here... Is this convenient? -AC_SUBST([release], [1]) - -dnl * We require autoconf version 2.69 due to -dnl https://bugs.ruby-lang.org/issues/8179. Also see #14910. -dnl * We need 2.50 due to the use of AC_SYS_LARGEFILE and AC_MSG_NOTICE. -dnl * We need 2.52 due to the use of AS_TR_CPP and AS_TR_SH. -dnl * Using autoconf 2.59 started to give nonsense like this -dnl #define SIZEOF_CHAR 0 -dnl recently. +# configure.ac AC_PREREQ([2.69]) - -# No, semi-sadly, we don't do `--srcdir'... -if test x"$srcdir" != 'x.' ; then - echo "This configuration does not support the \`--srcdir' option.." - exit 1 -fi - -dnl -------------------------------------------------------------- -dnl * Project specific configuration options -dnl -------------------------------------------------------------- -dnl What follows is a bunch of options that can either be configured -dnl through command line options to the configure script or by -dnl supplying defns in the build tree's mk/build.mk. Having the option to -dnl use either is considered a Feature. - -dnl ** What command to use to compile compiler sources ? -dnl -------------------------------------------------------------- - -AC_ARG_VAR(GHC,[Use as the full path to GHC. [default=autodetect]]) -AC_PATH_PROG([GHC], [ghc]) -AC_ARG_WITH([ghc], - AS_HELP_STRING([--with-ghc=PATH], [Use PATH as the full path to ghc (obsolete, use GHC=PATH instead) [default=autodetect]]), - AC_MSG_ERROR([--with-ghc=$withval is obsolete (use './configure GHC=$withval' or 'GHC=$withval ./configure' instead)])) -AC_SUBST(WithGhc,$GHC) - -AC_ARG_ENABLE(bootstrap-with-devel-snapshot, -[AS_HELP_STRING([--enable-bootstrap-with-devel-snapshot], - [Allow bootstrapping using a development snapshot of GHC. This is not guaranteed to work.])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableBootstrapWithDevelSnaphost])], - [EnableBootstrapWithDevelSnaphost=NO] -) - -AC_ARG_ENABLE(ignore-build-platform-mismatch, -[AS_HELP_STRING([--ignore-build-platform-mismatch], - [Ignore when the target platform reported by the bootstrap compiler doesn''t match the configured build platform. This flag is used to correct mistakes when the target platform is incorrectly reported by the bootstrap (#25200). ])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [IgnoreBuildPlatformMismatch])], - [IgnoreBuildPlatformMismatch=NO] -) - - -AC_ARG_ENABLE(tarballs-autodownload, -[AS_HELP_STRING([--enable-tarballs-autodownload], - [Automatically download Windows distribution binaries if needed.])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [TarballsAutodownload])], - [TarballsAutodownload=NO] -) - -AC_ARG_ENABLE(distro-toolchain, -[AS_HELP_STRING([--enable-distro-toolchain], - [Do not use bundled Windows toolchain binaries.])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableDistroToolchain])], - [EnableDistroToolchain=NO] -) - -if test "$EnableDistroToolchain" = "YES"; then - TarballsAutodownload=NO -fi - -AC_ARG_ENABLE(ghc-toolchain, -[AS_HELP_STRING([--enable-ghc-toolchain], - [Whether to use the newer ghc-toolchain tool to configure ghc targets])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableGhcToolchain])], - [EnableGhcToolchain=NO] -) -AC_SUBST([EnableGhcToolchain]) - -AC_ARG_ENABLE(strict-ghc-toolchain-check, -[AS_HELP_STRING([--enable-strict-ghc-toolchain-check], - [Whether to raise an error if the output of ghc-toolchain differs from configure])], - [FP_CAPITALIZE_YES_NO(["$enableval"], [EnableStrictGhcToolchainCheck])], - [EnableStrictGhcToolchainCheck=NO] -) -AC_SUBST([EnableStrictGhcToolchainCheck]) - -dnl CC_STAGE0, LD_STAGE0, AR_STAGE0 are like the "previous" variable -dnl CC, LD, AR (inherited by CC_STAGE[123], etc.) -dnl but instead used by stage0 for bootstrapping stage1 -AC_ARG_VAR(CC_STAGE0, [C compiler command (bootstrap)]) -AC_ARG_VAR(LD_STAGE0, [Linker command (bootstrap)]) -AC_ARG_VAR(AR_STAGE0, [Archive command (bootstrap)]) - -dnl RTS ways supplied by the bootstrapping compiler. -AC_ARG_VAR(RTS_WAYS_STAGE0, [RTS ways]) - -if test "$WithGhc" != ""; then - FPTOOLS_GHC_VERSION([GhcVersion], [GhcMajVersion], [GhcMinVersion], [GhcPatchLevel])dnl - - if test "$GhcMajVersion" = "unknown" || test "$GhcMinVersion" = "unknown"; then - AC_MSG_ERROR([Cannot determine the version of $WithGhc. Is it really GHC?]) - fi - - AC_SUBST(GhcVersion)dnl - AC_SUBST(GhcMajVersion)dnl - AC_SUBST(GhcMinVersion)dnl - AC_SUBST(GhcPatchLevel)dnl - GhcMinVersion2=`echo "$GhcMinVersion" | sed 's/^\\(.\\)$/0\\1/'` - GhcCanonVersion="$GhcMajVersion$GhcMinVersion2" - - dnl infer {CC,LD,AR}_STAGE0 from `ghc --info` unless explicitly set by user - if test -z "$CC_STAGE0"; then - BOOTSTRAPPING_GHC_INFO_FIELD([CC_STAGE0],[C compiler command]) - fi - - if test -z "$LD_STAGE0"; then - BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[ld command]) - # ld command is removed in 9.10.1 as a boot compiler and supplies "Merge objects - # command" instead - if test -z "$LD_STAGE0"; then - BOOTSTRAPPING_GHC_INFO_FIELD([LD_STAGE0],[Merge objects command]) - fi - - fi - if test -z "$AR_STAGE0"; then - BOOTSTRAPPING_GHC_INFO_FIELD([AR_STAGE0],[ar command]) - fi - BOOTSTRAPPING_GHC_INFO_FIELD([AR_OPTS_STAGE0],[ar flags]) - BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsAtFile_STAGE0],[ar supports at file]) - BOOTSTRAPPING_GHC_INFO_FIELD([ArSupportsDashL_STAGE0],[ar supports -L]) - BOOTSTRAPPING_GHC_INFO_FIELD([SUPPORT_SMP_STAGE0],[Support SMP]) - BOOTSTRAPPING_GHC_INFO_FIELD([RTS_WAYS_STAGE0],[RTS ways]) - - dnl Check whether or not the bootstrapping GHC has a threaded RTS. This - dnl determines whether or not we can have a threaded stage 1. - dnl See Note [Linking ghc-bin against threaded stage0 RTS] in - dnl hadrian/src/Settings/Packages.hs for details. - dnl SMP support which implies a registerised stage0 is also required (see issue 18266) - if echo ${RTS_WAYS_STAGE0} | tr ' ' '\n' | grep '^thr$' 2>&1 >/dev/null && \ - test "$SUPPORT_SMP_STAGE0" = "YES" - then - AC_SUBST(GhcThreadedRts, YES) - else - AC_SUBST(GhcThreadedRts, NO) - fi -fi - -dnl ** Must have GHC to build GHC -if test "$WithGhc" = "" -then - AC_MSG_ERROR([GHC is required.]) -fi -MinBootGhcVersion="9.10" -FP_COMPARE_VERSIONS([$GhcVersion],[-lt],[$MinBootGhcVersion], - [AC_MSG_ERROR([GHC version $MinBootGhcVersion or later is required to compile GHC.])]) - -if test `expr $GhcMinVersion % 2` = "1" -then - if test "$EnableBootstrapWithDevelSnaphost" = "NO" - then - AC_MSG_ERROR([ - $WithGhc is a development snapshot of GHC, version $GhcVersion. - Bootstrapping using this version of GHC is not supported, and may not - work. Use --enable-bootstrap-with-devel-snapshot to try it anyway, - or 'GHC=' to specify a different GHC to use.]) - fi -fi - -# GHC is passed to Cabal, so we need a native path -if test "${WithGhc}" != "" -then - ghc_host_os=`"${WithGhc}" +RTS --info | grep 'Host OS' | sed -e 's/.*, "//' -e 's/")//'` - - if test "$ghc_host_os" = "mingw32" - then - if test "${OSTYPE}" = "msys" - then - WithGhc=`echo "${WithGhc}" | sed "s#^/\([a-zA-Z]\)/#\1:/#"` - else - # Canonicalise to :/path/to/ghc - WithGhc=`cygpath -m "${WithGhc}"` - fi - echo "GHC path canonicalised to: ${WithGhc}" - fi -fi -AC_SUBST([WithGhc]) - -dnl ** Without optimization some INLINE trickery fails for GHCi -SRC_CC_OPTS="-O" - -dnl-------------------------------------------------------------------- -dnl * Choose host(/target/build) platform -dnl-------------------------------------------------------------------- -dnl If we aren't explicitly told what values to use with configure flags, -dnl we ask the bootstrapping compiler what platform it is for - -if test "${WithGhc}" != "" -then - bootstrap_host=`"${WithGhc}" --info | grep '^ ,("Host platform"' | sed -e 's/.*,"//' -e 's/")//' | tr -d '\r'` - bootstrap_target=`"${WithGhc}" --info | grep '^ ,("Target platform"' | sed -e 's/.*,"//' -e 's/")//' | tr -d '\r'` - if test "$bootstrap_host" != "$bootstrap_target" - then - echo "Bootstrapping GHC is a cross compiler. This probably isn't going to work" - fi -fi - -# We have to run these unconditionally, but we may discard their -# results in the following code -AC_CANONICAL_BUILD -AC_CANONICAL_HOST -AC_CANONICAL_TARGET - -FPTOOLS_SET_PLATFORMS_VARS - -FP_PROG_SH - -# Verify that the installed (bootstrap) GHC is capable of generating -# code for the requested build platform. -if test "$BuildPlatform" != "$bootstrap_target" -then - if test "$IgnoreBuildPlatformMismatch" = "NO" - then - echo "This GHC (${WithGhc}) does not generate code for the build platform" - echo " GHC target platform : $bootstrap_target" - echo " Desired build platform : $BuildPlatform" - exit 1 - fi -fi - -dnl ** Do an unregisterised build? -dnl -------------------------------------------------------------- - -GHC_UNREGISTERISED -AC_SUBST(Unregisterised) - -dnl ** Do a build with tables next to code? -dnl -------------------------------------------------------------- - -GHC_TABLES_NEXT_TO_CODE -AC_SUBST(TablesNextToCode) - -# Requires FPTOOLS_SET_PLATFORMS_VARS to be run first. -FP_FIND_ROOT - -# Extract and configure the Windows toolchain -if test "$HostOS" = "mingw32" -a "$EnableDistroToolchain" = "NO"; then - FP_INSTALL_WINDOWS_TOOLCHAIN - FP_SETUP_WINDOWS_TOOLCHAIN([$hardtop/inplace/mingw], [$hardtop/inplace/mingw]) -else - AC_CHECK_TOOL([CC],[gcc], [clang]) - AC_CHECK_TOOL([CXX],[g++], [clang++]) - AC_CHECK_TOOL([NM],[nm]) - # N.B. we don't probe for LD here but instead - # do so in FIND_LD to avoid #21778. - AC_CHECK_TOOL([AR],[ar]) - AC_CHECK_TOOL([RANLIB],[ranlib]) - AC_CHECK_TOOL([OBJDUMP],[objdump]) - AC_CHECK_TOOL([WindresCmd],[windres]) - AC_CHECK_TOOL([Genlib],[genlib]) - - if test "$HostOS" = "mingw32"; then - AC_CHECK_TARGET_TOOL([WindresCmd],[windres]) - AC_CHECK_TARGET_TOOL([OBJDUMP],[objdump]) - - WindresCmd="$(cygpath -m $WindresCmd)" - - if test "$Genlib" != ""; then - GenlibCmd="$(cygpath -m $Genlib)" - fi - fi -fi - -FP_ICONV -FP_GMP -FP_CURSES - -dnl On Windows we force in-tree GMP build until we support dynamic linking -if test "$HostOS" = "mingw32" -then - GMP_FORCE_INTREE="YES" -fi - -dnl ** Building a cross compiler? -dnl -------------------------------------------------------------- -dnl We allow the user to override this since the target/host check -dnl can get this wrong in some particular cases. See #26236. -if test -z "$CrossCompiling" ; then - CrossCompiling=NO - # If 'host' and 'target' differ, then this means we are building a cross-compiler. - if test "$target" != "$host" ; then - CrossCompiling=YES - fi -fi -if test "$CrossCompiling" = "YES"; then - # This tells configure that it can accept just 'target', - # otherwise you get - # configure: error: cannot run C compiled programs. - # If you meant to cross compile, use `--host'. - cross_compiling=yes -fi - -if test "$BuildPlatform" != "$HostPlatform" ; then - AC_MSG_ERROR([ -You've selected: - - BUILD: $BuildPlatform (the architecture we're building on) - HOST: $HostPlatform (the architecture the compiler we're building will execute on) - TARGET: $TargetPlatform (the architecture the compiler we're building will produce code for) - -BUILD must equal HOST; that is, we do not support building GHC itself -with a cross-compiler. To cross-compile GHC itself, set TARGET: stage -1 will be a cross-compiler, and stage 2 will be the cross-compiled -GHC. -]) -fi -# Despite its similarity in name to TargetPlatform, TargetPlatformFull is used -# in calls to subproject configure scripts and thus must be set to the autoconf -# triple, not the normalized GHC triple that TargetPlatform is set to. -# -# We use the non-canonicalized triple, target_alias, here since the subproject -# configure scripts will use this triple to construct the names of the toolchain -# executables. If we instead passed down the triple produced by -# AC_CANONICAL_TARGET then it may look for the target toolchain under the wrong -# name (this is a known problem in the case of the Android NDK, which has -# slightly odd triples). -# -# It may be better to just do away with the GHC triples altogether. This would -# all be taken care of for us if we configured the subprojects using -# AC_CONFIG_DIR, but unfortunately Cabal needs to be the one to do the -# configuration. -# -# We also use non-canonicalized triple when install stage1 crosscompiler -if test -z "${target_alias}" -then - # --target wasn't given; use result from AC_CANONICAL_TARGET - TargetPlatformFull="${target}" -else - TargetPlatformFull="${target_alias}" -fi -AC_SUBST(CrossCompiling) -AC_SUBST(TargetPlatformFull) - -dnl ** Which gcc to use? -dnl -------------------------------------------------------------- - -AC_ARG_WITH([gcc], - AS_HELP_STRING([--with-gcc=ARG], [Use ARG as the path to gcc (obsolete, use CC=ARG instead) [default=autodetect]]), - AC_MSG_ERROR([--with-gcc=$withval is obsolete (use './configure CC=$withval' or 'CC=$withval ./configure' instead)])) - -AC_ARG_WITH([clang], - AS_HELP_STRING([--with-clang=ARG], [Use ARG as the path to clang (obsolete, use CC=ARG instead) [default=autodetect]]), - AC_MSG_ERROR([--with-clang=$withval is obsolete (use './configure CC=$withval' or 'CC=$withval ./configure' instead)])) - -dnl detect compiler (prefer gcc over clang) and set $CC (unless CC already set), -dnl later CC is copied to CC_STAGE{1,2,3} -AC_PROG_CC([cc gcc clang]) -AC_PROG_CXX([g++ clang++ c++]) -# Work around #24324 -MOVE_TO_FLAGS([CC],[CFLAGS]) -MOVE_TO_FLAGS([CXX],[CXXFLAGS]) - -MAYBE_OVERRIDE_STAGE0([ar],[AR_STAGE0]) - -dnl make extensions visible to allow feature-tests to detect them lateron -AC_USE_SYSTEM_EXTENSIONS - -# --with-hs-cpp/--with-hs-cpp-flags -FP_HSCPP_CMD_WITH_ARGS(HaskellCPPCmd, HaskellCPPArgs) -AC_SUBST([HaskellCPPCmd]) -AC_SUBST([HaskellCPPArgs]) - -# --with-js-cpp/--with-js-cpp-flags -FP_JSCPP_CMD_WITH_ARGS(JavaScriptCPPCmd, JavaScriptCPPArgs) -AC_SUBST([JavaScriptCPPCmd]) -AC_SUBST([JavaScriptCPPArgs]) - -# --with-cmm-cpp/--with-cmm-cpp-flags -FP_CMM_CPP_CMD_WITH_ARGS([$CC_STAGE0], [CmmCPPCmd_STAGE0], [CmmCPPArgs_STAGE0], [CmmCPPSupportsG0_STAGE0]) -AC_SUBST([CmmCPPCmd_STAGE0]) -AC_SUBST([CmmCPPArgs_STAGE0]) -AC_SUBST([CmmCPPSupportsG0_STAGE0]) -FP_CMM_CPP_CMD_WITH_ARGS([$CC], [CmmCPPCmd], [CmmCPPArgs], [CmmCPPSupportsG0]) -AC_SUBST([CmmCPPCmd]) -AC_SUBST([CmmCPPArgs]) -AC_SUBST([CmmCPPSupportsG0]) - -FP_SET_CFLAGS_C99([CC],[CFLAGS],[CPPFLAGS]) -FP_SET_CFLAGS_C99([CC_STAGE0],[CONF_CC_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) -FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) -FP_SET_CFLAGS_C99([CC],[CONF_CC_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) - -dnl ** Do we have a compatible emsdk version? -dnl -------------------------------------------------------------- -EMSDK_VERSION("3.1.20", "", "") - -dnl ** Which ld to use -dnl -------------------------------------------------------------- -AC_ARG_VAR(LD,[Use as the path to ld. See also --disable-ld-override.]) -FIND_LD([$target],[GccUseLdOpt]) -FIND_MERGE_OBJECTS() -CONF_GCC_LINKER_OPTS_STAGE1="$CONF_GCC_LINKER_OPTS_STAGE1 $GccUseLdOpt" -CONF_GCC_LINKER_OPTS_STAGE2="$CONF_GCC_LINKER_OPTS_STAGE2 $GccUseLdOpt" -CFLAGS="$CFLAGS $GccUseLdOpt" - -FP_PROG_LD_IS_GNU -FP_PROG_LD_NO_COMPACT_UNWIND -FP_PROG_LD_FILELIST -FP_PROG_LD_SINGLE_MODULE - - -dnl ** Which nm to use? -dnl -------------------------------------------------------------- -FP_FIND_NM - -dnl ** Which objdump to use? -dnl -------------------------------------------------------------- -dnl Note: we may not have objdump on OS X, and we only need it on -dnl Windows (for DLL checks), OpenBSD, and AIX -case $HostOS_CPP in - cygwin32|mingw32|openbsd|aix) - AC_CHECK_TARGET_TOOL([OBJDUMP], [objdump]) - ;; -esac - -if test "$HostOS" = "mingw32" -then - ObjdumpCmd=$(cygpath -m "$OBJDUMP") -else - ObjdumpCmd="$OBJDUMP" -fi -AC_SUBST([ObjdumpCmd]) - -dnl ** Which ranlib to use? -dnl -------------------------------------------------------------- -AC_PROG_RANLIB -if test "$RANLIB" = ":"; then - AC_MSG_ERROR([cannot find ranlib in your PATH]) -fi -if test "$HostOS" = "mingw32" -then - RanlibCmd=$(cygpath -m "$RANLIB") -else - RanlibCmd="$RANLIB" -fi -AC_SUBST([RanlibCmd]) - -dnl ** which strip to use? -dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([STRIP], [strip]) -StripCmd="$STRIP" -AC_SUBST([StripCmd]) - -dnl ** Which otool to use on macOS -dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([OTOOL], [otool]) -OtoolCmd="$OTOOL" -AC_SUBST(OtoolCmd) - -dnl ** Which install_name_tool to use on macOS -dnl -------------------------------------------------------------- -AC_CHECK_TARGET_TOOL([INSTALL_NAME_TOOL], [install_name_tool]) -InstallNameToolCmd="$INSTALL_NAME_TOOL" -AC_SUBST(InstallNameToolCmd) - -# Here is where we re-target which specific version of the LLVM -# tools we are looking for. In the past, GHC supported a number of -# versions of LLVM simultaneously, but that stopped working around -# 3.5/3.6 release of LLVM. -LlvmMinVersion=13 # inclusive -LlvmMaxVersion=21 # not inclusive -AC_SUBST([LlvmMinVersion]) -AC_SUBST([LlvmMaxVersion]) - -ConfiguredEmsdkVersion="${EmsdkVersion}" -AC_SUBST([ConfiguredEmsdkVersion]) - -dnl ** Which LLVM llc to use? -dnl -------------------------------------------------------------- -AC_ARG_VAR(LLC,[Use as the path to LLVM's llc [default=autodetect]]) -FIND_LLVM_PROG([LLC], [llc], [$LlvmMinVersion], [$LlvmMaxVersion]) -LlcCmd="$LLC" -AC_SUBST([LlcCmd]) - -dnl ** Which LLVM opt to use? -dnl -------------------------------------------------------------- -AC_ARG_VAR(OPT,[Use as the path to LLVM's opt [default=autodetect]]) -FIND_LLVM_PROG([OPT], [opt], [$LlvmMinVersion], [$LlvmMaxVersion]) -OptCmd="$OPT" -AC_SUBST([OptCmd]) - -dnl ** Which LLVM assembler to use? -dnl -------------------------------------------------------------- -AC_ARG_VAR(LLVMAS,[Use as the path to LLVM's assembler (typically clang) [default=autodetect]]) -FIND_LLVM_PROG([LLVMAS], [clang], [$LlvmMinVersion], [$LlvmMaxVersion]) -LlvmAsCmd="$LLVMAS" -AC_SUBST([LlvmAsCmd]) - -dnl -------------------------------------------------------------- -dnl End of configure script option section -dnl -------------------------------------------------------------- - -dnl ** Copy headers shared by the RTS and compiler -dnl -------------------------------------------------------------- -dnl We can't commit symlinks without breaking Windows in the default -dnl configuration. -AC_MSG_NOTICE([Creating links for headers shared by the RTS and compiler]) -ln -f rts/include/rts/Bytecodes.h compiler/ -ln -f rts/include/rts/storage/ClosureTypes.h compiler/ -ln -f rts/include/rts/storage/FunTypes.h compiler/ -ln -f rts/include/stg/MachRegs.h compiler/ -mkdir -p compiler/MachRegs -ln -f rts/include/stg/MachRegs/arm32.h compiler/MachRegs/arm32.h -ln -f rts/include/stg/MachRegs/arm64.h compiler/MachRegs/arm64.h -ln -f rts/include/stg/MachRegs/loongarch64.h compiler/MachRegs/loongarch64.h -ln -f rts/include/stg/MachRegs/ppc.h compiler/MachRegs/ppc.h -ln -f rts/include/stg/MachRegs/riscv64.h compiler/MachRegs/riscv64.h -ln -f rts/include/stg/MachRegs/s390x.h compiler/MachRegs/s390x.h -ln -f rts/include/stg/MachRegs/wasm32.h compiler/MachRegs/wasm32.h -ln -f rts/include/stg/MachRegs/x86.h compiler/MachRegs/x86.h -AC_MSG_NOTICE([done.]) - -dnl ** Copy the files from the "fs" utility into the right folders. -dnl -------------------------------------------------------------- -AC_MSG_NOTICE([Creating links for in-tree file handling routines]) -ln -f utils/fs/fs.* utils/unlit/ -ln -f utils/fs/fs.* rts/ -ln -f utils/fs/fs.h libraries/ghc-internal/include/ -ln -f utils/fs/fs.c libraries/ghc-internal/cbits/ -AC_MSG_NOTICE([Routines in place. Packages can now be build normally.]) - -dnl ** Copy files for ghci wrapper C utilities. -dnl -------------------------------------------------------------- -dnl See Note [Hadrian's ghci-wrapper package] in hadrian/src/Packages.hs -AC_MSG_NOTICE([Creating links for ghci wrapper]) -ln -f driver/utils/getLocation.c driver/ghci/ -ln -f driver/utils/getLocation.h driver/ghci/ -ln -f driver/utils/isMinTTY.c driver/ghci/ -ln -f driver/utils/isMinTTY.h driver/ghci/ -ln -f driver/utils/cwrapper.c driver/ghci/ -ln -f driver/utils/cwrapper.h driver/ghci/ -AC_MSG_NOTICE([done.]) - -dnl -------------------------------------------------------------- -dnl ** Can the unix package be built? -dnl -------------------------------------------------------------- - -dnl ** does #! work? -AC_SYS_INTERPRETER() - -dnl ** look for GCC and find out which version -dnl Figure out which C compiler to use. Gcc is preferred. -dnl If gcc, make sure it's at least 4.7 -dnl -FP_GCC_VERSION - - -dnl ** Check support for the extra flags passed by GHC when compiling via C -FP_GCC_SUPPORTS_VIA_C_FLAGS - -dnl ** Used to determine how to compile ghc-prim's atomics.c, used by -dnl unregisterised, Sparc, and PPC backends. Also determines whether -dnl linking to libatomic is required for atomic operations, e.g. on -dnl RISCV64 GCC. -FP_CC_SUPPORTS__ATOMICS -if test "$need_latomic" = 1; then - AC_SUBST([NeedLibatomic],[YES]) -else - AC_SUBST([NeedLibatomic],[NO]) -fi - -dnl ** look to see if we have a C compiler using an llvm back end. -dnl -FP_CC_LLVM_BACKEND -AC_SUBST(CcLlvmBackend) - -FPTOOLS_SET_C_LD_FLAGS([target],[CFLAGS],[LDFLAGS],[IGNORE_LINKER_LD_FLAGS],[CPPFLAGS]) -FPTOOLS_SET_C_LD_FLAGS([build],[CONF_CC_OPTS_STAGE0],[CONF_GCC_LINKER_OPTS_STAGE0],[CONF_LD_LINKER_OPTS_STAGE0],[CONF_CPP_OPTS_STAGE0]) -FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE1],[CONF_GCC_LINKER_OPTS_STAGE1],[CONF_LD_LINKER_OPTS_STAGE1],[CONF_CPP_OPTS_STAGE1]) -FPTOOLS_SET_C_LD_FLAGS([target],[CONF_CC_OPTS_STAGE2],[CONF_GCC_LINKER_OPTS_STAGE2],[CONF_LD_LINKER_OPTS_STAGE2],[CONF_CPP_OPTS_STAGE2]) -# Stage 3 won't be supported by cross-compilation - -#-no_fixup_chains -FP_LD_NO_FIXUP_CHAINS([target], [LDFLAGS]) -FP_LD_NO_FIXUP_CHAINS([build], [CONF_GCC_LINKER_OPTS_STAGE0]) -FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE1]) -FP_LD_NO_FIXUP_CHAINS([target], [CONF_GCC_LINKER_OPTS_STAGE2]) - -#-no_warn_duplicate_libraries -FP_LD_NO_WARN_DUPLICATE_LIBRARIES([build], [CONF_GCC_LINKER_OPTS_STAGE0]) -FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE1]) -FP_LD_NO_WARN_DUPLICATE_LIBRARIES([target], [CONF_GCC_LINKER_OPTS_STAGE2]) - -FP_MERGE_OBJECTS_SUPPORTS_RESPONSE_FILES - -GHC_LLVM_TARGET_SET_VAR -# The target is substituted into the distrib/configure.ac file -AC_SUBST(LlvmTarget) - -dnl ** See whether cc supports --target= and set -dnl CONF_CC_OPTS_STAGE[012] accordingly. -FP_CC_SUPPORTS_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_CXX_OPTS_STAGE0]) -FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_CXX_OPTS_STAGE1]) -FP_CC_SUPPORTS_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_CXX_OPTS_STAGE2]) - -FP_PROG_CC_LINKER_TARGET([$CC_STAGE0], [CONF_CC_OPTS_STAGE0], [CONF_GCC_LINKER_OPTS_STAGE0]) -FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE1], [CONF_GCC_LINKER_OPTS_STAGE1]) -FP_PROG_CC_LINKER_TARGET([$CC], [CONF_CC_OPTS_STAGE2], [CONF_GCC_LINKER_OPTS_STAGE2]) - -dnl ** See whether cc used as a linker supports -no-pie -FP_GCC_SUPPORTS_NO_PIE - -dnl Pass -Qunused-arguments or otherwise GHC will have very noisy invocations of Clang -dnl TODO: Do we need -Qunused-arguments in CXX and GCC linker too? -FP_CC_IGNORE_UNUSED_ARGS([$CC_STAGE0], [CONF_CC_OPTS_STAGE0]) -FP_CC_IGNORE_UNUSED_ARGS([$CC], [CONF_CC_OPTS_STAGE1]) -FP_CC_IGNORE_UNUSED_ARGS([$CC], [CONF_CC_OPTS_STAGE2]) - -# CPP, CPPFLAGS -# --with-cpp/-with-cpp-flags -dnl Note that we must do this after setting and using the C99 CPPFLAGS, or -dnl otherwise risk trying to configure the C99 and LD flags using -E as a CPPFLAG -FP_CPP_CMD_WITH_ARGS([$CC_STAGE0],[CPPCmd_STAGE0],[CONF_CPP_OPTS_STAGE0]) -FP_CPP_CMD_WITH_ARGS([$CC],[CPPCmd],[CONF_CPP_OPTS_STAGE1]) -FP_CPP_CMD_WITH_ARGS([$CC],[CPPCmd],[CONF_CPP_OPTS_STAGE2]) -AC_SUBST([CPPCmd_STAGE0]) -AC_SUBST([CPPCmd]) - -# See rules/distdir-way-opts.mk for details. -# Flags passed to the C compiler -AC_SUBST(CONF_CC_OPTS_STAGE0) -AC_SUBST(CONF_CC_OPTS_STAGE1) -AC_SUBST(CONF_CC_OPTS_STAGE2) -# Flags passed to the C compiler when we ask it to link -AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE0) -AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE1) -AC_SUBST(CONF_GCC_LINKER_OPTS_STAGE2) -# Flags passed to the linker when we ask it to link -AC_SUBST(CONF_LD_LINKER_OPTS_STAGE0) -AC_SUBST(CONF_LD_LINKER_OPTS_STAGE1) -AC_SUBST(CONF_LD_LINKER_OPTS_STAGE2) -# Flags passed to the C preprocessor -AC_SUBST(CONF_CPP_OPTS_STAGE0) -AC_SUBST(CONF_CPP_OPTS_STAGE1) -AC_SUBST(CONF_CPP_OPTS_STAGE2) -# Flags passed to the Haskell compiler -AC_SUBST(CONF_HC_OPTS_STAGE0) -AC_SUBST(CONF_HC_OPTS_STAGE1) -AC_SUBST(CONF_HC_OPTS_STAGE2) - -dnl Identify C++ standard library flavour and location only when _not_ compiling -dnl the JS backend. The JS backend uses emscripten to wrap c++ utilities which -dnl fails this check, so we avoid it when compiling to JS. -if test "$TargetOS" != "ghcjs"; then - FP_FIND_CXX_STD_LIB -fi -AC_CONFIG_FILES([mk/system-cxx-std-lib-1.0.conf]) - -dnl ** Set up the variables for the platform in the settings file. -dnl May need to use gcc to find platform details. -dnl -------------------------------------------------------------- -FPTOOLS_SET_HASKELL_PLATFORM_VARS([Build]) - -FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host]) -AC_SUBST(HaskellHostArch) -AC_SUBST(HaskellHostOs) - -FPTOOLS_SET_HASKELL_PLATFORM_VARS([Target]) -AC_SUBST(HaskellTargetArch) -AC_SUBST(HaskellTargetOs) - -GHC_SUBSECTIONS_VIA_SYMBOLS -AC_SUBST(TargetHasSubsectionsViaSymbols) - -GHC_IDENT_DIRECTIVE -AC_SUBST(TargetHasIdentDirective) - -GHC_GNU_NONEXEC_STACK -AC_SUBST(TargetHasGnuNonexecStack) - -dnl Let's make sure install-sh is executable here. If we got it from -dnl a darcs repo, it might not be (see bug #978). -chmod +x install-sh -dnl ** figure out how to do a BSD-ish install -AC_PROG_INSTALL - -dnl ** how to invoke `ar' and `ranlib' -FP_PROG_AR_SUPPORTS_ATFILE -FP_PROG_AR_SUPPORTS_DASH_L -FP_PROG_AR_NEEDS_RANLIB - -dnl ** Check to see whether ln -s works -AC_PROG_LN_S - -FP_SETTINGS - -dnl ** Find the path to sed -AC_PATH_PROGS(SedCmd,gsed sed,sed) - - -dnl ** check for time command -AC_PATH_PROG(TimeCmd,time) - -dnl ** check for tar -dnl if GNU tar is named gtar, look for it first. -AC_PATH_PROGS(TarCmd,gnutar gtar tar,tar) - -dnl ** check for autoreconf -AC_PATH_PROG(AutoreconfCmd, autoreconf, autoreconf) - -dnl ** check for dtrace (currently only implemented for Mac OS X) -AC_ARG_ENABLE(dtrace, - [AS_HELP_STRING([--enable-dtrace], - [Enable DTrace])], - EnableDtrace=$enableval, - EnableDtrace=yes -) - -HaveDtrace=NO - -AC_PATH_PROG(DtraceCmd,dtrace) -if test "x$EnableDtrace" = "xyes"; then - if test -n "$DtraceCmd"; then - if test "x$TargetOS_CPP-$TargetVendor_CPP" = "xdarwin-apple" \ - -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xfreebsd-portbld" \ - -o "x$TargetOS_CPP-$TargetVendor_CPP" = "xsolaris2-unknown"; then - HaveDtrace=YES - fi - fi -fi -AC_SUBST(HaveDtrace) - -AC_PATH_PROG(HSCOLOUR,HsColour) -# HsColour is passed to Cabal, so we need a native path -if test "$HostOS" = "mingw32" && \ - test "${OSTYPE}" != "msys" && \ - test "${HSCOLOUR}" != "" -then - # Canonicalise to :/path/to/gcc - HSCOLOUR=`cygpath -m ${HSCOLOUR}` -fi - -dnl ** check for Sphinx toolchain -AC_PATH_PROG(SPHINXBUILD,sphinx-build) -AC_CACHE_CHECK([for version of sphinx-build], fp_cv_sphinx_version, -changequote(, )dnl -[if test -n "$SPHINXBUILD"; then - fp_cv_sphinx_version=`"$SPHINXBUILD" --version 2>&1 | sed -re 's/.* v?([0-9]\.[0-9]\.[0-9])/\1/' | head -n1`; -fi; -changequote([, ])dnl +AC_INIT([ghc-builder], [0.1.0], [your-email@example.com]) +AC_CONFIG_SRCDIR([.]) # A representative .in file +#AC_CONFIG_AUX_DIR([build-aux]) # Recommended place for config.guess, config.sub +AC_CONFIG_MACRO_DIR([m4]) # For any custom m4 macros +# AM_INIT_AUTOMAKE([-Wall -Werror foreign]) # Using some automake conventions + +# --- Define GHC Build Options --- +# Usage: ./configure ProjectVersion=X.Y ... +AC_ARG_WITH([project-version], [AS_HELP_STRING([--with-project-version=VER], [GHC version (default: 9.14)])], [ProjectVersion="$withval"], [ProjectVersion="9.14"]) +AC_ARG_WITH([project-version-int], [AS_HELP_STRING([--with-project-version-int=VER], [GHC version as int (default: 913)])], [ProjectVersionInt="$withval"], [ProjectVersionInt="913"]) +AC_ARG_WITH([project-version-munged], [AS_HELP_STRING([--with-project-version-munged=VER], [GHC version "munged" (default: 9.14)])], [ProjectVersionMunged="$withval"], [ProjectVersionMunged="9.14"]) +AC_ARG_WITH([project-version-for-lib], [AS_HELP_STRING([--with-project-version-for-lib=VER], [GHC version for libraries (default: 9.1400)])], [ProjectVersionForLib="$withval"], [ProjectVersionForLib="9.1400"]) +AC_ARG_WITH([project-patch-level], [AS_HELP_STRING([--with-project-patch-level=VER], [GHC patchlevel version (default: 0)])], [ProjectPatchLevel="$withval"], [ProjectPatchLevel="0"]) +AC_ARG_WITH([project-patch-level1], [AS_HELP_STRING([--with-project-patch-level1=VER], [GHC patchlevel1 version (default: 0)])], [ProjectPatchLevel1="$withval"], [ProjectPatchLevel1="0"]) +AC_ARG_WITH([project-patch-level2], [AS_HELP_STRING([--with-project-patch-level2=VER], [GHC patchlevel2 version (default: 0)])], [ProjectPatchLevel2="$withval"], [ProjectPatchLevel2="0"]) + +# Export these variables for substitution by AC_SUBST +AC_SUBST([ProjectVersion]) +AC_SUBST([ProjectVersionInt]) +AC_SUBST([ProjectVersionMunged]) +AC_SUBST([ProjectVersionForLib]) +AC_SUBST([ProjectPatchLevel]) +AC_SUBST([ProjectPatchLevel1]) +AC_SUBST([ProjectPatchLevel2]) + +# For ghc-boot-th.cabal.in +AC_SUBST([Suffix],[""]) +AC_SUBST([SourceRoot],["."]) + +# --- Feature toggle (dynamic only) for imported project settings --- +AC_ARG_ENABLE([dynamic], + [AS_HELP_STRING([--enable-dynamic],[Build shared libraries and enable dynamic RTS])], + [enable_dynamic=$enableval],[enable_dynamic=no]) + +# Initialize accumulation variables +ALL_PACKAGES="" +CONSTRAINTS="" + +# Provide defaults first (static) +APPEND_PKG_FIELD([shared: False]) +APPEND_PKG_FIELD([executable-dynamic: False]) + +AS_IF([test "x$enable_dynamic" = "xyes"], [ + # Override (we rebuild list to avoid mixing static+dynamic lines) + ALL_PACKAGES="" + APPEND_PKG_FIELD([shared: True]) + APPEND_PKG_FIELD([executable-dynamic: True]) + APPEND_CONSTRAINT([rts +dynamic]) ]) -FP_COMPARE_VERSIONS([$fp_cv_sphinx_version],-lt,1.0.0, - [AC_MSG_WARN([Sphinx version 1.0.0 or later is required to build documentation]); SPHINXBUILD=;]) -if test -n "$SPHINXBUILD"; then - if "$SPHINXBUILD" -b text utils/check-sphinx utils/check-sphinx/dist > /dev/null 2>&1; then true; else - AC_MSG_WARN([Sphinx for python3 is required to build documentation.]) - SPHINXBUILD=; - fi -fi - -dnl ** check for xelatex -AC_PATH_PROG(XELATEX,xelatex) -AC_PATH_PROG(MAKEINDEX,makeindex) -AC_PATH_PROG(GIT,git) - -dnl ** check for makeinfo -AC_PATH_PROG(MAKEINFO,makeinfo) - -dnl ** check for cabal -AC_PATH_PROG(CABAL,cabal) - -dnl ** check for Python for testsuite driver -FIND_PYTHON - -dnl ** check for ghc-pkg command -FP_PROG_GHC_PKG - -dnl ** check for installed happy binary + version - -AC_ARG_VAR(HAPPY,[Use as the path to happy [default=autodetect]]) -FPTOOLS_HAPPY - -dnl ** check for installed alex binary + version - -AC_ARG_VAR(ALEX,[Use as the path to alex [default=autodetect]]) -FPTOOLS_ALEX - -dnl -------------------------------------------------- -dnl ### program checking section ends here ### -dnl -------------------------------------------------- - -dnl for use in settings file -AC_CHECK_SIZEOF([void *]) -TargetWordSize=$ac_cv_sizeof_void_p -AC_SUBST(TargetWordSize) - -AC_C_BIGENDIAN([TargetWordBigEndian=YES],[TargetWordBigEndian=NO]) -AC_SUBST(TargetWordBigEndian) - -dnl ** check for math library -dnl Keep that check as early as possible. -dnl as we need to know whether we need libm -dnl for math functions or not -dnl (see https://gitlab.haskell.org/ghc/ghc/issues/3730) -AC_CHECK_LIB(m, atan, UseLibm=YES, UseLibm=NO) -AC_SUBST([UseLibm]) -TargetHasLibm=$UseLibm -AC_SUBST(TargetHasLibm) - -FP_BFD_FLAG -AC_SUBST([UseLibbfd]) - -dnl ################################################################ -dnl Check for libraries -dnl ################################################################ - -FP_FIND_LIBFFI -AC_SUBST(UseSystemLibFFI) -AC_SUBST(FFILibDir) -AC_SUBST(FFIIncludeDir) - -dnl ** check whether we need -ldl to get dlopen() -AC_CHECK_LIB([dl], [dlopen], UseLibdl=YES, UseLibdl=NO) -AC_SUBST([UseLibdl]) - -dnl ** check for leading underscores in symbol names -FP_LEADING_UNDERSCORE -AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`]) - -dnl ** check for librt -AC_CHECK_LIB([rt], [clock_gettime], UseLibrt=YES, UseLibrt=NO) -AC_SUBST([UseLibrt]) - -FP_CHECK_PTHREAD_LIB -AC_SUBST([UseLibpthread]) - -GHC_ADJUSTORS_METHOD([Target]) -AC_SUBST([UseLibffiForAdjustors]) - -dnl ** IPE data compression -dnl -------------------------------------------------------------- -FP_FIND_LIBZSTD -AC_SUBST(UseLibZstd) -AC_SUBST(UseStaticLibZstd) -AC_SUBST(LibZstdLibDir) -AC_SUBST(LibZstdIncludeDir) - -dnl ** Other RTS features -dnl -------------------------------------------------------------- -FP_FIND_LIBDW -AC_SUBST(UseLibdw) -AC_SUBST(LibdwLibDir) -AC_SUBST(LibdwIncludeDir) - -FP_FIND_LIBNUMA -AC_SUBST(UseLibNuma) -AC_SUBST(LibNumaLibDir) -AC_SUBST(LibNumaIncludeDir) - -dnl ** Documentation -dnl -------------------------------------------------------------- -if test -n "$SPHINXBUILD"; then - BUILD_MAN=YES - BUILD_SPHINX_HTML=YES - if test -n "$XELATEX" -a -n "$MAKEINDEX"; then - BUILD_SPHINX_PDF=YES - else - BUILD_SPHINX_PDF=NO - fi - if test -n "$MAKEINFO"; then - BUILD_SPHINX_INFO=YES - else - BUILD_SPHINX_INFO=NO - fi -else - BUILD_MAN=NO - BUILD_SPHINX_HTML=NO - BUILD_SPHINX_PDF=NO - BUILD_SPHINX_INFO=NO -fi -AC_SUBST(BUILD_MAN) -AC_SUBST(BUILD_SPHINX_HTML) -AC_SUBST(BUILD_SPHINX_PDF) - -if grep ' ' compiler/ghc.cabal.in 2>&1 >/dev/null; then - AC_MSG_ERROR([compiler/ghc.cabal.in contains tab characters; please remove them]) -fi - -# We got caught by -# http://savannah.gnu.org/bugs/index.php?1516 -# $(eval ...) inside conditionals causes errors -# with make 3.80, so warn the user if it looks like they're about to -# try to use it. -# We would use "grep -q" here, but Solaris's grep doesn't support it. -print_make_warning="" -checkMake380() { - make_ver=`$1 --version 2>&1 | head -1` - if echo "$make_ver" | grep 'GNU Make 3\.80' > /dev/null - then - print_make_warning="true" - fi - if echo "$make_ver" | grep 'GNU Make' > /dev/null - then - MakeCmd=$1 - AC_SUBST(MakeCmd) - fi -} - -checkMake380 make -checkMake380 gmake - -# Toolchain target files -FIND_GHC_TOOLCHAIN_BIN([NO]) -PREP_TARGET_FILE -FIND_GHC_TOOLCHAIN([hadrian/cfg]) - -AC_CONFIG_FILES( -[ hadrian/cfg/system.config - hadrian/ghci-cabal - hadrian/ghci-multi-cabal - hadrian/ghci-stack - hadrian/cfg/default.host.target - hadrian/cfg/default.target +# Indent with two spaces for substitution blocks (uniform handling) +ALL_PACKAGES=`printf '%b' "$ALL_PACKAGES"` +CONSTRAINTS=`printf '%b' "$CONSTRAINTS"` +ALL_PACKAGES_INDENTED=`printf '%s' "$ALL_PACKAGES" | sed 's/^/ /'` +CONSTRAINTS_INDENTED=`printf '%s' "$CONSTRAINTS" | sed 's/^/ /'` +ALL_PACKAGES="$ALL_PACKAGES_INDENTED" +AS_IF([test "x$CONSTRAINTS" = "x"], [CONSTRAINTS=" -- (none)"], [CONSTRAINTS="$CONSTRAINTS_INDENTED"]) + +AC_SUBST([ALL_PACKAGES]) +AC_SUBST([CONSTRAINTS]) + +# --- Define Programs --- +# We don't need to check for CC, MAKE_SET, and others for now, we only want substitution. +# AC_PROG_CC +# AC_PROG_MAKE_SET # To ensure 'set' works in Makefiles for undefined variables +AC_CHECK_PROGS([PYTHON], [python3 python python2]) +AS_IF([test "x$PYTHON" = x], [AC_MSG_ERROR([Python interpreter not found. Please install Python or set PYTHON environment variable.])]) +AC_SUBST([PYTHON]) + +# --- Files to generate --- +# config.status will create these files by substituting @VAR@ placeholders. +AC_CONFIG_FILES([ + ghc/ghc-bin.cabal:ghc/ghc-bin.cabal.in + compiler/ghc.cabal:compiler/ghc.cabal.in + compiler/GHC/CmmToLlvm/Version/Bounds.hs:compiler/GHC/CmmToLlvm/Version/Bounds.hs.in + libraries/ghc-boot/ghc-boot.cabal:libraries/ghc-boot/ghc-boot.cabal.in + libraries/ghc-boot-th/ghc-boot-th.cabal:libraries/ghc-boot-th/ghc-boot-th.cabal.in + libraries/ghc-boot-th-next/ghc-boot-th-next.cabal:libraries/ghc-boot-th-next/ghc-boot-th-next.cabal.in + libraries/ghc-heap/ghc-heap.cabal:libraries/ghc-heap/ghc-heap.cabal.in + libraries/template-haskell/template-haskell.cabal:libraries/template-haskell/template-haskell.cabal.in + libraries/ghci/ghci.cabal:libraries/ghci/ghci.cabal.in + utils/ghc-pkg/ghc-pkg.cabal:utils/ghc-pkg/ghc-pkg.cabal.in + utils/ghc-iserv/ghc-iserv.cabal:utils/ghc-iserv/ghc-iserv.cabal.in + utils/runghc/runghc.cabal:utils/runghc/runghc.cabal.in + libraries/ghc-internal/ghc-internal.cabal:libraries/ghc-internal/ghc-internal.cabal.in + libraries/ghc-experimental/ghc-experimental.cabal:libraries/ghc-experimental/ghc-experimental.cabal.in + libraries/base/base.cabal:libraries/base/base.cabal.in + rts/include/ghcversion.h:rts/include/ghcversion.h.in + cabal.project.stage2.settings:cabal.project.stage2.settings.in ]) -dnl Create the VERSION file, satisfying #22322. -printf "$ProjectVersion" > VERSION - AC_OUTPUT -[ -if test "$print_make_warning" = "true"; then - echo - echo "WARNING: It looks like \"$MakeCmd\" is GNU make 3.80." - echo "This version cannot be used to build GHC." - echo "Please use GNU make >= 3.81." -fi - -echo " ----------------------------------------------------------------------- -Configure completed successfully. - - Building GHC version : $ProjectVersion - Git commit id : $ProjectGitCommitId - - Build platform : $BuildPlatform - Host platform : $HostPlatform - Target platform : $TargetPlatform -" - -echo "\ - Bootstrapping using : $WithGhc - which is version : $GhcVersion - with threaded RTS? : $GhcThreadedRts -" - -if test "x$CcLlvmBackend" = "xYES"; then - CompilerName="clang " -else - CompilerName="gcc " -fi - -echo "\ - Using (for bootstrapping) : $CC_STAGE0 - Using $CompilerName : $CC - which is version : $GccVersion - linker options : $GccUseLdOpt - Building a cross compiler : $CrossCompiling - Unregisterised : $Unregisterised - TablesNextToCode : $TablesNextToCode - Build GMP in tree : $GMP_FORCE_INTREE - cpp : $CPPCmd - cpp-flags : $CONF_CPP_OPTS_STAGE2 - hs-cpp : $HaskellCPPCmd - hs-cpp-flags : $HaskellCPPArgs - js-cpp : $JavaScriptCPPCmd - js-cpp-flags : $JavaScriptCPPArgs - cmmcpp : $CmmCPPCmd - cmmcpp-flags : $CmmCPPArgs - cmmcpp-g0 : $CmmCPPSupportsG0 - c++ : $CXX - ar : $ArCmd - nm : $NmCmd - objdump : $ObjdumpCmd - ranlib : $RanlibCmd - otool : $OtoolCmd - install_name_tool : $InstallNameToolCmd - windres : $WindresCmd - genlib : $GenlibCmd - Happy : $HappyCmd ($HappyVersion) - Alex : $AlexCmd ($AlexVersion) - sphinx-build : $SPHINXBUILD - xelatex : $XELATEX - makeinfo : $MAKEINFO - git : $GIT - cabal-install : $CABAL -" - -echo "\ - Using optional dependencies: - libnuma : $UseLibNuma - libzstd : $UseLibZstd - statically linked? : ${UseStaticLibZstd:-N/A} - libdw : $UseLibdw - - Using LLVM tools - llc : $LlcCmd - opt : $OptCmd - llvm-as : $LlvmAsCmd" - -if test "$HSCOLOUR" = ""; then -echo " - HsColour was not found; documentation will not contain source links -" -else -echo "\ - HsColour : $HSCOLOUR -" -fi - -echo "\ - Tools to build Sphinx HTML documentation available: $BUILD_SPHINX_HTML - Tools to build Sphinx PDF documentation available: $BUILD_SPHINX_PDF - Tools to build Sphinx INFO documentation available: $BUILD_SPHINX_INFO" - -echo "---------------------------------------------------------------------- -" - -echo "\ -For a standard build of GHC (fully optimised with profiling), type - ./hadrian/build - -You can customise the build with flags such as - ./hadrian/build -j --flavour=devel2 [--freeze1] - -To make changes to the default build configuration, see the file - hadrian/src/UserSettings.hs - -For more information on how to configure your GHC build, see - https://gitlab.haskell.org/ghc/ghc/-/wikis/building/hadrian -"] - -# Currently we don't validate the /host/ GHC toolchain because configure -# doesn't configure flags and properties for most of the host toolchain -# -# In fact, most values in default.host.target are dummy values since they are -# never used (see default.host.target.in) -# -# When we move to configure toolchains by means of ghc-toolchain only, we'll -# have a correct complete /host/ toolchain rather than an incomplete one, which -# might further unlock things like canadian cross-compilation -# -# VALIDATE_GHC_TOOLCHAIN([default.host.target],[default.host.target.ghc-toolchain]) - -VALIDATE_GHC_TOOLCHAIN([hadrian/cfg/default.target],[hadrian/cfg/default.target.ghc-toolchain]) -rm -Rf acargs acghc-toolchain actmp-ghc-toolchain +# After running ./configure, the following command can be used to see configured values: +# ./config.status --config diff --git a/hie.yaml b/hie.yaml index 34dde0452ad1..3248a0262221 100644 --- a/hie.yaml +++ b/hie.yaml @@ -1,8 +1,4 @@ -# This is a IDE configuration file which tells IDEs such as `ghcide` how -# to set up a GHC API session for this project. -# -# To use it in windows systems replace the config with -# cradle: {bios: {program: "./hadrian/hie-bios.bat"}} -# -# The format is documented here - https://github.com/mpickering/hie-bios -cradle: {bios: {program: "./hadrian/hie-bios"}} +# This is not perfect but it works ok +cradle: + cabal: + cabalProject: cabal.project.stage1 \ No newline at end of file diff --git a/libraries/ghc-boot-th/ghc-boot-th.cabal.in b/libraries/ghc-boot-th/ghc-boot-th.cabal.in index 03bbf9d9f342..2e26821636ee 100644 --- a/libraries/ghc-boot-th/ghc-boot-th.cabal.in +++ b/libraries/ghc-boot-th/ghc-boot-th.cabal.in @@ -56,7 +56,7 @@ Library cpp-options: -DBOOTSTRAP_TH build-depends: ghc-prim - hs-source-dirs: @SourceRoot@ ../ghc-internal/src + hs-source-dirs: ../ghc-boot-th ../ghc-internal/src exposed-modules: GHC.Boot.TH.Lib GHC.Boot.TH.Syntax diff --git a/m4/accumulate.m4 b/m4/accumulate.m4 new file mode 100644 index 000000000000..9ee1496f67b5 --- /dev/null +++ b/m4/accumulate.m4 @@ -0,0 +1,21 @@ +# Helper macros to accumulate package fields and constraints without leading newline. +# Usage: APPEND_PKG_FIELD([shared: True]) +# APPEND_CONSTRAINT([rts +dynamic]) + +AC_DEFUN([APPEND_PKG_FIELD], [ + AS_IF([test "x$ALL_PACKAGES" = "x"], [ + AS_VAR_SET([ALL_PACKAGES], ["$1"]) + ], [ + AS_VAR_APPEND([ALL_PACKAGES], [" +$1"]) + ]) +]) + +AC_DEFUN([APPEND_CONSTRAINT], [ + AS_IF([test "x$CONSTRAINTS" = "x"], [ + AS_VAR_SET([CONSTRAINTS], ["$1"]) + ], [ + AS_VAR_APPEND([CONSTRAINTS], [" +$1"]) + ]) +]) diff --git a/m4/fp_check_pthreads.m4 b/m4/fp_check_pthreads.m4 index 55657f60b550..ab007fc01887 100644 --- a/m4/fp_check_pthreads.m4 +++ b/m4/fp_check_pthreads.m4 @@ -12,22 +12,7 @@ AC_DEFUN([FP_CHECK_PTHREAD_LIB], dnl dnl Note that it is important that this happens before we AC_CHECK_LIB(thread) AC_MSG_CHECKING(whether -lpthread is needed for pthreads) - AC_CHECK_FUNC(pthread_create, - [ - AC_MSG_RESULT(no) - UseLibpthread=NO - ], - [ - AC_CHECK_LIB(pthread, pthread_create, - [ - AC_MSG_RESULT(yes) - UseLibpthread=YES - ], - [ - AC_MSG_RESULT([no pthreads support found.]) - UseLibpthread=NO - ]) - ]) + AC_SEARCH_LIBS([pthread_create],[pthread]) ]) # FP_CHECK_PTHREAD_FUNCS @@ -37,6 +22,7 @@ AC_DEFUN([FP_CHECK_PTHREAD_LIB], # `AC_DEFINE`s various C `HAVE_*` macros. AC_DEFUN([FP_CHECK_PTHREAD_FUNCS], [ + OLD_LIBS=$LIBS dnl Setting thread names dnl ~~~~~~~~~~~~~~~~~~~~ dnl The portability situation here is complicated: @@ -123,4 +109,5 @@ AC_DEFUN([FP_CHECK_PTHREAD_FUNCS], ) AC_CHECK_FUNCS_ONCE([pthread_condattr_setclock]) + LIBS=$OLD_LIBS ])