Revert "compiler/iface: compress .hi files"
[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.lhs
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 define preprocessCompilerFiles
263 # $0 = stage
264 compiler/stage$1/build/primops.txt: compiler/prelude/primops.txt.pp compiler/stage$1/$$(PLATFORM_H)
265 $$(HS_CPP) -P $$(compiler_CPP_OPTS) -Icompiler/stage$1 -x c $$< | grep -v '^#pragma GCC' > $$@
266
267 compiler/stage$1/build/primop-data-decl.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
268 "$$(genprimopcode_INPLACE)" --data-decl < $$< > $$@
269 compiler/stage$1/build/primop-tag.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
270 "$$(genprimopcode_INPLACE)" --primop-tag < $$< > $$@
271 compiler/stage$1/build/primop-list.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
272 "$$(genprimopcode_INPLACE)" --primop-list < $$< > $$@
273 compiler/stage$1/build/primop-has-side-effects.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
274 "$$(genprimopcode_INPLACE)" --has-side-effects < $$< > $$@
275 compiler/stage$1/build/primop-out-of-line.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
276 "$$(genprimopcode_INPLACE)" --out-of-line < $$< > $$@
277 compiler/stage$1/build/primop-commutable.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
278 "$$(genprimopcode_INPLACE)" --commutable < $$< > $$@
279 compiler/stage$1/build/primop-code-size.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
280 "$$(genprimopcode_INPLACE)" --code-size < $$< > $$@
281 compiler/stage$1/build/primop-can-fail.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
282 "$$(genprimopcode_INPLACE)" --can-fail < $$< > $$@
283 compiler/stage$1/build/primop-strictness.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
284 "$$(genprimopcode_INPLACE)" --strictness < $$< > $$@
285 compiler/stage$1/build/primop-fixity.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
286 "$$(genprimopcode_INPLACE)" --fixity < $$< > $$@
287 compiler/stage$1/build/primop-primop-info.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
288 "$$(genprimopcode_INPLACE)" --primop-primop-info < $$< > $$@
289 compiler/stage$1/build/primop-vector-uniques.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
290 "$$(genprimopcode_INPLACE)" --primop-vector-uniques < $$< > $$@
291 compiler/stage$1/build/primop-vector-tys.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
292 "$$(genprimopcode_INPLACE)" --primop-vector-tys < $$< > $$@
293 compiler/stage$1/build/primop-vector-tys-exports.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
294 "$$(genprimopcode_INPLACE)" --primop-vector-tys-exports < $$< > $$@
295 compiler/stage$1/build/primop-vector-tycons.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
296 "$$(genprimopcode_INPLACE)" --primop-vector-tycons < $$< > $$@
297
298 # Usages aren't used any more; but the generator
299 # can still generate them if we want them back
300 compiler/stage$1/build/primop-usage.hs-incl: compiler/stage$1/build/primops.txt $$$$(genprimopcode_INPLACE)
301 "$$(genprimopcode_INPLACE)" --usage < $$< > $$@
302
303 endef
304
305 $(eval $(call preprocessCompilerFiles,1))
306 $(eval $(call preprocessCompilerFiles,2))
307 $(eval $(call preprocessCompilerFiles,3))
308
309 # -----------------------------------------------------------------------------
310 # Configuration
311
312 compiler_stage1_CONFIGURE_OPTS += --flags=stage1
313 compiler_stage2_CONFIGURE_OPTS += --flags=stage2
314 compiler_stage3_CONFIGURE_OPTS += --flags=stage3
315
316 ifeq "$(GhcThreaded)" "YES"
317 # We pass THREADED_RTS to the stage2 C files so that cbits/genSym.c will bring
318 # the threaded version of atomic_inc() into scope.
319 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-optc-DTHREADED_RTS
320 endif
321
322 ifeq "$(GhcWithNativeCodeGen)" "YES"
323 compiler_stage1_CONFIGURE_OPTS += --flags=ncg
324 compiler_stage2_CONFIGURE_OPTS += --flags=ncg
325 endif
326
327 ifeq "$(GhcWithInterpreter)" "YES"
328 compiler_stage2_CONFIGURE_OPTS += --flags=ghci
329
330 ifeq "$(GhcEnableTablesNextToCode) $(GhcUnregisterised)" "YES NO"
331 # Should GHCI be building info tables in the TABLES_NEXT_TO_CODE style
332 # or not?
333 # XXX This should logically be a CPP option, but there doesn't seem to
334 # be a flag for that
335 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DGHCI_TABLES_NEXT_TO_CODE
336 endif
337
338 # Should the debugger commands be enabled?
339 ifeq "$(GhciWithDebugger)" "YES"
340 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DDEBUGGER
341 endif
342
343 endif
344
345 ifeq "$(TargetOS_CPP)" "openbsd"
346 compiler_CONFIGURE_OPTS += --ld-options=-E
347 endif
348
349 ifeq "$(GhcUnregisterised)" "NO"
350 else
351 compiler_CONFIGURE_OPTS += --ghc-option=-DNO_REGS
352 endif
353
354 ifneq "$(GhcWithSMP)" "YES"
355 compiler_CONFIGURE_OPTS += --ghc-option=-DNOSMP
356 compiler_CONFIGURE_OPTS += --ghc-option=-optc-DNOSMP
357 endif
358
359 # Careful optimisation of the parser: we don't want to throw everything
360 # at it, because that takes too long and doesn't buy much, but we do want
361 # to inline certain key external functions, so we instruct GHC not to
362 # throw away inlinings as it would normally do in -O0 mode.
363 # Since GHC version 7.8, we need -fcmm-sink to be
364 # passed to the compiler. This is required on x86 to avoid the
365 # register allocator running out of stack slots when compiling this
366 # module with -fPIC -dynamic.
367 # See #8182 for all the details
368 compiler/stage1/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
369 compiler/stage2/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
370 compiler/stage3/build/Parser_HC_OPTS += -O0 -fno-ignore-interface-pragmas -fcmm-sink
371
372 ifeq "$(GhcProfiled)" "YES"
373 # If we're profiling GHC then we want SCCs. However, adding -auto-all
374 # everywhere tends to give a hard-to-read profile, and adds lots of
375 # overhead. A better approach is to proceed top-down; identify the
376 # parts of the compiler of interest, and then add further cost centres
377 # as necessary. Turn on -fprof-auto for individual modules like this:
378
379 # compiler/main/DriverPipeline_HC_OPTS += -fprof-auto
380 compiler/main/GhcMake_HC_OPTS += -fprof-auto
381 compiler/main/GHC_HC_OPTS += -fprof-auto
382
383 # or alternatively add {-# OPTIONS_GHC -fprof-auto #-} to the top of
384 # modules you're interested in.
385
386 # We seem to still build the vanilla libraries even if we say
387 # --disable-library-vanilla, but installation then fails, as Cabal
388 # doesn't copy the vanilla .hi files, but ghc-pkg complains about
389 # their absence when we register the package. So for now, we just
390 # leave the vanilla libraries enabled.
391 # compiler_stage2_CONFIGURE_OPTS += --disable-library-vanilla
392 compiler_stage2_CONFIGURE_OPTS += --ghc-pkg-option=--force
393 endif
394
395 compiler_stage3_CONFIGURE_OPTS := $(compiler_stage2_CONFIGURE_OPTS)
396
397 compiler_stage1_CONFIGURE_OPTS += --ghc-option=-DSTAGE=1
398 compiler_stage2_CONFIGURE_OPTS += --ghc-option=-DSTAGE=2
399 compiler_stage3_CONFIGURE_OPTS += --ghc-option=-DSTAGE=3
400 compiler_stage2_HADDOCK_OPTS += --optghc=-DSTAGE=2
401
402 compiler/stage1/package-data.mk : compiler/ghc.mk
403 compiler/stage2/package-data.mk : compiler/ghc.mk
404 compiler/stage3/package-data.mk : compiler/ghc.mk
405
406 # -----------------------------------------------------------------------------
407 # And build the package
408
409 compiler_PACKAGE = ghc
410
411 # Don't do splitting for the GHC package, it takes too long and
412 # there's not much benefit.
413 compiler_stage1_SplitObjs = NO
414 compiler_stage2_SplitObjs = NO
415 compiler_stage3_SplitObjs = NO
416 compiler_stage1_SplitSections = NO
417 compiler_stage2_SplitSections = NO
418 compiler_stage3_SplitSections = NO
419
420 # There are too many symbols in the ghc package for a Windows DLL
421 # (due to a limitation of bfd ld, see Trac #5987). We therefore need to split
422 # some of the modules off into a separate DLL. This clump are the modules
423 # reachable from DynFlags:
424 compiler_stage2_dll0_START_MODULE = DynFlags
425 compiler_stage2_dll0_MODULES = \
426 Annotations \
427 ApiAnnotation \
428 Avail \
429 Bag \
430 BasicTypes \
431 Binary \
432 BooleanFormula \
433 BufWrite \
434 Class \
435 CmdLineParser \
436 CmmType \
437 CoAxiom \
438 ConLike \
439 Coercion \
440 Config \
441 Constants \
442 CoreArity \
443 CoreFVs \
444 CoreSubst \
445 CoreSyn \
446 CoreTidy \
447 CoreUnfold \
448 CoreUtils \
449 CoreSeq \
450 CoreStats \
451 CostCentre \
452 DataCon \
453 Demand \
454 Digraph \
455 DriverPhases \
456 DynFlags \
457 Encoding \
458 ErrUtils \
459 Exception \
460 FamInstEnv \
461 FastFunctions \
462 FastMutInt \
463 FastString \
464 FastStringEnv \
465 FieldLabel \
466 Fingerprint \
467 FiniteMap \
468 ForeignCall \
469 FV \
470 Hooks \
471 HsBinds \
472 HsDecls \
473 HsDoc \
474 HsExpr \
475 HsImpExp \
476 HsLit \
477 PlaceHolder \
478 PmExpr \
479 HsPat \
480 HsSyn \
481 HsTypes \
482 HsUtils \
483 HscTypes \
484 IOEnv \
485 Id \
486 IdInfo \
487 IfaceSyn \
488 IfaceType \
489 InstEnv \
490 Kind \
491 Lexeme \
492 ListSetOps \
493 Literal \
494 Maybes \
495 MkCore \
496 MkId \
497 Module \
498 MonadUtils \
499 Name \
500 NameEnv \
501 NameSet \
502 OccName \
503 OccurAnal \
504 OptCoercion \
505 OrdList \
506 Outputable \
507 PackageConfig \
508 Packages \
509 Pair \
510 Panic \
511 PatSyn \
512 PipelineMonad \
513 Platform \
514 PlatformConstants \
515 PprCore \
516 PrelNames \
517 PrelRules \
518 Pretty \
519 PrimOp \
520 RdrName \
521 Rules \
522 SrcLoc \
523 StaticFlags \
524 StringBuffer \
525 TcEvidence \
526 TcRnTypes \
527 TcType \
528 TrieMap \
529 TyCon \
530 Type \
531 TyCoRep \
532 TysPrim \
533 TysWiredIn \
534 Unify \
535 UniqDFM \
536 UniqDSet \
537 UniqFM \
538 UniqSet \
539 UniqSupply \
540 Unique \
541 Util \
542 Var \
543 VarEnv \
544 VarSet
545
546 ifeq "$(GhcWithInterpreter)" "YES"
547 # These files are reacheable from DynFlags
548 # only by GHCi-enabled code (see #9552)
549 compiler_stage2_dll0_MODULES += \
550 ByteCodeTypes \
551 InteractiveEvalTypes
552 endif
553
554 compiler_stage2_dll0_HS_OBJS = \
555 $(patsubst %,compiler/stage2/build/%.$(dyn_osuf),$(subst .,/,$(compiler_stage2_dll0_MODULES)))
556
557 # if stage is set to something other than "1" or "", disable stage 1
558 # See Note [Stage1Only vs stage=1] in mk/config.mk.in.
559 ifneq "$(filter-out 1,$(stage))" ""
560 compiler_stage1_NOT_NEEDED = YES
561 endif
562 # if stage is set to something other than "2" or "", disable stage 2
563 ifneq "$(filter-out 2,$(stage))" ""
564 compiler_stage2_NOT_NEEDED = YES
565 endif
566 # stage 3 has to be requested explicitly with stage=3
567 ifneq "$(stage)" "3"
568 compiler_stage3_NOT_NEEDED = YES
569 endif
570 $(eval $(call build-package,compiler,stage1,0))
571 $(eval $(call build-package,compiler,stage2,1))
572 $(eval $(call build-package,compiler,stage3,2))
573
574 # We only want to turn keepCAFs on if we will be loading dynamic
575 # Haskell libraries with GHCi. We therefore filter the object file
576 # out for non-dynamic ways.
577 define keepCAFsForGHCiDynOnly
578 # $1 = stage
579 # $2 = way
580 ifeq "$$(findstring dyn, $2)" ""
581 compiler_stage$1_$2_C_OBJS := $$(filter-out %/keepCAFsForGHCi.$$($2_osuf),$$(compiler_stage$1_$2_C_OBJS))
582 endif
583 endef
584 $(foreach w,$(compiler_stage1_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,1,$w)))
585 $(foreach w,$(compiler_stage2_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,2,$w)))
586 $(foreach w,$(compiler_stage3_WAYS),$(eval $(call keepCAFsForGHCiDynOnly,3,$w)))
587
588 # after build-package, because that adds --enable-library-for-ghci
589 # to compiler_stage*_CONFIGURE_OPTS:
590 # We don't build the GHCi library for the ghc package. We can load it
591 # the .a file instead, and as object splitting isn't on for the ghc
592 # package this isn't much slower.However, not building the package saves
593 # a significant chunk of disk space.
594 compiler_stage1_CONFIGURE_OPTS += --disable-library-for-ghci
595 compiler_stage2_CONFIGURE_OPTS += --disable-library-for-ghci
596 compiler_stage3_CONFIGURE_OPTS += --disable-library-for-ghci
597
598 # after build-package, because that sets compiler_stage1_HC_OPTS:
599 ifeq "$(V)" "0"
600 compiler_stage1_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage1HcOpts)
601 compiler_stage2_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage2HcOpts)
602 compiler_stage3_HC_OPTS += $(filter-out -Rghc-timing,$(GhcHcOpts)) $(GhcStage3HcOpts)
603 else
604 compiler_stage1_HC_OPTS += $(GhcHcOpts) $(GhcStage1HcOpts)
605 compiler_stage2_HC_OPTS += $(GhcHcOpts) $(GhcStage2HcOpts)
606 compiler_stage3_HC_OPTS += $(GhcHcOpts) $(GhcStage3HcOpts)
607 endif
608
609 ifneq "$(BINDIST)" "YES"
610
611 compiler_stage2_TAGS_HC_OPTS = -package ghc
612 $(eval $(call tags-package,compiler,stage2))
613
614 $(compiler_stage1_depfile_haskell) : compiler/stage1/$(PLATFORM_H)
615 $(compiler_stage2_depfile_haskell) : compiler/stage2/$(PLATFORM_H)
616 $(compiler_stage3_depfile_haskell) : compiler/stage3/$(PLATFORM_H)
617
618 COMPILER_INCLUDES_DEPS += $(includes_H_CONFIG)
619 COMPILER_INCLUDES_DEPS += $(includes_H_PLATFORM)
620 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS)
621 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_TYPE)
622 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_WRAPPERS)
623 COMPILER_INCLUDES_DEPS += $(includes_GHCCONSTANTS_HASKELL_EXPORTS)
624 COMPILER_INCLUDES_DEPS += $(includes_DERIVEDCONSTANTS)
625
626 $(compiler_stage1_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE1)
627 $(compiler_stage2_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE2)
628 $(compiler_stage3_depfile_haskell) : $(COMPILER_INCLUDES_DEPS) $(PRIMOP_BITS_STAGE3)
629
630 $(foreach way,$(compiler_stage1_WAYS),\
631 compiler/stage1/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE1)
632 $(foreach way,$(compiler_stage2_WAYS),\
633 compiler/stage2/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE2)
634 $(foreach way,$(compiler_stage3_WAYS),\
635 compiler/stage3/build/PrimOp.$($(way)_osuf)) : $(PRIMOP_BITS_STAGE3)
636
637
638 # GHC itself doesn't know about the above dependencies, so we have to
639 # switch off the recompilation checker for that module:
640 compiler/prelude/PrimOp_HC_OPTS += -fforce-recomp
641
642 ifeq "$(DYNAMIC_GHC_PROGRAMS)" "YES"
643 compiler/utils/Util_HC_OPTS += -DDYNAMIC_GHC_PROGRAMS
644 endif
645
646 endif