Skip to content

Commit aee37a5

Browse files
author
GHC GitLab CI
committed
chore: Final improvements and cleanup
- Update hie.yaml for cabal build - Improve error messages - Fix build process issues - Update dependencies
1 parent 1cd13f4 commit aee37a5

File tree

6 files changed

+222
-79
lines changed

6 files changed

+222
-79
lines changed

Makefile

Lines changed: 85 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,25 +87,31 @@ GHC0 ?= ghc-9.8.4
8787
PYTHON ?= python3
8888
CABAL ?= cabal
8989

90+
EMCC ?= emcc
91+
EMCXX ?= em++
92+
EMAR ?= emar
93+
EMRANLIB ?= emranlib
94+
9095
# :exploding-head: It turns out override doesn't override the command-line
9196
# value but it overrides Make's normal behavior of ignoring assignments to
9297
# command-line variables. This allows the += operations to append to whatever
9398
# was passed from the command line.
9499

95100
override CABAL_ARGS += \
96101
--remote-repo-cache _build/packages \
97-
--store-dir=_build/$(STAGE)/store \
102+
--store-dir=_build/$(STAGE)/$(TARGET)/store \
98103
--logs-dir=_build/$(STAGE)/logs
99104

100105
override CABAL_BUILD_ARGS += \
101106
-j -w $(GHC) --with-gcc=$(CC) \
102107
--project-file=cabal.project.$(STAGE) \
103-
--builddir=_build/$(STAGE) \
108+
--builddir=_build/$(STAGE)/$(TARGET) \
104109
--ghc-options="-fhide-source-paths"
105110

106111
# just some defaults
107112
STAGE ?= stage1
108113
GHC ?= $(GHC0)
114+
TARGET ?=
109115

110116
CABAL_BUILD = $(CABAL) $(CABAL_ARGS) build $(CABAL_BUILD_ARGS)
111117

@@ -231,6 +237,33 @@ STAGE2_UTIL_EXECUTABLES := \
231237
runghc \
232238
unlit
233239

240+
STAGE2_TARGET_LIBS := \
241+
Cabal \
242+
Cabal-syntax \
243+
array \
244+
base \
245+
binary \
246+
bytestring \
247+
containers \
248+
deepseq \
249+
directory \
250+
exceptions \
251+
file-io \
252+
filepath \
253+
hpc \
254+
integer-gmp \
255+
mtl \
256+
os-string \
257+
parsec \
258+
pretty \
259+
process \
260+
stm \
261+
template-haskell \
262+
text \
263+
time \
264+
transformers \
265+
xhtml
266+
234267
# 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)
235268
$(abspath _build/stage0/bin/cabal): _build/stage0/bin/cabal
236269

@@ -300,6 +333,12 @@ $(addprefix _build/stage2/bin/,$(STAGE2_EXECUTABLES)) &: $(CABAL) stage1
300333
@echo "::group::Building stage2 executables ($(STAGE2_EXECUTABLES))..."
301334
# Force cabal to replan
302335
rm -rf _build/stage2/cache
336+
# Building of rts:nonthreaded-nodebug should not be necessary as it should be
337+
# pulled in by the `ghc-bin` target, which is the only one in the STAGE2_TARGETS.
338+
#
339+
# HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
340+
# PATH=$(PWD)/_build/stage1/bin:$(PATH) \
341+
# $(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) rts:nonthreaded-nodebug
303342
HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
304343
PATH=$(PWD)/_build/stage1/bin:$(PATH) \
305344
$(CABAL_BUILD) --ghc-options="-ghcversion-file=$(abspath ./rts/include/ghcversion.h)" -W $(GHC0) $(STAGE2_TARGETS)
@@ -366,6 +405,50 @@ _build/stage2/lib/template-hsc.h: utils/hsc2hs/data/template-hsc.h
366405
.PHONY: stage2
367406
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
368407

408+
.PHONY: stage2-javascript-unknown-ghcjs
409+
stage2-javascript-unknown-ghcjs: javascript-unknown-ghcjs-libs _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache
410+
411+
_build/stage2/lib/targets/javascript-unknown-ghcjs/lib/settings: _build/stage1/bin/ghc-toolchain-bin
412+
@mkdir -p $(@D)
413+
$(call run_and_log, emconfigure _build/stage1/bin/ghc-toolchain-bin --triple javascript-unknown-ghcjs --output-settings -o $@ --cc $(EMCC) --cxx $(EMCXX) --ar $(EMAR) --ranlib $(EMRANLIB))
414+
415+
_build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg: _build/stage2/bin/ghc-pkg
416+
@mkdir -p $(@D)
417+
ln -sf ghc-pkg $@
418+
419+
_build/stage2/bin/javascript-unknown-ghcjs-ghc: _build/stage2/bin/ghc
420+
@mkdir -p $(@D)
421+
ln -sf ghc $@
422+
423+
_build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d:
424+
@mkdir -p $@
425+
426+
_build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d/package.cache: _build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/settings javascript-unknown-ghcjs-libs
427+
@mkdir -p $(@D)
428+
@rm -rf $(@D)/*
429+
cp -rfp _build/stage2/javascript-unknown-ghcjs/packagedb/host/*/* $(@D)
430+
_build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg recache
431+
432+
_build/stage2/lib/targets/javascript-unknown-ghcjs/bin/unlit: _build/stage2/bin/unlit
433+
@mkdir -p $(@D)
434+
cp -rfp $< $@
435+
436+
.PHONY: javascript-unknown-ghcjs-libs
437+
javascript-unknown-ghcjs-libs: private TARGET=javascript-unknown-ghcjs
438+
javascript-unknown-ghcjs-libs: private GHC=$(abspath _build/stage2/bin/javascript-unknown-ghcjs-ghc)
439+
javascript-unknown-ghcjs-libs: private GHC2=$(abspath _build/stage2/bin/ghc)
440+
javascript-unknown-ghcjs-libs: private STAGE=stage2
441+
javascript-unknown-ghcjs-libs: private CC=emcc
442+
javascript-unknown-ghcjs-libs: _build/stage2/bin/javascript-unknown-ghcjs-ghc-pkg _build/stage2/bin/javascript-unknown-ghcjs-ghc _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/settings _build/stage2/lib/targets/javascript-unknown-ghcjs/bin/unlit _build/stage2/lib/targets/javascript-unknown-ghcjs/lib/package.conf.d
443+
# Force cabal to replan
444+
rm -rf _build/stage2/javascript-unknown-ghcjs/cache
445+
$(call run_and_log, HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
446+
PATH=$(PWD)/_build/stage2/bin:$(PATH) \
447+
$(CABAL_BUILD) -W $(GHC2) --happy-options="--template=$(abspath _build/stage2/src/happy-lib-2.1.5/data/)" rts:nonthreaded-nodebug )
448+
$(call run_and_log, HADRIAN_SETTINGS='$(HADRIAN_SETTINGS)' \
449+
PATH=$(PWD)/_build/stage2/bin:$(PATH) \
450+
$(CABAL_BUILD) -W $(GHC2) --happy-options="--template=$(abspath _build/stage2/src/happy-lib-2.1.5/data/)" $(STAGE2_TARGET_LIBS) )
451+
369452
# Target for creating the final binary distribution directory
370453
_build/bindist: stage2 driver/ghc-usage.txt driver/ghci-usage.txt
371454
@echo "::group::Creating binary distribution in _build/bindist"

cabal.project.stage2

Lines changed: 53 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,6 @@ packages:
2222
libraries/template-haskell
2323
libraries/hpc
2424
libraries/system-cxx-std-lib
25-
ghc
26-
utils/ghc-pkg
27-
utils/hsc2hs
28-
utils/unlit
29-
utils/genprimopcode
30-
utils/deriveConstants
31-
utils/ghc-toolchain
3225
libraries/array
3326
libraries/binary
3427
libraries/bytestring
@@ -50,19 +43,31 @@ packages:
5043
libraries/unix
5144
libraries/xhtml
5245
libraries/Win32
46+
5347
libraries/Cabal/Cabal-syntax
5448
libraries/Cabal/Cabal
5549
https://hackage.haskell.org/package/alex-3.5.2.0/alex-3.5.2.0.tar.gz
5650
https://hackage.haskell.org/package/happy-2.1.5/happy-2.1.5.tar.gz
5751
https://hackage.haskell.org/package/happy-lib-2.1.5/happy-lib-2.1.5.tar.gz
5852

59-
libraries/haskeline
60-
libraries/terminfo
61-
utils/hp2ps
62-
utils/hpc
63-
utils/ghc-iserv
64-
utils/genapply
65-
utils/runghc
53+
utils/genprimopcode
54+
utils/deriveConstants
55+
56+
if !arch(javascript)
57+
packages:
58+
ghc
59+
utils/ghc-pkg
60+
utils/hsc2hs
61+
utils/unlit
62+
utils/ghc-toolchain
63+
64+
libraries/haskeline
65+
libraries/terminfo
66+
utils/hp2ps
67+
utils/hpc
68+
utils/ghc-iserv
69+
utils/genapply
70+
utils/runghc
6671

6772

6873
-- project-rts
@@ -71,6 +76,40 @@ tests: False
7176
allow-boot-library-installs: True
7277
active-repositories: :none
7378

79+
if arch(javascript)
80+
constraints:
81+
Cabal source,
82+
Cabal-syntax source,
83+
array source,
84+
base source,
85+
binary source,
86+
bytestring source,
87+
containers source,
88+
deepseq source,
89+
directory source,
90+
exceptions source,
91+
file-io source,
92+
filepath source,
93+
hpc source,
94+
integer-gmp source,
95+
mtl source,
96+
os-string source,
97+
parsec source,
98+
pretty source,
99+
process source,
100+
rts source,
101+
rts-headers source,
102+
rts-fs source,
103+
stm source,
104+
system-cxx-std-lib source,
105+
template-haskell source,
106+
text source,
107+
time source,
108+
transformers source,
109+
unix source,
110+
xhtml source,
111+
Win32 source
112+
74113
constraints:
75114
-- we do not want to use the rts-headers from stage1
76115
rts-headers source, rts-fs source

hie.yaml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,4 @@
1-
# This is a IDE configuration file which tells IDEs such as `ghcide` how
2-
# to set up a GHC API session for this project.
3-
#
4-
# To use it in windows systems replace the config with
5-
# cradle: {bios: {program: "./hadrian/hie-bios.bat"}}
6-
#
7-
# The format is documented here - https://github.com/mpickering/hie-bios
1+
# This is not perfect but it works ok
82
cradle:
9-
multi:
10-
- path: Build.hs
11-
config:
12-
cradle:
13-
direct:
14-
arguments: []
15-
- path: "*"
16-
config:
17-
cradle: {bios: {program: "./hadrian/hie-bios"}}
3+
cabal:
4+
cabalProject: cabal.project.stage1

rts/configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ dnl
560560
if $DERIVE_CONSTANTS \
561561
--gen-header \
562562
-o include/DerivedConstants.h \
563-
--target-os "$BuildOS_CPP" \
563+
--target-os "$HostOS_CPP" \
564564
--gcc-program "$CC" \
565565
--nm-program "$NM" \
566566
--objdump-program "$OBJDUMP" \

rts/rts.cabal

Lines changed: 46 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -338,19 +338,20 @@ common rts-base-config
338338
rts
339339

340340
common rts-c-sources-base
341-
cmm-sources:
342-
Apply.cmm
343-
Compact.cmm
344-
ContinuationOps.cmm
345-
Exception.cmm
346-
HeapStackCheck.cmm
347-
Jumps_D.cmm
348-
Jumps_V16.cmm
349-
PrimOps.cmm
350-
StgMiscClosures.cmm
351-
StgStartup.cmm
352-
StgStdThunks.cmm
353-
Updates.cmm
341+
if !arch(javascript)
342+
cmm-sources:
343+
Apply.cmm
344+
Compact.cmm
345+
ContinuationOps.cmm
346+
Exception.cmm
347+
HeapStackCheck.cmm
348+
Jumps_D.cmm
349+
Jumps_V16.cmm
350+
PrimOps.cmm
351+
StgMiscClosures.cmm
352+
StgStartup.cmm
353+
StgStdThunks.cmm
354+
Updates.cmm
354355

355356
-- Adjustor stuff
356357
if flag(libffi-adjustors)
@@ -689,33 +690,34 @@ library
689690
rts-headers,
690691
rts-fs
691692

692-
-- FIXME: by virtue of being part of the rts main library, these do not get
693-
-- the flags (debug, threaded, ...) as the sub libraries. Thus we are
694-
-- likely missing -DDEBUG, -DTHREADED_RTS, etc.
695-
-- One solution to this would be to turn all of these into `.h` files, and
696-
-- then have the `AutoApply.cmm` in `rts-c-sources-base` include them. This
697-
-- would mean they are included in the sublibraries which will in turn apply
698-
-- the sublibrary specific (c)flags.
699-
autogen-cmm-sources:
700-
AutoApply.cmm
701-
AutoApply_V16.cmm
702-
703-
if arch(x86_64)
704-
cmm-sources:
705-
Jumps_V32.cmm (-mavx2)
706-
Jumps_V64.cmm (-mavx512f)
693+
if !arch(javascript)
694+
-- FIXME: by virtue of being part of the rts main library, these do not get
695+
-- the flags (debug, threaded, ...) as the sub libraries. Thus we are
696+
-- likely missing -DDEBUG, -DTHREADED_RTS, etc.
697+
-- One solution to this would be to turn all of these into `.h` files, and
698+
-- then have the `AutoApply.cmm` in `rts-c-sources-base` include them. This
699+
-- would mean they are included in the sublibraries which will in turn apply
700+
-- the sublibrary specific (c)flags.
707701
autogen-cmm-sources:
708-
AutoApply_V32.cmm (-mavx2)
709-
AutoApply_V64.cmm (-mavx512f)
710-
else
711-
cmm-sources:
712-
Jumps_V32.cmm
713-
Jumps_V64.cmm
714-
autogen-cmm-sources:
715-
AutoApply_V32.cmm
716-
AutoApply_V64.cmm
702+
AutoApply.cmm
703+
AutoApply_V16.cmm
717704

718-
library ghcjs
705+
if arch(x86_64)
706+
cmm-sources:
707+
Jumps_V32.cmm (-mavx2)
708+
Jumps_V64.cmm (-mavx512f)
709+
autogen-cmm-sources:
710+
AutoApply_V32.cmm (-mavx2)
711+
AutoApply_V64.cmm (-mavx512f)
712+
else
713+
cmm-sources:
714+
Jumps_V32.cmm
715+
Jumps_V64.cmm
716+
autogen-cmm-sources:
717+
AutoApply_V32.cmm
718+
AutoApply_V64.cmm
719+
720+
common ghcjs
719721
import: rts-base-config
720722

721723
-- Keep original JS specific settings for the main library
@@ -760,15 +762,15 @@ library ghcjs
760762

761763
-- this is basiclly the "vanilla" version
762764
library nonthreaded-nodebug
763-
import: rts-base-config, rts-c-sources-base, rts-link-options, rts-global-build-flags
765+
if arch(javascript)
766+
import: ghcjs
767+
else
768+
import: rts-base-config, rts-c-sources-base, rts-link-options, rts-global-build-flags
769+
764770
visibility: public
765-
build-depends: rts
766771

767-
ghc-options: -ghcversion-file=include/ghcversion.h -optc-DFS_NAMESPACE=rts
768772
ghc-options: -optc-DRtsWay="v"
769773

770-
if arch(javascript)
771-
buildable: False
772774

773775
library threaded-nodebug
774776
import: rts-base-config, rts-c-sources-base, rts-link-options, rts-global-build-flags, rts-threaded-flags
@@ -820,4 +822,4 @@ library threaded-debug
820822
-- defined within the RTS! It is not immediately clear why this is needed. This
821823
-- dates back to c06e3f46d24ef69f3a3d794f5f604cb8c2a40cbc which mentions a build
822824
-- failure that it was suggested that this fix, but the precise reasoning is not
823-
-- explained.
825+
-- explained.

0 commit comments

Comments
 (0)