@@ -25,19 +25,22 @@ endef
25
25
26
26
CABAL_FLAGS += --store-dir $(OUT ) /store --logs-dir $(OUT ) /logs
27
27
28
- CABAL_INSTALL_FLAGS += --builddir $(OUT ) /build
29
- CABAL_INSTALL_FLAGS += --with-compiler $(GHC )
28
+ CABAL_BUILD_FLAGS += --builddir $(OUT ) /build
29
+ CABAL_BUILD_FLAGS += --with-compiler $(GHC )
30
+
31
+ CABAL_BUILD = $(CABAL ) $(CABAL_FLAGS ) build $(CABAL_BUILD_FLAGS )
32
+
30
33
CABAL_INSTALL_FLAGS += --installdir $(OUT ) /bin
31
34
CABAL_INSTALL_FLAGS += --overwrite-policy=always
32
35
# If we copy the executables then ghc will recognise _stage1 as topdir (rather than a path in the store)
33
36
CABAL_INSTALL_FLAGS += --install-method=copy
34
37
35
- CABAL_INSTALL = $(CABAL ) $(CABAL_FLAGS ) install $(CABAL_INSTALL_FLAGS )
38
+ CABAL_INSTALL = $(CABAL ) $(CABAL_FLAGS ) install $(CABAL_BUILD_FLAGS ) $( CABAL_INSTALL_FLAGS )
36
39
37
40
cabal : _stage0/bin/cabal
38
41
39
42
CABAL_EXE = cabal cabal-main-simple cabal-main-configure
40
- CABAL_BIN : = $(addprefix _stage0/bin/,$(CABAL_EXE ) )
43
+ CABAL_BIN = $(addprefix _stage0/bin/,$(CABAL_EXE ) )
41
44
42
45
$(CABAL_BIN ) & : OUT ?= $(abspath _stage0)
43
46
$(CABAL_BIN ) & : CABAL=$(CABAL0 )
@@ -47,7 +50,7 @@ $(CABAL_BIN) &:
47
50
log $(CABAL_INSTALL ) --project-dir libraries/Cabal --project-file cabal.release.project $(addprefix exe:,$(CABAL_EXE ) )
48
51
49
52
STAGE1_EXE = ghc ghc-toolchain-bin deriveConstants genprimopcode genapply
50
- STAGE1_BIN : = $(addprefix _stage1/bin/,$(STAGE1_EXE ) )
53
+ STAGE1_BIN = $(addprefix _stage1/bin/,$(STAGE1_EXE ) )
51
54
52
55
$(STAGE1_BIN ) & : OUT ?= $(abspath _stage1)
53
56
$(STAGE1_BIN ) & : $(CABAL )
@@ -73,35 +76,94 @@ _stage1/lib/settings: _stage1/bin/ghc-toolchain-bin
73
76
74
77
stage1 : _stage1/bin/ghc _stage1/lib/settings
75
78
79
+ #
80
+ # TODO: We cannot build the rts with cabal-install because we are passing
81
+ # to deriveConstants the headers in rts-headers via a relative path.
82
+ # cabal-install's install command makes a source distribution before building
83
+ # and this breaks the relative path. The solution is to move the call to
84
+ # derivedConstants into Setup.hs where we have access to the installed
85
+ # packagedb. I had a version of this then it looked too complex and I moved back
86
+ # to configure.ac.
87
+ #
88
+ # stage1-rts: CABAL = _stage0/bin/cabal
89
+ # stage1-rts: GHC = $(abspath _stage1/bin/ghc)
90
+ # stage1-rts: OUT ?= $(abspath _stage1-rts)
91
+ # stage1-rts: _stage0/bin/cabal _stage1/bin/ghc _stage1/bin/deriveConstants _stage1/bin/genapply rts/configure
92
+ # @$(LIB)
93
+ # export PATH=$(abspath _stage1/bin):$$PATH
94
+ # log $(CABAL_INSTALL) --lib --package-env $(OUT) --project-file cabal.project.stage1-rts all
95
+
76
96
stage1-rts : CABAL = _stage0/bin/cabal
97
+ stage1-rts : CABAL_CONFIG_FLAGS += --with-compiler $(abspath _stage1/bin/ghc)
98
+ stage1-rts : CABAL_CONFIG_FLAGS += --prefix $(OUT )
99
+ stage1-rts : CABAL_CONFIG_FLAGS += --package-db $(OUT ) /lib/package.conf.d
77
100
stage1-rts : OUT ?= $(abspath _stage1-rts)
78
101
stage1-rts : _stage0/bin/cabal-main-simple _stage0/bin/cabal-main-configure _stage1/bin/ghc _stage1/bin/deriveConstants _stage1/bin/genapply rts/configure
79
102
@$(LIB )
80
-
81
- flags=( \
82
- --with-compiler $(abspath _stage1/bin/ghc) \
83
- --prefix "$(OUT)" \
84
- --package-db "$(OUT)/lib/package.conf.d" \
85
- )
86
103
mkdir -p $(OUT ) /lib/package.conf.d
87
104
88
105
pushd rts-fs || exit
89
- log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-fs" "$${flags[@]}"
106
+ log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-fs" $(CABAL_CONFIG_FLAGS)
90
107
log ../_stage0/bin/cabal-main-simple build --builddir "$(OUT)/dist/rts-fs"
91
108
log ../_stage0/bin/cabal-main-simple install --builddir "$(OUT)/dist/rts-fs"
92
109
popd
93
110
94
111
pushd rts-headers || exit
95
- log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-headers" "$${flags[@]}"
112
+ log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-headers" $(CABAL_CONFIG_FLAGS)
96
113
log ../_stage0/bin/cabal-main-simple build --builddir "$(OUT)/dist/rts-headers"
97
114
log ../_stage0/bin/cabal-main-simple install --builddir "$(OUT)/dist/rts-headers"
98
115
popd
99
116
100
117
export DERIVE_CONSTANTS=$(abspath _stage1/bin/deriveConstants)
101
118
export GENAPPLY=$(abspath _stage1/bin/genapply)
102
119
pushd rts || exit
103
- log ../_stage0/bin/cabal-main-configure configure --builddir "$(OUT)/dist/rts" -v "$${flags[@]}"
104
- log ../_stage0/bin/cabal-main-configure build --builddir "$(OUT)/dist/rts" -v
105
- log ../_stage0/bin/cabal-main-configure install --builddir "$(OUT)/dist/rts" -v
120
+ log ../_stage0/bin/cabal-main-configure configure --builddir "$(OUT)/dist/rts" $(CABAL_CONFIG_FLAGS)
121
+ log ../_stage0/bin/cabal-main-configure build --builddir "$(OUT)/dist/rts"
122
+ log ../_stage0/bin/cabal-main-configure install --builddir "$(OUT)/dist/rts"
106
123
popd
107
124
125
+ _stage1-boot/src/compiler/GHC/Builtin/primops.txt : compiler/GHC/Builtin/primops.txt.pp
126
+ @$(LIB )
127
+ mkdir -p $(@D )
128
+ log cc -E -undef -traditional -P -x c $< > $@
129
+
130
+ _stage1-boot/src/ghc-internal/ghc-internal.cabal :
131
+ @$(LIB )
132
+ rm -rf $(@D )
133
+ mkdir -p $(@D )
134
+ cp -r libraries/ghc-internal/* $(@D )
135
+
136
+ _stage1-boot/src/ghc-internal/src/GHC/Internal/Prim.hs : _stage1-boot/src/compiler/GHC/Builtin/primops.txt | _stage1-boot/src/ghc-internal/ghc-internal.cabal
137
+ @$(LIB )
138
+ mkdir -p $(@D )
139
+ log _stage1/bin/genprimopcode --make-haskell-source < $< > $@
140
+
141
+ _stage1-boot/src/ghc-internal/src/GHC/Internal/PrimopWrappers.hs : _stage1-boot/src/compiler/GHC/Builtin/primops.txt | _stage1-boot/src/ghc-internal/ghc-internal.cabal
142
+ @$(LIB )
143
+ mkdir -p $(@D )
144
+ log _stage1/bin/genprimopcode --make-haskell-wrappers < $< > $@
145
+
146
+ _stage1-boot/src/ghc-internal/.stamp : _stage1-boot/src/ghc-internal/ghc-internal.cabal
147
+ _stage1-boot/src/ghc-internal/.stamp : _stage1-boot/src/ghc-internal/src/GHC/Internal/Prim.hs
148
+ _stage1-boot/src/ghc-internal/.stamp : _stage1-boot/src/ghc-internal/src/GHC/Internal/PrimopWrappers.hs
149
+
150
+ # targets
151
+ STAGE1_BOOT_TARGETS = rts ghc-internal ghc-experimental ghc-compact base stm system-cxx-std-lib
152
+ # shallow compat packages over ghc-internal
153
+ STAGE1_BOOT_TARGETS += ghc-prim ghc-bignum integer-gmp template-haskell
154
+ # target dependencies
155
+ STAGE1_BOOT_TARGETS += ghc-boot-th pretty
156
+ # other boot libraries used by tests
157
+ STAGE1_BOOT_TARGETS += array binary bytestring Cabal Cabal-syntax containers deepseq directory exceptions file-io filepath hpc mtl os-string parsec process semaphore-compat text time transformers
158
+ STAGE1_BOOT_TARGETS += unix
159
+ # FIXME: we'd have to install Win32 for Windows target. Maybe --libs could install dependencies too..
160
+ # ghc related
161
+ STAGE1_BOOT_TARGETS += ghc-boot ghc-heap ghc-platform ghc-toolchain ghci ghc
162
+
163
+ stage1-boot : CABAL = _stage0/bin/cabal
164
+ stage1-boot : GHC = $(abspath _stage1/bin/ghc)
165
+ stage1-boot : OUT ?= $(abspath _stage1-boot)
166
+ stage1-boot : _stage0/bin/cabal _stage1/bin/ghc _stage1-boot/src/ghc-internal/.stamp _stage1-boot/src/ghc-internal/configure
167
+ @$(LIB )
168
+ log $(CABAL_INSTALL ) --lib --package-env $(OUT ) --project-file cabal.project.stage1-boot $(STAGE1_BOOT_TARGETS )
169
+
0 commit comments