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