57db2970dafb694573ccd74cbdc12c7922ad653f
[ghc.git] / rts / ghc.mk
1 # -----------------------------------------------------------------------------
2 #
3 # (c) 2009 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 # Building the RTS
15
16 # We build the RTS with stage 1
17 rts_dist_HC = $(GHC_STAGE1)
18
19 rts_INSTALL_INFO = rts
20 rts_VERSION = 1.0
21
22 # Minimum supported Windows version.
23 # These numbers can be found at:
24 # https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx
25 # If we're compiling on windows, enforce that we only support Vista SP1+
26 # Adding this here means it doesn't have to be done in individual .c files
27 # and also centralizes the versioning.
28 rts_WINVER = 0x06000100
29
30 # merge GhcLibWays and GhcRTSWays but strip out duplicates
31 rts_WAYS = $(GhcLibWays) $(filter-out $(GhcLibWays),$(GhcRTSWays))
32 rts_dist_WAYS = $(rts_WAYS)
33
34 ALL_RTS_LIBS = $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf))
35 $(eval $(call all-target,rts,$(ALL_RTS_LIBS)))
36
37 # -----------------------------------------------------------------------------
38 # Defining the sources
39
40 ALL_DIRS = hooks sm eventlog linker
41
42 ifeq "$(TargetOS_CPP)" "mingw32"
43 ALL_DIRS += win32
44 else
45 ALL_DIRS += posix
46 endif
47
48 rts_C_SRCS := $(wildcard rts/*.c $(foreach dir,$(ALL_DIRS),rts/$(dir)/*.c))
49 rts_CMM_SRCS := $(wildcard rts/*.cmm)
50
51 # Don't compile .S files when bootstrapping a new arch
52 ifneq "$(PORTING_HOST)" "YES"
53 ifneq "$(findstring $(TargetArch_CPP), i386 powerpc powerpc64)" ""
54 rts_S_SRCS += rts/AdjustorAsm.S
55 endif
56 # this matches substrings of powerpc64le, including "powerpc" and "powerpc64"
57 ifneq "$(findstring $(TargetArch_CPP), powerpc64le)" ""
58 # unregisterised builds use the mini interpreter
59 ifneq "$(GhcUnregisterised)" "YES"
60 rts_S_SRCS += rts/StgCRunAsm.S
61 endif
62 endif
63 endif
64
65 ifeq "$(GhcUnregisterised)" "YES"
66 GENAPPLY_OPTS = -u
67 endif
68
69 rts_AUTO_APPLY_CMM = rts/dist/build/AutoApply.cmm
70
71 $(rts_AUTO_APPLY_CMM): $$(genapply_INPLACE)
72 "$(genapply_INPLACE)" >$@
73
74
75 rts_H_FILES := $(wildcard rts/*.h rts/*/*.h)
76
77 ifeq "$(USE_DTRACE)" "YES"
78 DTRACEPROBES_H = rts/dist/build/RtsProbes.h
79 rts_H_FILES += $(DTRACEPROBES_H)
80 endif
81
82 # collect the -l and -L flags that we need to link the rts dyn lib.
83 # Note that, as sed on OS X doesn't handle \+, we use [^ ][^ ]* rather
84 # than [^ ]\+
85 rts/dist/libs.depend : $$(ghc-pkg_INPLACE) | $$(dir $$@)/.
86 "$(ghc-pkg_INPLACE)" --simple-output field rts extra-libraries \
87 | sed -e 's/\([^ ][^ ]*\)/-l\1/g' > $@
88 "$(ghc-pkg_INPLACE)" --simple-output field rts library-dirs \
89 | sed -e 's/\([^ ][^ ]*\)/-L\1/g' >> $@
90
91
92 # ----------------------------------------------------------------------------
93 # On Windows, as the RTS and base libraries have recursive imports,
94 # we have to break the loop with "import libraries".
95 # These are made from rts/win32/libHS*.def which contain lists of
96 # all the symbols in those libraries used by the RTS.
97 #
98 ifeq "$(TargetOS_CPP)" "mingw32"
99
100 ALL_RTS_DEF_LIBNAMES = base ghc-prim
101 ALL_RTS_DEF_LIBS = \
102 rts/dist/build/win32/libHSbase.dll.a \
103 rts/dist/build/win32/libHSghc-prim.dll.a
104
105 # -- import libs for the regular Haskell libraries
106 define make-importlib-def # args $1 = lib name
107 rts/dist/build/win32/libHS$1.def : rts/win32/libHS$1.def
108 cat rts/win32/libHS$1.def \
109 | sed "s/@LibVersion@/$$(libraries/$1_dist-install_VERSION)/" \
110 | sed "s/@ProjectVersion@/$$(ProjectVersion)/" \
111 > rts/dist/build/win32/libHS$1.def
112
113 rts/dist/build/win32/libHS$1.dll.a : rts/dist/build/win32/libHS$1.def
114 "$$(DLLTOOL)" -d rts/dist/build/win32/libHS$1.def \
115 -l rts/dist/build/win32/libHS$1.dll.a
116 endef
117 $(foreach lib,$(ALL_RTS_DEF_LIBNAMES),$(eval $(call make-importlib-def,$(lib))))
118 endif
119
120 ifneq "$(BINDIST)" "YES"
121 ifneq "$(UseSystemLibFFI)" "YES"
122 ifeq "$(TargetOS_CPP)" "mingw32"
123 rts/dist/build/$(LIBFFI_DLL): libffi/build/inst/bin/$(LIBFFI_DLL)
124 cp $< $@
125 else
126 # This is a little hacky. We don't know the SO version, so we only
127 # depend on libffi.so, but copy libffi.so*
128 rts/dist/build/lib$(LIBFFI_NAME)$(soext): libffi/build/inst/lib/lib$(LIBFFI_NAME)$(soext)
129 cp libffi/build/inst/lib/lib$(LIBFFI_NAME)$(soext)* rts/dist/build
130 ifeq "$(TargetOS_CPP)" "darwin"
131 install_name_tool -id @rpath/lib$(LIBFFI_NAME)$(soext) rts/dist/build/lib$(LIBFFI_NAME)$(soext)
132 endif
133 endif
134 endif
135 endif
136
137
138 ifeq "$(USE_DTRACE)" "YES"
139 ifneq "$(findstring $(TargetOS_CPP), linux solaris2 freebsd)" ""
140 NEED_DTRACE_PROBES_OBJ = YES
141 endif
142 endif
143
144 #-----------------------------------------------------------------------------
145 # Building one way
146 define build-rts-way # args: $1 = way
147
148 ifneq "$$(BINDIST)" "YES"
149
150 rts_dist_$1_HC_OPTS := $$(GhcRtsHcOpts)
151 rts_dist_$1_CC_OPTS := $$(GhcRtsCcOpts)
152
153 # The per-way CC_OPTS
154 ifneq "$$(findstring debug, $1)" ""
155 rts_dist_$1_HC_OPTS += -O0
156 rts_dist_$1_CC_OPTS += -fno-omit-frame-pointer -g -O0
157 endif
158
159 ifneq "$$(findstring dyn, $1)" ""
160 ifeq "$$(TargetOS_CPP)" "mingw32"
161 rts_dist_$1_CC_OPTS += -DCOMPILING_WINDOWS_DLL
162 endif
163 rts_dist_$1_CC_OPTS += -DDYNAMIC
164 endif
165
166
167 $(call distdir-way-opts,rts,dist,$1,1) # 1 because the rts is built with stage1
168 $(call c-suffix-rules,rts,dist,$1,YES)
169 $(call cmm-suffix-rules,rts,dist,$1)
170
171 rts_$1_LIB_FILE = libHSrts$$($1_libsuf)
172 rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_FILE)
173
174 rts_$1_C_OBJS = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS))
175 rts_$1_S_OBJS = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS))
176 rts_$1_CMM_OBJS = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_SRCS)) $$(patsubst %.cmm,%.$$($1_osuf),$$(rts_AUTO_APPLY_CMM))
177
178 rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS)
179
180 ifeq "$(USE_DTRACE)" "YES"
181 ifeq "$(NEED_DTRACE_PROBES_OBJ)" "YES"
182 # On Darwin we don't need to generate binary containing probes defined
183 # in DTrace script, but DTrace on Solaris expects generation of binary
184 # from the DTrace probes definitions
185 rts_$1_DTRACE_OBJS = rts/dist/build/RtsProbes.$$($1_osuf)
186
187 $$(rts_$1_DTRACE_OBJS) : $$(rts_$1_OBJS)
188 $(DTRACE) -G -C $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) -DDTRACE -s rts/RtsProbes.d -o \
189 $$@ $$(rts_$1_OBJS)
190 endif
191 endif
192
193 rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
194
195 # If we're compiling on windows, enforce that we only support XP+
196 # Adding this here means it doesn't have to be done in individual .c files
197 # and also centralizes the versioning.
198 ifeq "$$(TargetOS_CPP)" "mingw32"
199 rts_dist_$1_CC_OPTS += -DWINVER=$(rts_WINVER)
200 endif
201
202 ifneq "$$(UseSystemLibFFI)" "YES"
203 rts_dist_FFI_SO = rts/dist/build/lib$$(LIBFFI_NAME)$$(soext)
204 else
205 rts_dist_FFI_SO =
206 endif
207
208 # Making a shared library for the RTS.
209 ifneq "$$(findstring dyn, $1)" ""
210 ifeq "$$(TargetOS_CPP)" "mingw32"
211 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/dist/libs.depend rts/dist/build/$$(LIBFFI_DLL)
212 "$$(RM)" $$(RM_OPTS) $$@
213 # Call out to the shell script to decide how to build the dll.
214 # Making a shared library for the RTS.
215 # $$1 = dir
216 # $$2 = distdir
217 # $$3 = way
218 # $$4 = extra flags
219 # $$5 = extra libraries to link
220 # $$6 = object files to link
221 # $$7 = output filename
222 # $$8 = link command
223 # $$9 = create delay load import lib
224 # $$10 = SxS Name
225 # $$11 = SxS Version
226 $$(gen-dll_INPLACE) link "rts/dist/build" "rts/dist/build" "" "" "$$(ALL_RTS_DEF_LIBS)" "$$(rts_$1_OBJS)" "$$@" "$$(rts_dist_HC) -this-unit-id rts -no-hs-main -shared -dynamic -dynload deploy \
227 -no-auto-link-packages -Lrts/dist/build -l$$(LIBFFI_NAME) \
228 `cat rts/dist/libs.depend | tr '\n' ' '` \
229 $$(rts_dist_$1_GHC_LD_OPTS)" "NO" \
230 "$(rts_INSTALL_INFO)-$(subst dyn,,$(subst _dyn,,$(subst v,,$1)))" "$(ProjectVersion)"
231
232 else
233 ifneq "$$(UseSystemLibFFI)" "YES"
234 LIBFFI_LIBS = -Lrts/dist/build -l$$(LIBFFI_NAME)
235 ifeq "$$(TargetElf)" "YES"
236 LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,'$$$$ORIGIN' -optl-Wl,-zorigin
237 endif
238 ifeq "$(TargetOS_CPP)" "darwin"
239 LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,@loader_path
240 endif
241
242 else
243 # flags will be taken care of in rts/dist/libs.depend
244 LIBFFI_LIBS =
245 endif
246 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/dist/libs.depend $$(rts_dist_FFI_SO)
247 "$$(RM)" $$(RM_OPTS) $$@
248 "$$(rts_dist_HC)" -this-unit-id rts -shared -dynamic -dynload deploy \
249 -no-auto-link-packages $$(LIBFFI_LIBS) `cat rts/dist/libs.depend` $$(rts_$1_OBJS) \
250 $$(rts_dist_$1_GHC_LD_OPTS) \
251 $$(rts_$1_DTRACE_OBJS) -o $$@
252 endif
253 else
254
255 ifeq "$(USE_DTRACE)" "YES"
256 ifeq "$(NEED_DTRACE_PROBES_OBJ)" "YES"
257 rts_$1_LINKED_OBJS = rts/dist/build/RTS.$$($1_osuf)
258
259 $$(rts_$1_LINKED_OBJS) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
260 "$$(RM)" $$(RM_OPTS) $$@
261
262 # When linking an archive the linker will only include the object files that
263 # are actually needed during linking. It therefore does not include the dtrace
264 # specific code for initializing the probes. By creating a single object that
265 # also includes the probe object code we force the linker to include the
266 # probes when linking the static runtime.
267 $(LD) -r -o $$(rts_$1_LINKED_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_$1_OBJS)
268 else
269 rts_$1_LINKED_OBJS = $$(rts_$1_OBJS)
270 endif
271 else
272 rts_$1_LINKED_OBJS = $$(rts_$1_OBJS)
273 endif
274
275
276 $$(rts_$1_LIB) : $$(rts_$1_LINKED_OBJS)
277 "$$(RM)" $$(RM_OPTS) $$@
278
279 echo $$(rts_$1_LINKED_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
280 $$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
281
282 ifneq "$$(UseSystemLibFFI)" "YES"
283 $$(rts_$1_LIB) : rts/dist/build/libC$$(LIBFFI_NAME)$$($1_libsuf)
284 rts/dist/build/libC$$(LIBFFI_NAME)$$($1_libsuf): libffi/build/inst/lib/libffi.a
285 cp $$< $$@
286 endif
287
288 endif
289
290 endif
291
292 endef
293
294 # And expand the above for each way:
295 $(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way))))
296
297 $(eval $(call distdir-opts,rts,dist,1))
298
299 #-----------------------------------------------------------------------------
300 # Flags for compiling every file
301
302 # We like plenty of warnings.
303 WARNING_OPTS += -Wall
304 ifeq "$(GccLT34)" "YES"
305 WARNING_OPTS += -W
306 else
307 WARNING_OPTS += -Wextra
308 endif
309 WARNING_OPTS += -Wstrict-prototypes
310 WARNING_OPTS += -Wmissing-prototypes
311 WARNING_OPTS += -Wmissing-declarations
312 WARNING_OPTS += -Winline
313 WARNING_OPTS += -Waggregate-return
314 WARNING_OPTS += -Wpointer-arith
315 WARNING_OPTS += -Wmissing-noreturn
316 WARNING_OPTS += -Wnested-externs
317 WARNING_OPTS += -Wredundant-decls
318 ifeq "$(GccLT46)" "NO"
319 WARNING_OPTS += -Wundef
320 endif
321
322 # These ones are hard to avoid:
323 #WARNING_OPTS += -Wconversion
324 #WARNING_OPTS += -Wbad-function-cast
325 #WARNING_OPTS += -Wshadow
326 #WARNING_OPTS += -Wcast-qual
327
328 # This one seems buggy on GCC 4.1.2, which is the only GCC version we
329 # have that can bootstrap the SPARC build. We end up with lots of supurious
330 # warnings of the form "cast increases required alignment of target type".
331 # Some legitimate warnings can be fixed by adding an intermediate cast to
332 # (void*), but we get others in rts/sm/GCUtils.c concerning the gct var
333 # that look innocuous to me. We could enable this again once we deprecate
334 # support for registerised builds on this arch. -- BL 2010/02/03
335 # WARNING_OPTS += -Wcast-align
336
337 STANDARD_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) -Irts -Irts/dist/build
338 # COMPILING_RTS is only used when building Win32 DLL support.
339 STANDARD_OPTS += -DCOMPILING_RTS
340
341 # HC_OPTS is included in both .c and .cmm compilations, whereas CC_OPTS is
342 # only included in .c compilations. HC_OPTS included the WAY_* opts, which
343 # must be included in both types of compilations.
344
345 rts_CC_OPTS += $(WARNING_OPTS)
346 rts_CC_OPTS += $(STANDARD_OPTS)
347
348 rts_HC_OPTS += $(STANDARD_OPTS) -this-unit-id rts
349
350 ifneq "$(GhcWithSMP)" "YES"
351 rts_CC_OPTS += -DNOSMP
352 rts_HC_OPTS += -optc-DNOSMP
353 endif
354
355 ifeq "$(UseLibFFIForAdjustors)" "YES"
356 rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
357 endif
358
359 # We *want* type-checking of hand-written cmm.
360 rts_HC_OPTS += -dcmm-lint
361
362 # -fno-strict-aliasing is required for the runtime, because we often
363 # use a variety of types to represent closure pointers (StgPtr,
364 # StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is
365 # allowed to assume that these pointers do not alias. eg. without
366 # this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the
367 # upd_evacuee() assignments get moved before the object copy.
368 rts_CC_OPTS += -fno-strict-aliasing
369
370 rts_CC_OPTS += -fno-common
371
372 ifeq "$(BeConservative)" "YES"
373 rts_CC_OPTS += -DBE_CONSERVATIVE
374 endif
375
376 # Set Windows version
377 ifeq "$$(TargetOS_CPP)" "mingw32"
378 rts_CC_OPTS += -DWINVER=$(rts_WINVER)
379 endif
380
381 #-----------------------------------------------------------------------------
382 # Flags for compiling specific files
383 rts/RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
384 rts/RtsUtils_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
385 rts/Trace_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
386 #
387 rts/RtsUtils_CC_OPTS += -DHostPlatform=\"$(HOSTPLATFORM)\"
388 rts/RtsUtils_CC_OPTS += -DHostArch=\"$(HostArch_CPP)\"
389 rts/RtsUtils_CC_OPTS += -DHostOS=\"$(HostOS_CPP)\"
390 rts/RtsUtils_CC_OPTS += -DHostVendor=\"$(HostVendor_CPP)\"
391 #
392 rts/RtsUtils_CC_OPTS += -DBuildPlatform=\"$(BUILDPLATFORM)\"
393 rts/RtsUtils_CC_OPTS += -DBuildArch=\"$(BuildArch_CPP)\"
394 rts/RtsUtils_CC_OPTS += -DBuildOS=\"$(BuildOS_CPP)\"
395 rts/RtsUtils_CC_OPTS += -DBuildVendor=\"$(BuildVendor_CPP)\"
396 #
397 rts/RtsUtils_CC_OPTS += -DTargetPlatform=\"$(TARGETPLATFORM)\"
398 rts/RtsUtils_CC_OPTS += -DTargetArch=\"$(TargetArch_CPP)\"
399 rts/RtsUtils_CC_OPTS += -DTargetOS=\"$(TargetOS_CPP)\"
400 rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
401 #
402 rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
403 rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
404 #
405 rts/xxhash_CC_OPTS += -O3 -ffast-math -ftree-vectorize
406
407 # Compile various performance-critical pieces *without* -fPIC -dynamic
408 # even when building a shared library. If we don't do this, then the
409 # GC runs about 50% slower on x86 due to the overheads of PIC. The
410 # cost of doing this is a little runtime linking and less sharing, but
411 # not much.
412 #
413 # On x86_64 this doesn't work, because all objects in a shared library
414 # must be compiled with -fPIC (since the 32-bit relocations generated
415 # by the default small memory can't be resolved at runtime). So we
416 # only do this on i386.
417 #
418 # This apparently doesn't work on OS X (Darwin) nor on Solaris.
419 # On Darwin we get errors of the form
420 #
421 # ld: absolute addressing (perhaps -mdynamic-no-pic) used in _stg_ap_0_fast from rts/dist/build/Apply.dyn_o not allowed in slidable image
422 #
423 # and lots of these warnings:
424 #
425 # ld: warning codegen in _stg_ap_pppv_fast (offset 0x0000005E) prevents image from loading in dyld shared cache
426 #
427 # On Solaris we get errors like:
428 #
429 # Text relocation remains referenced
430 # against symbol offset in file
431 # .rodata (section) 0x11 rts/dist/build/Apply.dyn_o
432 # ...
433 # ld: fatal: relocations remain against allocatable but non-writable sections
434 # collect2: ld returned 1 exit status
435
436 ifeq "$(TargetArch_CPP)" "i386"
437 i386_SPEED_HACK := "YES"
438 ifeq "$(TargetOS_CPP)" "darwin"
439 i386_SPEED_HACK := "NO"
440 endif
441 ifeq "$(TargetOS_CPP)" "solaris2"
442 i386_SPEED_HACK := "NO"
443 endif
444 endif
445
446 ifeq "$(TargetArch_CPP)" "i386"
447 ifeq "$(i386_SPEED_HACK)" "YES"
448 rts/sm/Evac_HC_OPTS += -fno-PIC
449 rts/sm/Evac_thr_HC_OPTS += -fno-PIC
450 rts/sm/Scav_HC_OPTS += -fno-PIC
451 rts/sm/Scav_thr_HC_OPTS += -fno-PIC
452 rts/sm/Compact_HC_OPTS += -fno-PIC
453 rts/sm/GC_HC_OPTS += -fno-PIC
454
455 # -static is also necessary for these bits, otherwise the NCG
456 # -generates dynamic references:
457 rts/Updates_HC_OPTS += -fno-PIC -static
458 rts/StgMiscClosures_HC_OPTS += -fno-PIC -static
459 rts/PrimOps_HC_OPTS += -fno-PIC -static
460 rts/Apply_HC_OPTS += -fno-PIC -static
461 rts/dist/build/AutoApply_HC_OPTS += -fno-PIC -static
462 endif
463 endif
464
465 # add CFLAGS for libffi
466 # ffi.h triggers prototype warnings, so disable them here:
467 ifeq "$(UseSystemLibFFI)" "YES"
468 LIBFFI_CFLAGS = $(addprefix -I,$(FFIIncludeDir))
469 else
470 LIBFFI_CFLAGS =
471 endif
472 rts/Interpreter_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
473 rts/Adjustor_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
474 rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
475
476 # inlining warnings happen in Compact
477 rts/sm/Compact_CC_OPTS += -Wno-inline
478
479 # emits warnings about call-clobbered registers on x86_64
480 rts/StgCRun_CC_OPTS += -w
481
482 rts/RetainerProfile_CC_OPTS += -w
483 rts/RetainerSet_CC_OPTS += -Wno-format
484 # On Windows:
485 rts/win32/ConsoleHandler_CC_OPTS += -w
486 rts/win32/ThrIOManager_CC_OPTS += -w
487 # The above warning suppression flags are a temporary kludge.
488 # While working on this module you are encouraged to remove it and fix
489 # any warnings in the module. See
490 # http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
491 # for details
492
493 # Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0)
494 ifneq "$(CC_CLANG_BACKEND)" "1"
495 rts/sm/Compact_CC_OPTS += -finline-limit=2500
496 endif
497
498 # -O3 helps unroll some loops (especially in copy() with a constant argument).
499 rts/sm/Evac_CC_OPTS += -funroll-loops
500 rts/sm/Evac_thr_HC_OPTS += -optc-funroll-loops
501
502
503 #-----------------------------------------------------------------------------
504 # Use system provided libffi
505
506 ifeq "$(UseSystemLibFFI)" "YES"
507
508 rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir)
509 rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir)
510 rts_PACKAGE_CPP_OPTS += '-DFFI_LIB='
511
512 else # UseSystemLibFFI==YES
513
514 rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=
515 rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=
516 rts_PACKAGE_CPP_OPTS += '-DFFI_LIB="C$(LIBFFI_NAME)"'
517
518 endif
519
520 # -----------------------------------------------------------------------------
521 # dependencies
522
523 rts_WAYS_DASHED = $(subst $(space),,$(patsubst %,-%,$(strip $(rts_WAYS))))
524 rts_dist_depfile_base = rts/dist/build/.depend$(rts_WAYS_DASHED)
525
526 rts_dist_C_SRCS = $(rts_C_SRCS) $(rts_thr_EXTRA_C_SRCS)
527 rts_dist_S_SRCS = $(rts_S_SRCS)
528 rts_dist_CMM_SRCS = $(rts_CMM_SRCS)
529 rts_dist_C_FILES = $(rts_dist_C_SRCS)
530 rts_dist_S_FILES = $(rts_dist_S_SRCS)
531 rts_dist_CMM_FILES = $(rts_dist_CMM_SRCS)
532
533 # Hack: we define every way-related option here, so that we get (hopefully)
534 # a superset of the dependencies. To do this properly, we should generate
535 # a different set of dependencies for each way. Further hack: PROFILING an
536
537 # TICKY_TICKY can't be used together, so we omit TICKY_TICKY for now.
538 rts_dist_MKDEPENDC_OPTS += -DPROFILING -DTHREADED_RTS -DDEBUG
539
540 ifeq "$(USE_DTRACE)" "YES"
541
542 rts_dist_MKDEPENDC_OPTS += -Irts/dist/build
543
544 endif
545
546 $(eval $(call dependencies,rts,dist,1))
547
548 $(rts_dist_depfile_c_asm) : $(DTRACEPROBES_H)
549 ifneq "$(UseSystemLibFFI)" "YES"
550 $(rts_dist_depfile_c_asm) : $(libffi_HEADERS)
551 endif
552
553 # -----------------------------------------------------------------------------
554 # compile dtrace probes if dtrace is supported
555
556 ifeq "$(USE_DTRACE)" "YES"
557
558 rts_CC_OPTS += -DDTRACE
559 rts_HC_OPTS += -DDTRACE
560
561 # Apple's dtrace (the only one supported by ghc at the moment) uses
562 # gcc as its preprocessor. If gcc isn't at /usr/bin/gcc, or we need
563 # to force it to use a different gcc, we need to give the path in
564 # the option cpppath.
565
566 ifeq "$(TargetOS_CPP)" "darwin"
567 # Darwin has a flag to tell dtrace which cpp to use.
568 # Unfortunately, this isn't supported on Solaris (See Solaris Dynamic Tracing
569 # Guide, Chapter 16, for the configuration variables available on Solaris)
570 DTRACE_FLAGS = -x cpppath=$(CC)
571 endif
572
573 DTRACEPROBES_SRC = rts/RtsProbes.d
574 $(DTRACEPROBES_H): $(DTRACEPROBES_SRC) includes/ghcplatform.h | $$(dir $$@)/.
575 "$(DTRACE)" $(filter -I%,$(rts_CC_OPTS)) -C $(DTRACE_FLAGS) -h -o $@ -s $<
576 endif
577
578 # -----------------------------------------------------------------------------
579 # The RTS package config
580
581 # If -DDEBUG is in effect, adjust package conf accordingly..
582 ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" ""
583 rts_PACKAGE_CPP_OPTS += -DDEBUG
584 endif
585
586 ifeq "$(HaveLibMingwEx)" "YES"
587 rts_PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
588 endif
589
590 $(eval $(call manual-package-config,rts))
591
592 rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM)
593
594 # -----------------------------------------------------------------------------
595 # installing
596
597 RTS_INSTALL_LIBS += $(ALL_RTS_LIBS)
598 ifneq "$(UseSystemLibFFI)" "YES"
599 RTS_INSTALL_LIBS += $(wildcard rts/dist/build/lib$(LIBFFI_NAME)*$(soext)*)
600 RTS_INSTALL_LIBS += $(foreach w,$(filter-out %dyn,$(rts_WAYS)),rts/dist/build/libC$(LIBFFI_NAME)$($w_libsuf))
601 endif
602
603 ifneq "$(UseSystemLibFFI)" "YES"
604 install: install_libffi_headers
605 endif
606
607 .PHONY: install_libffi_headers
608 install_libffi_headers :
609 $(INSTALL_DIR) "$(DESTDIR)$(ghcheaderdir)"
610 $(INSTALL_HEADER) $(INSTALL_OPTS) $(libffi_HEADERS) "$(DESTDIR)$(ghcheaderdir)/"
611
612 # -----------------------------------------------------------------------------
613 # cleaning
614
615 $(eval $(call clean-target,rts,dist,rts/dist))
616
617 BINDIST_EXTRAS += rts/package.conf.in
618