Add some commented-out tracing in SpecConstr
[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 ' | IntegerSimple' >> $@
58 @echo ' deriving Eq' >> $@
59 @echo >> $@
60 @echo 'cBuildPlatformString :: String' >> $@
61 @echo 'cBuildPlatformString = BuildPlatform_NAME' >> $@
62 @echo 'cHostPlatformString :: String' >> $@
63 @echo 'cHostPlatformString = HostPlatform_NAME' >> $@
64 @echo 'cTargetPlatformString :: String' >> $@
65 @echo 'cTargetPlatformString = TargetPlatform_NAME' >> $@
66 @echo >> $@
67 @echo 'cProjectName :: String' >> $@
68 @echo 'cProjectName = "$(ProjectName)"' >> $@
69 @echo 'cProjectGitCommitId :: String' >> $@
70 @echo 'cProjectGitCommitId = "$(ProjectGitCommitId)"' >> $@
71 @echo 'cProjectVersion :: String' >> $@
72 @echo 'cProjectVersion = "$(ProjectVersion)"' >> $@
73 @echo 'cProjectVersionInt :: String' >> $@
74 @echo 'cProjectVersionInt = "$(ProjectVersionInt)"' >> $@
75 @echo 'cProjectPatchLevel :: String' >> $@
76 @echo 'cProjectPatchLevel = "$(ProjectPatchLevel)"' >> $@
77 @echo 'cProjectPatchLevel1 :: String' >> $@
78 @echo 'cProjectPatchLevel1 = "$(ProjectPatchLevel1)"' >> $@
79 @echo 'cProjectPatchLevel2 :: String' >> $@
80 @echo 'cProjectPatchLevel2 = "$(ProjectPatchLevel2)"' >> $@
81 @echo 'cBooterVersion :: String' >> $@
82 @echo 'cBooterVersion = "$(GhcVersion)"' >> $@
83 @echo 'cStage :: String' >> $@
84 @echo 'cStage = show (STAGE :: Int)' >> $@
85 @echo 'cIntegerLibrary :: String' >> $@
86 @echo 'cIntegerLibrary = "$(INTEGER_LIBRARY)"' >> $@
87 @echo 'cIntegerLibraryType :: IntegerLibrary' >> $@
88 ifeq "$(INTEGER_LIBRARY)" "integer-gmp"
89 @echo 'cIntegerLibraryType = IntegerGMP' >> $@
90 else ifeq "$(INTEGER_LIBRARY)" "integer-simple"
91 @echo 'cIntegerLibraryType = IntegerSimple' >> $@
92 else ifneq "$(CLEANING)" "YES"
93 $(error Unknown integer library)
94 endif
95 @echo 'cSupportsSplitObjs :: String' >> $@
96 @echo 'cSupportsSplitObjs = "$(SupportsSplitObjs)"' >> $@
97 @echo 'cGhcWithInterpreter :: String' >> $@
98 @echo 'cGhcWithInterpreter = "$(GhcWithInterpreter)"' >> $@
99 @echo 'cGhcWithNativeCodeGen :: String' >> $@
100 @echo 'cGhcWithNativeCodeGen = "$(GhcWithNativeCodeGen)"' >> $@
101 @echo 'cGhcWithSMP :: String' >> $@
102 @echo 'cGhcWithSMP = "$(GhcWithSMP)"' >> $@
103 @echo 'cGhcRTSWays :: String' >> $@
104 @echo 'cGhcRTSWays = "$(GhcRTSWays)"' >> $@
105 @echo 'cGhcRtsWithLibdw :: Bool' >> $@
106 ifeq "$(GhcRtsWithLibdw)" "YES"
107 @echo 'cGhcRtsWithLibdw = True' >> $@
108 else
109 @echo 'cGhcRtsWithLibdw = False' >> $@
110 endif
111 @echo 'cGhcEnableTablesNextToCode :: String' >> $@
112 @echo 'cGhcEnableTablesNextToCode = "$(GhcEnableTablesNextToCode)"' >> $@
113 @echo 'cLeadingUnderscore :: String' >> $@
114 @echo 'cLeadingUnderscore = "$(LeadingUnderscore)"' >> $@
115 @echo 'cGHC_UNLIT_PGM :: String' >> $@
116 @echo 'cGHC_UNLIT_PGM = "$(utils/unlit_dist_PROG)"' >> $@
117 @echo 'cGHC_SPLIT_PGM :: String' >> $@
118 @echo 'cGHC_SPLIT_PGM = "$(driver/split_dist_PROG)"' >> $@
119 @echo 'cLibFFI :: Bool' >> $@
120 ifeq "$(UseLibFFIForAdjustors)" "YES"
121 @echo 'cLibFFI = True' >> $@
122 else
123 @echo 'cLibFFI = False' >> $@
124 endif
125 # Note that GhcThreaded just reflects the Makefile variable setting.
126 # In particular, the stage1 compiler is never actually compiled with
127 # -threaded, but it will nevertheless have cGhcThreaded = True.
128 # The "+RTS --info" output will show what RTS GHC is really using.
129 @echo 'cGhcThreaded :: Bool' >> $@
130 ifeq "$(GhcThreaded)" "YES"
131 @echo 'cGhcThreaded = True' >> $@
132 else
133 @echo 'cGhcThreaded = False' >> $@
134 endif
135 @echo 'cGhcDebugged :: Bool' >> $@
136 ifeq "$(GhcDebugged)" "YES"
137 @echo 'cGhcDebugged = True' >> $@
138 else
139 @echo 'cGhcDebugged = False' >> $@
140 endif
141 @echo done.
142
143 # -----------------------------------------------------------------------------
144 # Create platform includes
145
146 # Here we generate a little header file containing CPP symbols that GHC
147 # uses to determine which platform it is building on/for. The platforms
148 # can differ between stage1 and stage2 if we're cross-compiling, so we
149 # need one of these header files per stage.
150
151 PLATFORM_H = ghc_boot_platform.h
152
153 compiler/stage1/$(PLATFORM_H) : mk/config.mk mk/project.mk | $$(dir $$@)/.
154 $(call removeFiles,$@)
155 @echo "Creating $@..."
156 @echo "#ifndef __PLATFORM_H__" >> $@
157 @echo "#define __PLATFORM_H__" >> $@
158 @echo >> $@
159 @echo "#define BuildPlatform_NAME \"$(BUILDPLATFORM)\"" >> $@
160 @echo "#define HostPlatform_NAME \"$(HOSTPLATFORM)\"" >> $@
161 @echo "#define TargetPlatform_NAME \"$(TARGETPLATFORM)\"" >> $@
162 @echo >> $@
163 @echo "#define $(BuildPlatform_CPP)_BUILD 1" >> $@
164 @echo "#define $(HostPlatform_CPP)_HOST 1" >> $@
165 @echo "#define $(TargetPlatform_CPP)_TARGET 1" >> $@
166 @echo >> $@
167 @echo "#define $(BuildArch_CPP)_BUILD_ARCH 1" >> $@
168 @echo "#define $(HostArch_CPP)_HOST_ARCH 1" >> $@
169 @echo "#define $(TargetArch_CPP)_TARGET_ARCH 1" >> $@
170 @echo "#define BUILD_ARCH \"$(BuildArch_CPP)\"" >> $@
171 @echo "#define HOST_ARCH \"$(HostArch_CPP)\"" >> $@
172 @echo "#define TARGET_ARCH \"$(TargetArch_CPP)\"" >> $@
173 @echo >> $@
174 @echo "#define $(BuildOS_CPP)_BUILD_OS 1" >> $@
175 @echo "#define $(HostOS_CPP)_HOST_OS 1" >> $@
176 @echo "#define $(TargetOS_CPP)_TARGET_OS 1" >> $@
177 @echo "#define BUILD_OS \"$(BuildOS_CPP)\"" >> $@
178 @echo "#define HOST_OS \"$(HostOS_CPP)\"" >> $@
179 @echo "#define TARGET_OS \"$(TargetOS_CPP)\"" >> $@
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 @echo >> $@
222 @echo "#define $(HostVendor_CPP)_BUILD_VENDOR 1" >> $@
223 @echo "#define $(TargetVendor_CPP)_HOST_VENDOR 1" >> $@
224 @echo "#define $(TargetVendor_CPP)_TARGET_VENDOR 1" >> $@
225 @echo "#define BUILD_VENDOR \"$(HostVendor_CPP)\"" >> $@
226 @echo "#define HOST_VENDOR \"$(TargetVendor_CPP)\"" >> $@
227 @echo "#define TARGET_VENDOR \"$(TargetVendor_CPP)\"" >> $@
228 @echo >> $@
229 @echo "#endif /* __PLATFORM_H__ */" >> $@
230 @echo "Done."
231
232 compiler/stage3/$(PLATFORM_H) : compiler/stage2/$(PLATFORM_H)
233 "$(CP)" $< $@
234
235 # ----------------------------------------------------------------------------
236 # Generate supporting stuff for prelude/PrimOp.hs
237 # from prelude/primops.txt
238
239 PRIMOP_BITS_NAMES = primop-data-decl.hs-incl \
240 primop-tag.hs-incl \
241 primop-list.hs-incl \
242 primop-has-side-effects.hs-incl \
243 primop-out-of-line.hs-incl \
244 primop-commutable.hs-incl \
245 primop-code-size.hs-incl \
246 primop-can-fail.hs-incl \
247 primop-strictness.hs-incl \
248 primop-fixity.hs-incl \
249 primop-primop-info.hs-incl \
250 primop-vector-uniques.hs-incl \
251 primop-vector-tys.hs-incl \
252 primop-vector-tys-exports.hs-incl \
253 primop-vector-tycons.hs-incl
254
255 PRIMOP_BITS_STAGE1 = $(addprefix compiler/stage1/build/,$(PRIMOP_BITS_NAMES))
256 PRIMOP_BITS_STAGE2 = $(addprefix compiler/stage2/build/,$(PRIMOP_BITS_NAMES))
257 PRIMOP_BITS_STAGE3 = $(addprefix compiler/stage3/build/,$(PRIMOP_BITS_NAMES))
258
259 compiler_CPP_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
260 compiler_CPP_OPTS += ${GhcCppOpts}
261
262 # We add these paths to the Haskell compiler's #include search path list since
263 # we must avoid #including files by paths relative to the source file as Hadrian
264 # moves the build artifacts out of the source tree. See #8040.
265 compiler_HC_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS))
266
267 define preprocessCompilerFiles
268 # $0 = stage
269 compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
270 $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
271
272 compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
273 "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
274 compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
275 "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
276 compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
277 "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
278 compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
279 "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
280 compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
281 "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
282 compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
283 "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
284 compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
285 "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
286 compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
287 "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
288 compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
289 "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
290 compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
291 "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
292 compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
293 "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
294 compiler/stage$1/build/primop-vector-uniques.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
295 "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
296 compiler/stage$1/build/primop-vector-tys.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
297 "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
298 compiler/stage$1/build/primop-vector-tys-exports.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
299 "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
300 compiler/stage$1/build/primop-vector-tycons.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
301 "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
302
303 # Usages aren't used any more; but the generator
304 # can still generate them if we want them back
305 compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
306 "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
307
308 endef
309
310 $(eval $(call preprocessCompilerFiles,1))
311 $(eval $(call preprocessCompilerFiles,2))
312 $(eval $(call preprocessCompilerFiles,3))
313
314 # -----------------------------------------------------------------------------
315 # Configuration
316
317 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
318 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
319 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
320
321 ifeq "$(GhcThreaded)" "YES"
322 # We pass THREADED_RTS to the stage2 C files so that cbits/genSym.c will bring
323 # the threaded version of atomic_inc() into scope.
324 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS
325 endif
326
327 ifeq "$(GhcWithNativeCodeGen)" "YES"
328 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
329 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
330 endif
331
332 ifeq "$(GhcWithInterpreter)" "YES"
333 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
334
335 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
336 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
337 # or not?
338 # XXX This should logically be a CPP option, but there doesn't seem to
339 # be a flag for that
340 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
341 endif
342
343 # Should the debugger commands be enabled?
344 ifeq "$(GhciWithDebugger)" "YES"
345 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
346 endif
347
348 endif
349
350 ifeq "$(TargetOS_CPP)" "openbsd"
351 compiler_CONFIGURE_OPTS += --ld-options=-E
352 endif
353
354 ifeq "$(GhcUnregisterised)" "NO"
355 else
356 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
357 endif
358
359 ifneq "$(GhcWithSMP)" "YES"
360 compiler_CONFIGURE_OPTS += --ghc-option=-DNOSMP
361 compiler_CONFIGURE_OPTS += --ghc-option=-optc-DNOSMP
362 endif
363
364 # Careful optimisation of the parser: we don't want to throw everything
365 # at it, because that takes too long and doesn't buy much, but we do want
366 # to inline certain key external functions, so we instruct GHC not to
367 # throw away inlinings as it would normally do in -O0 mode.
368 # Since GHC version 7.8, we need -fcmm-sink to be
369 # passed to the compiler. This is required on x86 to avoid the
370 # register allocator running out of stack slots when compiling this
371 # module with -fPIC -dynamic.
372 # See #8182 for all the details
373 compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
374 compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
375 compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
376
377 ifeq "$(GhcProfiled)" "YES"
378 # If we're profiling GHC then we want SCCs. However, adding -auto-all
379 # everywhere tends to give a hard-to-read profile, and adds lots of
380 # overhead. A better approach is to proceed top-down; identify the
381 # parts of the compiler of interest, and then add further cost centres
382 # as necessary. Turn on -fprof-auto for individual modules like this:
383
384 # compiler/main/DriverPipeline_HC_OPTS += -fprof-auto
385 compiler/main/GhcMake_HC_OPTS += -fprof-auto
386 compiler/main/GHC_HC_OPTS += -fprof-auto
387
388 # or alternatively add {-# OPTIONS_GHC -fprof-auto #-} to the top of
389 # modules you're interested in.
390
391 # We seem to still build the vanilla libraries even if we say
392 # --disable-library-vanilla, but installation then fails, as Cabal
393 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
394 # their absence when we register the package. So for now, we just
395 # leave the vanilla libraries enabled.
396 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
397 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
398 endif
399
400 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
401
402 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
403 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
404 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
405 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
406
407 compiler/stage1/package-data.mk : compiler/ghc.mk
408 compiler/stage2/package-data.mk : compiler/ghc.mk
409 compiler/stage3/package-data.mk : compiler/ghc.mk
410
411 # -----------------------------------------------------------------------------
412 # And build the package
413
414 compiler_PACKAGE = ghc
415
416 # Don't do splitting for the GHC package, it takes too long and
417 # there's not much benefit.
418 compiler_stage1_SplitObjs = NO
419 compiler_stage2_SplitObjs = NO
420 compiler_stage3_SplitObjs = NO
421 compiler_stage1_SplitSections = NO
422 compiler_stage2_SplitSections = NO
423 compiler_stage3_SplitSections = NO
424
425 # There are too many symbols in the ghc package for a Windows DLL
426 # (due to a limitation of bfd ld, see Trac #5987). We therefore need to split
427 # some of the modules off into a separate DLL. This clump are the modules
428 # reachable from DynFlags:
429 compiler_stage2_dll0_START_MODULE = DynFlags
430 compiler_stage2_dll0_MODULES = \
431 Annotations \
432 ApiAnnotation \
433 Avail \
434 Bag \
435 BasicTypes \
436 Binary \
437 BinFingerprint \
438 BooleanFormula \
439 BufWrite \
440 Class \
441 CmdLineParser \
442 CmmType \
443 CoAxiom \
444 ConLike \
445 Coercion \
446 Config \
447 Constants \
448 CoreArity \
449 CoreFVs \
450 CoreSubst \
451 CoreSyn \
452 CoreTidy \
453 CoreUnfold \
454 CoreUtils \
455 CoreSeq \
456 CoreStats \
457 CostCentre \
458 DataCon \
459 Demand \
460 Digraph \
461 DriverPhases \
462 DynFlags \
463 Encoding \
464 ErrUtils \
465 Exception \
466 FamInstEnv \
467 FastFunctions \
468 FastMutInt \
469 FastString \
470 FastStringEnv \
471 FieldLabel \
472 Fingerprint \
473 FiniteMap \
474 ForeignCall \
475 FV \
476 Hooks \
477 HsBinds \
478 HsDecls \
479 HsDoc \
480 HsExpr \
481 HsImpExp \
482 HsLit \
483 PlaceHolder \
484 PmExpr \
485 HsPat \
486 HsSyn \
487 HsTypes \
488 HsUtils \
489 HscTypes \
490 IOEnv \
491 NameCache \
492 Id \
493 IdInfo \
494 IfaceSyn \
495 IfaceType \
496 Json \
497 ToIface \
498 InstEnv \
499 Kind \
500 KnownUniques \
501 Lexeme \
502 ListSetOps \
503 Literal \
504 Maybes \
505 MkCore \
506 MkId \
507 Module \
508 MonadUtils \
509 Name \
510 NameEnv \
511 NameSet \
512 OccName \
513 OccurAnal \
514 OptCoercion \
515 OrdList \
516 Outputable \
517 PackageConfig \
518 Packages \
519 Pair \
520 Panic \
521 PatSyn \
522 PipelineMonad \
523 Platform \
524 PlatformConstants \
525 PprCore \
526 PrelNames \
527 PrelRules \
528 Pretty \
529 PrimOp \
530 RepType \
531 RdrName \
532 Rules \
533 SrcLoc \
534 StringBuffer \
535 SysTools.Terminal \
536 TcEvidence \
537 TcRnTypes \
538 TcType \
539 TrieMap \
540 TyCon \
541 Type \
542 TyCoRep \
543 TysPrim \
544 TysWiredIn \
545 Unify \
546 UniqDFM \
547 UniqDSet \
548 UniqFM \
549 UniqSet \
550 UniqSupply \
551 Unique \
552 Util \
553 Var \
554 VarEnv \
555 VarSet
556
557 ifeq "$(GhcWithInterpreter)" "YES"
558 # These files are reacheable from DynFlags
559 # only by GHCi-enabled code (see #9552)
560 compiler_stage2_dll0_MODULES += \
561 ByteCodeTypes \
562 InteractiveEvalTypes
563 endif
564
565 compiler_stage2_dll0_HS_OBJS = \
566 $(patsubst %,compiler/stage2/build/%.$(dyn_osuf),$(subst .,/,$(compiler_stage2_dll0_MODULES)))
567
568 # if stage is set to something other than "1" or "", disable stage 1
569 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
570 ifneq "$(filter-out 1,$(stage))" ""
571 compiler_stage1_NOT_NEEDED = YES
572 endif
573 # if stage is set to something other than "2" or "", disable stage 2
574 ifneq "$(filter-out 2,$(stage))" ""
575 compiler_stage2_NOT_NEEDED = YES
576 endif
577 # stage 3 has to be requested explicitly with stage=3
578 ifneq "$(stage)" "3"
579 compiler_stage3_NOT_NEEDED = YES
580 endif
581 $(eval $(call build-package,compiler,stage1,0))
582 $(eval $(call build-package,compiler,stage2,1))
583 $(eval $(call build-package,compiler,stage3,2))
584
585 # We only want to turn keepCAFs on if we will be loading dynamic
586 # Haskell libraries with GHCi. We therefore filter the object file
587 # out for non-dynamic ways.
588 define keepCAFsForGHCiDynOnly
589 # $1 = stage
590 # $2 = way
591 ifeq "$$(findstring dyn, $2)" ""
592 compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.$$($2_osuf),$$(compiler_stage$1_$2_C_OBJS))
593 endif
594 endef
595 $(foreach w,$(compiler_stage1_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,1,$w)))
596 $(foreach w,$(compiler_stage2_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,2,$w)))
597 $(foreach w,$(compiler_stage3_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,3,$w)))
598
599 # after build-package, because that adds --enable-library-for-ghci
600 # to compiler_stage*_CONFIGURE_OPTS:
601 # We don't build the GHCi library for the ghc package. We can load it
602 # the .a file instead, and as object splitting isn't on for the ghc
603 # package this isn't much slower.However, not building the package saves
604 # a significant chunk of disk space.
605 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
606 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
607 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
608
609 # after build-package, because that sets compiler_stage1_HC_OPTS:
610 ifeq "$(V)" "0"
611 compiler_stage1_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage1HcOpts)
612 compiler_stage2_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage2HcOpts)
613 compiler_stage3_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage3HcOpts)
614 else
615 compiler_stage1_HC_OPTS += $(GhcHcOpts) $(GhcStage1HcOpts)
616 compiler_stage2_HC_OPTS += $(GhcHcOpts) $(GhcStage2HcOpts)
617 compiler_stage3_HC_OPTS += $(GhcHcOpts) $(GhcStage3HcOpts)
618 endif
619
620 ifneq "$(BINDIST)" "YES"
621
622 compiler_stage2_TAGS_HC_OPTS = -package ghc
623 $(eval $(call tags-package,compiler,stage2))
624
625 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
626 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
627 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
628
629 COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
630 COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
631 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
632 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_TYPE)
633 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
634 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
635 COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
636
637 $(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1)
638 $(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2)
639 $(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3)
640
641 $(foreach way,$(compiler_stage1_WAYS),\
642 compiler/stage1/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE1)
643 $(foreach way,$(compiler_stage2_WAYS),\
644 compiler/stage2/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE2)
645 $(foreach way,$(compiler_stage3_WAYS),\
646 compiler/stage3/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE3)
647
648
649 # GHC itself doesn't know about the above dependencies, so we have to
650 # switch off the recompilation checker for that module:
651 compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
652
653 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
654 compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
655 endif
656
657 endif