@@ -5,9 +5,11 @@ SHELL := bash
5
5
MAKEFLAGS += --warn-undefined-variables
6
6
MAKEFLAGS += --no-builtin-rules
7
7
8
+ all : stage1-boot
9
+
8
10
CABAL0 ?= cabal
9
11
CABAL ?= _stage0/bin/cabal
10
- GHC ?= ghc
12
+ GHC0 ?= ghc
11
13
12
14
define LIB =
13
15
BOLD_RED='\033[1;31m'
@@ -76,56 +78,65 @@ _stage1/lib/settings: _stage1/bin/ghc-toolchain-bin
76
78
77
79
stage1 : _stage1/bin/ghc _stage1/lib/settings
78
80
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
- # # for rts/configure
94
- # export DERIVE_CONSTANTS=$(abspath _stage1/bin/deriveConstants)
95
- # export GENAPPLY=$(abspath _stage1/bin/genapply)
96
- # log $(CABAL_INSTALL) --lib --package-env $(OUT) --project-file cabal.project.stage1-rts all
97
-
98
- stage1-rts : CABAL = _stage0/bin/cabal
99
- stage1-rts : CABAL_CONFIG_FLAGS += --with-compiler $(abspath _stage1/bin/ghc)
100
- stage1-rts : CABAL_CONFIG_FLAGS += --prefix $(OUT )
101
- stage1-rts : CABAL_CONFIG_FLAGS += --package-db $(OUT ) /lib/package.conf.d
102
- stage1-rts : OUT ?= $(abspath _stage1-rts)
103
- stage1-rts : _stage0/bin/cabal-main-simple _stage0/bin/cabal-main-configure _stage1/bin/ghc _stage1/bin/deriveConstants _stage1/bin/genapply rts/configure
81
+ _stage1-rts/lib/package.conf.d/rts-fs-1.0.0.0.conf : _stage0/bin/cabal-main-simple
104
82
@$(LIB )
105
- mkdir -p $(OUT ) /lib/package.conf.d
106
-
107
- # for rts/configure
108
- export DERIVE_CONSTANTS=$(abspath _stage1/bin/deriveConstants)
109
- export GENAPPLY=$(abspath _stage1/bin/genapply)
83
+ mkdir -p " $( @D) /lib/package.conf.d"
110
84
111
85
pushd rts-fs || exit
112
- log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-fs" $(CABAL_CONFIG_FLAGS)
86
+ log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-fs" $(CABAL_CONFIG_FLAGS) --ipid=$(notdir $(@:%.conf=%))
113
87
log ../_stage0/bin/cabal-main-simple build --builddir "$(OUT)/dist/rts-fs"
114
88
log ../_stage0/bin/cabal-main-simple install --builddir "$(OUT)/dist/rts-fs"
115
89
popd
116
90
91
+ _stage1-rts/lib/package.conf.d/rts-headers-1.0.0.0.conf : _stage0/bin/cabal-main-simple
92
+ @$(LIB )
93
+ mkdir -p " $( @D) "
94
+
117
95
pushd rts-headers || exit
118
- log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-headers" $(CABAL_CONFIG_FLAGS)
96
+ log ../_stage0/bin/cabal-main-simple configure --builddir "$(OUT)/dist/rts-headers" $(CABAL_CONFIG_FLAGS) --ipid=$(notdir $(@:%.conf=%))
119
97
log ../_stage0/bin/cabal-main-simple build --builddir "$(OUT)/dist/rts-headers"
120
98
log ../_stage0/bin/cabal-main-simple install --builddir "$(OUT)/dist/rts-headers"
121
99
popd
122
100
101
+ # NOTE: The bootstrap is particularly annoying in this step.
102
+ #
103
+ # rts has a custom config so we need a Cabal to compile Setup.hs, but we cannot
104
+ # use the new compiler (not even stage1) for this because we do not have the rts
105
+ # yet (as we are just preparing to build it).
106
+ #
107
+ # We cut the know by using the version of Cabal we had built with the stage0 compiler.
108
+ # NOTE: the requirement _stage0/bin/cabal is representative of the fact that we had built the library
109
+ #
110
+
111
+ # _stage0/bin/cabal as evidence that we have build cabal
112
+ _stage1-rts/dist/rts/Setup : .EXTRA_PREREQS=_stage0/bin/cabal
113
+ _stage1-rts/dist/rts/Setup : rts/Setup.hs
114
+ @$(LIB )
115
+ # FIXME I am using the store as a package db, its path is not quite fixed as it
116
+ # relies on the bootstrap compiler id
117
+ mkdir -p $(@D )
118
+ log $(GHC0 ) -clear-package-db -global-package-db -package-db _stage0/store/* /package.db -o $@ $<
119
+
120
+ _stage1-rts/lib/package.conf.d/rts-1.0.0.0.conf : _stage1/bin/ghc rts/configure _stage1-rts/lib/package.conf.d/rts-fs-1.0.0.0.conf _stage1-rts/lib/package.conf.d/rts-headers-1.0.0.0.conf _stage1-rts/dist/rts/Setup _stage1/bin/deriveConstants _stage1/bin/genapply
121
+ @$(LIB )
122
+ mkdir -p " $( @D) /lib/package.conf.d"
123
+
124
+ # for rts setup to find derivedConstants and genApply
125
+ export PATH=$(abspath _stage1/bin):$$PATH
126
+
123
127
pushd rts || exit
124
- log ../_stage0/bin/cabal-main-configure configure --builddir "$(OUT)/dist/rts" $(CABAL_CONFIG_FLAGS)
125
- log ../_stage0/bin/cabal-main-configure build --builddir "$(OUT)/dist/rts"
126
- log ../_stage0/bin/cabal-main-configure install --builddir "$(OUT)/dist/rts"
128
+ log ../_stage1-rts/dist/rts/Setup configure --builddir "$(OUT)/dist/rts" $(CABAL_CONFIG_FLAGS) --ipid=$(notdir $(@:%.conf=%) )
129
+ log ../_stage1-rts/dist/rts/Setup build --builddir "$(OUT)/dist/rts"
130
+ log ../_stage1-rts/dist/rts/Setup install --builddir "$(OUT)/dist/rts"
127
131
popd
128
132
133
+ stage1-rts : GHC = _stage1/bin/ghc
134
+ stage1-rts : CABAL_CONFIG_FLAGS += -v --with-compiler $(abspath _stage1/bin/ghc)
135
+ stage1-rts : CABAL_CONFIG_FLAGS += --prefix $(OUT )
136
+ stage1-rts : CABAL_CONFIG_FLAGS += --package-db $(OUT ) /lib/package.conf.d
137
+ stage1-rts : OUT ?= $(abspath _stage1-rts)
138
+ stage1-rts : $(addprefix _stage1-rts/lib/package.conf.d/,rts-1.0.0.0.conf rts-fs-1.0.0.0.conf rts-headers-1.0.0.0.conf)
139
+
129
140
_stage1-boot/src/compiler/GHC/Builtin/primops.txt : compiler/GHC/Builtin/primops.txt.pp
130
141
@$(LIB )
131
142
mkdir -p $(@D )
@@ -147,12 +158,13 @@ _stage1-boot/src/ghc-internal/src/GHC/Internal/PrimopWrappers.hs: _stage1-boot/s
147
158
mkdir -p $(@D )
148
159
log _stage1/bin/genprimopcode --make-haskell-wrappers < $< > $@
149
160
150
- _stage1-boot/src/ghc-internal/.stamp : _stage1-boot/src/ghc-internal/ghc-internal.cabal
151
- _stage1-boot/src/ghc-internal/.stamp : _stage1-boot/src/ghc-internal/src/GHC/Internal/Prim.hs
152
- _stage1-boot/src/ghc-internal/.stamp : _stage1-boot/src/ghc-internal/src/GHC/Internal/PrimopWrappers.hs
161
+ _stage1-boot/src/ghc-internal/.ready : _stage1-boot/src/ghc-internal/ghc-internal.cabal
162
+ _stage1-boot/src/ghc-internal/.ready : _stage1-boot/src/ghc-internal/src/GHC/Internal/Prim.hs
163
+ _stage1-boot/src/ghc-internal/.ready : _stage1-boot/src/ghc-internal/src/GHC/Internal/PrimopWrappers.hs
164
+ _stage1-boot/src/ghc-internal/.ready : _stage1-boot/src/ghc-internal/configure
153
165
154
166
# targets
155
- STAGE1_BOOT_TARGETS = rts ghc-internal ghc-experimental ghc-compact base stm system-cxx-std-lib
167
+ STAGE1_BOOT_TARGETS = ghc-internal ghc-experimental ghc-compact base stm system-cxx-std-lib
156
168
# shallow compat packages over ghc-internal
157
169
STAGE1_BOOT_TARGETS += ghc-prim ghc-bignum integer-gmp template-haskell
158
170
# target dependencies
@@ -167,10 +179,9 @@ STAGE1_BOOT_TARGETS += ghc-boot ghc-heap ghc-platform ghc-toolchain ghci ghc
167
179
stage1-boot : CABAL = _stage0/bin/cabal
168
180
stage1-boot : GHC = $(abspath _stage1/bin/ghc)
169
181
stage1-boot : OUT ?= $(abspath _stage1-boot)
170
- stage1-boot : _stage0/bin/cabal _stage1/bin/ghc _stage1-boot/src/ghc-internal/.stamp _stage1-boot/src/ghc-internal/configure
182
+ stage1-boot : _stage0/bin/cabal _stage1/bin/ghc _stage1-boot/src/ghc-internal/.ready stage1-rts
171
183
@$(LIB )
172
184
# for rts/configure
173
185
export DERIVE_CONSTANTS=$(abspath _stage1/bin/deriveConstants)
174
186
export GENAPPLY=$(abspath _stage1/bin/genapply)
175
- log $(CABAL_INSTALL ) --lib --package-env $(OUT ) --project-file cabal.project.stage1-boot $(STAGE1_BOOT_TARGETS )
176
-
187
+ log $(CABAL_INSTALL ) --lib --package-db=$(abspath _stage1-rts/lib/package.conf.d) --package-env $(OUT ) --project-file cabal.project.stage1-boot Cabal
0 commit comments