Remove TcMType from compiler_stage2_dll0_MODULES
[ghc.git] / compiler / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009-2012 The University of Glasgow
4 #
5 # This file is part of the GHC build system.
6 #
7 # To understand how the build system works and how to modify it, see
8 # http://ghc.haskell.org/trac/ghc/wiki/Building/Architecture
9 # http://ghc.haskell.org/trac/ghc/wiki/Building/Modifying
10 #
11 # -----------------------------------------------------------------------------
12
13 # -----------------------------------------------------------------------------
14 # Create compiler configuration
15 #
16 # The 'echo' commands simply spit the values of various make variables
17 # into Config.hs, whence they can be compiled and used by GHC itself
18
19 # This is just to avoid generating a warning when generating deps
20 # involving RtsFlags.h
21 compiler_stage1_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
22 compiler_stage2_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
23 compiler_stage3_MKDEPENDC_OPTS = -DMAKING_GHC_BUILD_SYSTEM_DEPENDENCIES
24
25 compiler_stage1_C_FILES_NODEPS = compiler/parser/cutils.c
26
27 # This package doesn't pass the Cabal checks because include-dirs
28 # points outside the source directory. This isn't a real problem, so
29 # we just skip the check.
30 compiler_NO_CHECK = YES
31
32 ifneq "$(BINDIST)" "YES"
33 compiler/stage1/package-data.mk : compiler/stage1/build/Config.hs
34 compiler/stage2/package-data.mk : compiler/stage2/build/Config.hs
35 compiler/stage3/package-data.mk : compiler/stage3/build/Config.hs
36
37 compiler/stage1/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
38 compiler/stage2/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
39 compiler/stage3/build/PlatformConstants.o: $(includes_GHCCONSTANTS_HASKELL_TYPE)
40 compiler/stage1/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
41 compiler/stage2/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
42 compiler/stage3/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
43 compiler/stage1/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
44 compiler/stage2/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
45 compiler/stage3/build/DynFlags.o: $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
46 endif
47
48 compiler/stage%/build/Config.hs : mk/config.mk mk/project.mk | $$(dir $$@)/.
49 $(call removeFiles,$@)
50 @echo 'Creating $@ ... '
51 @echo '{-# LANGUAGE CPP #-}' >> $@
52 @echo 'module Config where' >> $@
53 @echo >> $@
54 @echo '#include "ghc_boot_platform.h"' >> $@
55 @echo >> $@
56 @echo 'data IntegerLibrary = IntegerGMP' >> $@
57 @echo ' | IntegerGMP2' >> $@
58 @echo ' | IntegerSimple' >> $@
59 @echo ' deriving Eq' >> $@
60 @echo >> $@
61 @echo 'cBuildPlatformString :: String' >> $@
62 @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
63 @echo 'cHostPlatformString :: String' >> $@
64 @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
65 @echo 'cTargetPlatformString :: String' >> $@
66 @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
67 @echo >> $@
68 @echo 'cProjectName :: String' >> $@
69 @echo 'cProjectName = "$(ProjectName)"' >> $@
70 @echo 'cProjectVersion :: String' >> $@
71 @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
72 @echo 'cProjectVersionInt :: String' >> $@
73 @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
74 @echo 'cProjectPatchLevel :: String' >> $@
75 @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
76 @echo 'cProjectPatchLevel1 :: String' >> $@
77 @echo 'cProjectPatchLevel1 = "$(ProjectPatchLevel1)"' >> $@
78 @echo 'cProjectPatchLevel2 :: String' >> $@
79 @echo 'cProjectPatchLevel2 = "$(ProjectPatchLevel2)"' >> $@
80 @echo 'cBooterVersion :: String' >> $@
81 @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
82 @echo 'cStage :: String' >> $@
83 @echo 'cStage = show (STAGE :: Int)' >> $@
84 @echo 'cIntegerLibrary :: String' >> $@
85 @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
86 @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
87 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
88 @echo 'cIntegerLibraryType = IntegerGMP' >> $@
89 else ifeq "$(INTEGER_LIBRARY)" "integer-gmp2"
90 @echo 'cIntegerLibraryType = IntegerGMP2' >> $@
91 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
92 @echo 'cIntegerLibraryType = IntegerSimple' >> $@
93 else ifneq "$(CLEANING)" "YES"
94 $(error Unknown integer library)
95 endif
96 @echo 'cSupportsSplitObjs :: String' >> $@
97 @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
98 @echo 'cGhcWithInterpreter :: String' >> $@
99 @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
100 @echo 'cGhcWithNativeCodeGen :: String' >> $@
101 @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
102 @echo 'cGhcWithSMP :: String' >> $@
103 @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
104 @echo 'cGhcRTSWays :: String' >> $@
105 @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
106 @echo 'cGhcEnableTablesNextToCode :: String' >> $@
107 @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
108 @echo 'cLeadingUnderscore :: String' >> $@
109 @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
110 @echo 'cGHC_UNLIT_PGM :: String' >> $@
111 @echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
112 @echo 'cGHC_SPLIT_PGM :: String' >> $@
113 @echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
114 @echo 'cLibFFI :: Bool' >> $@
115 ifeq "$(UseLibFFIForAdjustors)" "YES"
116 @echo 'cLibFFI = True' >> $@
117 else
118 @echo 'cLibFFI = False' >> $@
119 endif
120 # Note that GhcThreaded just reflects the Makefile variable setting.
121 # In particular, the stage1 compiler is never actually compiled with
122 # -threaded, but it will nevertheless have cGhcThreaded = True.
123 # The "+RTS --info" output will show what RTS GHC is really using.
124 @echo 'cGhcThreaded :: Bool' >> $@
125 ifeq "$(GhcThreaded)" "YES"
126 @echo 'cGhcThreaded = True' >> $@
127 else
128 @echo 'cGhcThreaded = False' >> $@
129 endif
130 @echo 'cGhcDebugged :: Bool' >> $@
131 ifeq "$(GhcDebugged)" "YES"
132 @echo 'cGhcDebugged = True' >> $@
133 else
134 @echo 'cGhcDebugged = False' >> $@
135 endif
136 @echo done.
137
138 # -----------------------------------------------------------------------------
139 # Create platform includes
140
141 # Here we generate a little header file containing CPP symbols that GHC
142 # uses to determine which platform it is building on/for. The platforms
143 # can differ between stage1 and stage2 if we're cross-compiling, so we
144 # need one of these header files per stage.
145
146 PLATFORM_H = ghc_boot_platform.h
147
148 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
149 $(call removeFiles,$@)
150 @echo "Creating $@..."
151 @echo "#ifndef __PLATFORM_H__" >> $@
152 @echo "#define __PLATFORM_H__" >> $@
153 @echo >> $@
154 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
155 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
156 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
157 @echo >> $@
158 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
159 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
160 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
161 @echo >> $@
162 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
163 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
164 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
165 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
166 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
167 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
168 @echo >> $@
169 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
170 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
171 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
172 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
173 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
174 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
175 ifeq "$(TargetOS_CPP)" "irix"
176 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
177 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
178 @echo "#endif" >> $@
179 endif
180 @echo >> $@
181 @echo "#define $(BuildVendor_CPP)_BUILD_VENDOR 1" >> $@
182 @echo "#define $(HostVendor_CPP)_HOST_VENDOR 1" >> $@
183 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
184 @echo "#define BUILD_VENDOR \"$(BuildVendor_CPP)\"" >> $@
185 @echo "#define HOST_VENDOR \"$(HostVendor_CPP)\"" >> $@
186 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
187 @echo >> $@
188 @echo "#endif /* __PLATFORM_H__ */" >> $@
189 @echo "Done."
190
191 # For stage2 and above, the BUILD platform is the HOST of stage1, and
192 # the HOST platform is the TARGET of stage1. The TARGET remains the same
193 # (stage1 is the cross-compiler, not stage2).
194 compiler/stage2/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
195 $(call removeFiles,$@)
196 @echo "Creating $@..."
197 @echo "#ifndef __PLATFORM_H__" >> $@
198 @echo "#define __PLATFORM_H__" >> $@
199 @echo >> $@
200 @echo "#define BuildPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
201 @echo "#define HostPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
202 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
203 @echo >> $@
204 @echo "#define $(HostPlatform_CPP)_BUILD 1" >> $@
205 @echo "#define $(TargetPlatform_CPP)_HOST 1" >> $@
206 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
207 @echo >> $@
208 @echo "#define $(HostArch_CPP)_BUILD_ARCH 1" >> $@
209 @echo "#define $(TargetArch_CPP)_HOST_ARCH 1" >> $@
210 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
211 @echo "#define BUILD_ARCH \"$(HostArch_CPP)\"" >> $@
212 @echo "#define HOST_ARCH \"$(TargetArch_CPP)\"" >> $@
213 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
214 @echo >> $@
215 @echo "#define $(HostOS_CPP)_BUILD_OS 1" >> $@
216 @echo "#define $(TargetOS_CPP)_HOST_OS 1" >> $@
217 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
218 @echo "#define BUILD_OS \"$(HostOS_CPP)\"" >> $@
219 @echo "#define HOST_OS \"$(TargetOS_CPP)\"" >> $@
220 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
221 ifeq "$(TargetOS_CPP)" "irix"
222 @echo "#ifndef $(IRIX_MAJOR)_TARGET_OS" >> $@
223 @echo "#define $(IRIX_MAJOR)_TARGET_OS 1" >> $@
224 @echo "#endif" >> $@
225 endif
226 @echo >> $@
227 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
228 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
229 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
230 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
231 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
232 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
233 @echo >> $@
234 @echo "#endif /* __PLATFORM_H__ */" >> $@
235 @echo "Done."
236
237 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
238 "$(CP)" $< $@
239
240 # ----------------------------------------------------------------------------
241 # Generate supporting stuff for prelude/PrimOp.lhs
242 # from prelude/primops.txt
243
244 PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
245 primop-tag.hs-incl \
246 primop-list.hs-incl \
247 primop-has-side-effects.hs-incl \
248 primop-out-of-line.hs-incl \
249 primop-commutable.hs-incl \
250 primop-code-size.hs-incl \
251 primop-can-fail.hs-incl \
252 primop-strictness.hs-incl \
253 primop-fixity.hs-incl \
254 primop-primop-info.hs-incl \
255 primop-vector-uniques.hs-incl \
256 primop-vector-tys.hs-incl \
257 primop-vector-tys-exports.hs-incl \
258 primop-vector-tycons.hs-incl
259
260 PRIMOP_BITS_STAGE1 = $(addprefix compiler/stage1/build/,$(PRIMOP_BITS_NAMES))
261 PRIMOP_BITS_STAGE2 = $(addprefix compiler/stage2/build/,$(PRIMOP_BITS_NAMES))
262 PRIMOP_BITS_STAGE3 = $(addprefix compiler/stage3/build/,$(PRIMOP_BITS_NAMES))
263
264 compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
265 compiler_CPP_OPTS += ${GhcCppOpts}
266
267 define preprocessCompilerFiles
268 # $0 = stage
269 compiler/stage$1/build/Parser.y: compiler/parser/Parser.y.pp
270 $$(CPP) -P $$(compiler_CPP_OPTS) -x c $$< | grep -v '^#pragma GCC' > $$@
271
272 compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
273 $$(CPP) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
274
275 compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
276 "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
277 compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
278 "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
279 compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
280 "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
281 compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
282 "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
283 compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
284 "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
285 compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
286 "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
287 compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
288 "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
289 compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
290 "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
291 compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
292 "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
293 compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
294 "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
295 compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
296 "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
297 compiler/stage$1/build/primop-vector-uniques.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
298 "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
299 compiler/stage$1/build/primop-vector-tys.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
300 "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
301 compiler/stage$1/build/primop-vector-tys-exports.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
302 "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
303 compiler/stage$1/build/primop-vector-tycons.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
304 "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
305
306 # Usages aren't used any more; but the generator
307 # can still generate them if we want them back
308 compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
309 "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
310
311 endef
312
313 $(eval $(call preprocessCompilerFiles,1))
314 $(eval $(call preprocessCompilerFiles,2))
315 $(eval $(call preprocessCompilerFiles,3))
316
317 # -----------------------------------------------------------------------------
318 # Configuration
319
320 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
321 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
322 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
323
324 ifeq "$(GhcThreaded)" "YES"
325 # We pass THREADED_RTS to the stage2 C files so that cbits/genSym.c will bring
326 # the threaded version of atomic_inc() into scope.
327 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS
328 endif
329
330 ifeq "$(GhcWithNativeCodeGen)" "YES"
331 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
332 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
333 endif
334
335 ifeq "$(GhcWithInterpreter)" "YES"
336 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
337
338 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
339 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
340 # or not?
341 # XXX This should logically be a CPP option, but there doesn't seem to
342 # be a flag for that
343 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
344 endif
345
346 # Should the debugger commands be enabled?
347 ifeq "$(GhciWithDebugger)" "YES"
348 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
349 endif
350
351 endif
352
353 ifeq "$(TargetOS_CPP)" "openbsd"
354 compiler_CONFIGURE_OPTS += --ld-options=-E
355 endif
356
357 ifeq "$(GhcUnregisterised)" "NO"
358 else
359 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
360 endif
361
362 ifneq "$(GhcWithSMP)" "YES"
363 compiler_CONFIGURE_OPTS += --ghc-option=-DNOSMP
364 compiler_CONFIGURE_OPTS += --ghc-option=-optc-DNOSMP
365 endif
366
367 # Careful optimisation of the parser: we don't want to throw everything
368 # at it, because that takes too long and doesn't buy much, but we do want
369 # to inline certain key external functions, so we instruct GHC not to
370 # throw away inlinings as it would normally do in -O0 mode.
371 compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas
372 # If we're bootstrapping the compiler during stage2, or we're being
373 # built by a GHC whose version is > 7.8, we need -fcmm-sink to be
374 # passed to the compiler. This is required on x86 to avoid the
375 # register allocator running out of stack slots when compiling this
376 # module with -fPIC -dynamic.
377 # See #8182 for all the details
378 ifeq "$(CMM_SINK_BOOTSTRAP_IS_NEEDED)" "YES"
379 compiler/stage1/build/Parser_HC_OPTS += -fcmm-sink
380 endif
381 # We also pass -fcmm-sink to every stage != 1
382 compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
383 compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
384
385
386 ifeq "$(GhcProfiled)" "YES"
387 # If we're profiling GHC then we want SCCs. However, adding -auto-all
388 # everywhere tends to give a hard-to-read profile, and adds lots of
389 # overhead. A better approach is to proceed top-down; identify the
390 # parts of the compiler of interest, and then add further cost centres
391 # as necessary. Turn on -auto-all for individual modules like this:
392
393 # compiler/main/DriverPipeline_HC_OPTS += -auto-all
394 compiler/main/GhcMake_HC_OPTS += -auto-all
395 compiler/main/GHC_HC_OPTS += -auto-all
396
397 # or alternatively add {-# OPTIONS_GHC -auto-all #-} to the top of
398 # modules you're interested in.
399
400 # We seem to still build the vanilla libraries even if we say
401 # --disable-library-vanilla, but installation then fails, as Cabal
402 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
403 # their absence when we register the package. So for now, we just
404 # leave the vanilla libraries enabled.
405 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
406 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
407 endif
408
409 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
410
411 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
412 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
413 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
414 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
415
416 compiler/stage1/package-data.mk : compiler/ghc.mk
417 compiler/stage2/package-data.mk : compiler/ghc.mk
418 compiler/stage3/package-data.mk : compiler/ghc.mk
419
420 # -----------------------------------------------------------------------------
421 # And build the package
422
423 compiler_PACKAGE = ghc
424
425 # Note [fiddle-stage1-version]
426 # The version of the GHC package changes every day, since the
427 # patchlevel is the current date. We don't want to force
428 # recompilation of the entire compiler when this happens, so for stage
429 # 1 we omit the patchlevel from the version number. For stage 2 we
430 # have to include the patchlevel since this is the package we install,
431 # however.
432 #
433 # Note: we also have to tweak the version number of the package itself
434 # when it gets registered; see Note [munge-stage1-package-config]
435 # below.
436 # The ProjectPatchLevel > 20000000 iff it's a date. If it's e.g. 6.12.1
437 # then we don't want to remove it
438 ifneq "$(CLEANING)" "YES"
439 ifeq "$(shell [ $(ProjectPatchLevel) -gt 20000000 ] && echo YES)" "YES"
440 compiler_stage1_VERSION_MUNGED = YES
441 endif
442 endif
443
444 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
445 compiler_stage1_MUNGED_VERSION = $(subst .$(ProjectPatchLevel),,$(ProjectVersion))
446 define compiler_PACKAGE_MAGIC
447 compiler_stage1_VERSION = $(compiler_stage1_MUNGED_VERSION)
448 compiler_stage1_PACKAGE_KEY = $(subst .$(ProjectPatchLevel),,$(compiler_stage1_PACKAGE_KEY))
449 endef
450
451 # NB: the PACKAGE_KEY munging has no effect for new-style package keys
452 # (which indeed, have nothing version like in them, but are important for
453 # old-style package keys which do.) The subst operation is idempotent, so
454 # as long as we do it at least once we should be good.
455
456 # Don't register the non-munged package
457 compiler_stage1_REGISTER_PACKAGE = NO
458
459 endif
460
461 # Don't do splitting for the GHC package, it takes too long and
462 # there's not much benefit.
463 compiler_stage1_SplitObjs = NO
464 compiler_stage2_SplitObjs = NO
465 compiler_stage3_SplitObjs = NO
466
467 # There are too many symbols in the ghc package for a Windows DLL.
468 # We therefore need to split some of the modules off into a separate
469 # DLL. This clump are the modules reachable from DynFlags:
470 compiler_stage2_dll0_START_MODULE = DynFlags
471 compiler_stage2_dll0_MODULES = \
472 Annotations \
473 Avail \
474 Bag \
475 BasicTypes \
476 BinIface \
477 Binary \
478 BooleanFormula \
479 BreakArray \
480 BufWrite \
481 BuildTyCl \
482 Class \
483 CmdLineParser \
484 CmmType \
485 CoAxiom \
486 ConLike \
487 Coercion \
488 Config \
489 Constants \
490 CoreArity \
491 CoreFVs \
492 CoreLint \
493 CoreSubst \
494 CoreSyn \
495 CoreTidy \
496 CoreUnfold \
497 CoreUtils \
498 CostCentre \
499 DataCon \
500 Demand \
501 Digraph \
502 DriverPhases \
503 DsMonad \
504 DynFlags \
505 Encoding \
506 ErrUtils \
507 Exception \
508 ExtsCompat46 \
509 FamInstEnv \
510 FastFunctions \
511 FastMutInt \
512 FastString \
513 FastTypes \
514 Finder \
515 Fingerprint \
516 FiniteMap \
517 ForeignCall \
518 Hooks \
519 HsBinds \
520 HsDecls \
521 HsDoc \
522 HsExpr \
523 HsImpExp \
524 HsLit \
525 PlaceHolder \
526 HsPat \
527 HsSyn \
528 HsTypes \
529 HsUtils \
530 HscTypes \
531 IOEnv \
532 Id \
533 IdInfo \
534 IfaceEnv \
535 IfaceSyn \
536 IfaceType \
537 InstEnv \
538 Kind \
539 ListSetOps \
540 Literal \
541 LoadIface \
542 Maybes \
543 MkCore \
544 MkId \
545 Module \
546 MonadUtils \
547 Name \
548 NameEnv \
549 NameSet \
550 OccName \
551 OccurAnal \
552 OptCoercion \
553 OrdList \
554 Outputable \
555 PackageConfig \
556 Packages \
557 Pair \
558 Panic \
559 PatSyn \
560 PipelineMonad \
561 Platform \
562 PlatformConstants \
563 PprCore \
564 PrelInfo \
565 PrelNames \
566 PrelRules \
567 Pretty \
568 PrimOp \
569 RdrName \
570 Rules \
571 Serialized \
572 SrcLoc \
573 StaticFlags \
574 StringBuffer \
575 TcEvidence \
576 TcIface \
577 TcRnMonad \
578 TcRnTypes \
579 TcType \
580 TcTypeNats \
581 TrieMap \
582 TyCon \
583 Type \
584 TypeRep \
585 TysPrim \
586 TysWiredIn \
587 Unify \
588 UniqFM \
589 UniqSet \
590 UniqSupply \
591 Unique \
592 Util \
593 Var \
594 VarEnv \
595 VarSet
596
597 ifeq "$(GhcWithInterpreter)" "YES"
598 # These files are reacheable from DynFlags
599 # only by GHCi-enabled code (see #9552)
600 compiler_stage2_dll0_MODULES += \
601 Bitmap \
602 BlockId \
603 ByteCodeAsm \
604 ByteCodeInstr \
605 ByteCodeItbls \
606 CLabel \
607 Cmm \
608 CmmCallConv \
609 CmmExpr \
610 CmmInfo \
611 CmmMachOp \
612 CmmNode \
613 CmmUtils \
614 CodeGen.Platform \
615 CodeGen.Platform.ARM \
616 CodeGen.Platform.ARM64 \
617 CodeGen.Platform.NoRegs \
618 CodeGen.Platform.PPC \
619 CodeGen.Platform.PPC_Darwin \
620 CodeGen.Platform.SPARC \
621 CodeGen.Platform.X86 \
622 CodeGen.Platform.X86_64 \
623 FastBool \
624 Hoopl \
625 Hoopl.Dataflow \
626 InteractiveEvalTypes \
627 MkGraph \
628 PprCmm \
629 PprCmmDecl \
630 PprCmmExpr \
631 Reg \
632 RegClass \
633 SMRep \
634 StgCmmArgRep \
635 StgCmmClosure \
636 StgCmmEnv \
637 StgCmmLayout \
638 StgCmmMonad \
639 StgCmmProf \
640 StgCmmTicky \
641 StgCmmUtils \
642 StgSyn \
643 Stream
644 endif
645
646 compiler_stage2_dll0_HS_OBJS = \
647 $(patsubst %,compiler/stage2/build/%.$(dyn_osuf),$(subst .,/,$(compiler_stage2_dll0_MODULES)))
648
649 # if stage is set to something other than "1" or "", disable stage 1
650 ifneq "$(filter-out 1,$(stage))" ""
651 compiler_stage1_NOT_NEEDED = YES
652 endif
653 # if stage is set to something other than "2" or "", disable stage 2
654 ifneq "$(filter-out 2,$(stage))" ""
655 compiler_stage2_NOT_NEEDED = YES
656 endif
657 # stage 3 has to be requested explicitly with stage=3
658 ifneq "$(stage)" "3"
659 compiler_stage3_NOT_NEEDED = YES
660 endif
661 $(eval $(call build-package,compiler,stage1,0))
662 $(eval $(call build-package,compiler,stage2,1))
663 $(eval $(call build-package,compiler,stage3,2))
664
665 # We only want to turn keepCAFs on if we will be loading dynamic
666 # Haskell libraries with GHCi. We therefore filter the object file
667 # out for non-dynamic ways.
668 define keepCAFsForGHCiDynOnly
669 # $1 = stage
670 # $2 = way
671 ifeq "$$(findstring dyn, $1)" ""
672 compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.o,$$(compiler_stage$1_$2_C_OBJS))
673 endif
674 endef
675 $(foreach w,$(compiler_stage1_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,1,$w)))
676 $(foreach w,$(compiler_stage2_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,2,$w)))
677 $(foreach w,$(compiler_stage3_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,3,$w)))
678
679 # after build-package, because that adds --enable-library-for-ghci
680 # to compiler_stage*_CONFIGURE_OPTS:
681 # We don't build the GHCi library for the ghc package. We can load it
682 # the .a file instead, and as object splitting isn't on for the ghc
683 # package this isn't much slower.However, not building the package saves
684 # a significant chunk of disk space.
685 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
686 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
687 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
688
689 # after build-package, because that sets compiler_stage1_HC_OPTS:
690 compiler_stage1_HC_OPTS += $(GhcHcOpts) $(GhcStage1HcOpts)
691 compiler_stage2_HC_OPTS += $(GhcHcOpts) $(GhcStage2HcOpts)
692 compiler_stage3_HC_OPTS += $(GhcHcOpts) $(GhcStage3HcOpts)
693
694 ifneq "$(BINDIST)" "YES"
695
696 compiler_stage2_TAGS_HC_OPTS = -package ghc
697 $(eval $(call tags-package,compiler,stage2))
698
699 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
700 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
701 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
702
703 COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
704 COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
705 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
706 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_TYPE)
707 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
708 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
709 COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
710
711 $(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1)
712 $(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2)
713 $(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3)
714
715 $(foreach way,$(compiler_stage1_WAYS),\
716 compiler/stage1/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE1)
717 $(foreach way,$(compiler_stage2_WAYS),\
718 compiler/stage2/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE2)
719 $(foreach way,$(compiler_stage3_WAYS),\
720 compiler/stage3/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE3)
721
722
723 # GHC itself doesn't know about the above dependencies, so we have to
724 # switch off the recompilation checker for that module:
725 compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
726
727 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
728 compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
729 endif
730
731 # LibFFI.hs #includes ffi.h
732 ifneq "$(UseSystemLibFFI)" "YES"
733 compiler/stage2/build/LibFFI.hs : $(libffi_HEADERS)
734 endif
735
736 # Note [munge-stage1-package-config]
737 # Strip the date/patchlevel from the version of stage1. See Note
738 # [fiddle-stage1-version] above.
739 ifeq "$(compiler_stage1_VERSION_MUNGED)" "YES"
740 compiler/stage1/inplace-pkg-config-munged: compiler/stage1/inplace-pkg-config
741 sed -e 's/^\(version: .*\)\.$(ProjectPatchLevel)$$/\1/' \
742 -e 's/^\(id: .*\)\.$(ProjectPatchLevel)$$/\1/' \
743 -e 's/^\(hs-libraries: HSghc-.*\)\.$(ProjectPatchLevel)$$/\1/' \
744 < $< > $@
745 "$(compiler_stage1_GHC_PKG)" update --force $(compiler_stage1_GHC_PKG_OPTS) $@
746
747 # We need to make sure the munged config is in the database before we
748 # try to configure ghc-bin
749 ghc/stage1/package-data.mk : compiler/stage1/inplace-pkg-config-munged
750 endif
751
752 endif
753