UNREG: use __builtin___clear_cache where available
[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 # Building one way
139 define build-rts-way # args: $1 = way
140
141 ifneq "$$(BINDIST)" "YES"
142
143 rts_dist_$1_HC_OPTS := $$(GhcRtsHcOpts)
144 rts_dist_$1_CC_OPTS := $$(GhcRtsCcOpts)
145
146 # The per-way CC_OPTS
147 ifneq "$$(findstring debug, $1)" ""
148 rts_dist_$1_HC_OPTS += -O0
149 rts_dist_$1_CC_OPTS += -fno-omit-frame-pointer -g -O0
150 endif
151
152 ifneq "$$(findstring dyn, $1)" ""
153 ifeq "$$(TargetOS_CPP)" "mingw32"
154 rts_dist_$1_CC_OPTS += -DCOMPILING_WINDOWS_DLL
155 endif
156 rts_dist_$1_CC_OPTS += -DDYNAMIC
157 endif
158
159
160 $(call distdir-way-opts,rts,dist,$1,1) # 1 because the rts is built with stage1
161 $(call c-suffix-rules,rts,dist,$1,YES)
162 $(call cmm-suffix-rules,rts,dist,$1)
163
164 rts_$1_LIB_FILE = libHSrts$$($1_libsuf)
165 rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_FILE)
166
167 rts_$1_C_OBJS = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS))
168 rts_$1_S_OBJS = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS))
169 rts_$1_CMM_OBJS = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_SRCS)) $$(patsubst %.cmm,%.$$($1_osuf),$$(rts_AUTO_APPLY_CMM))
170
171 rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS)
172
173 ifeq "$(USE_DTRACE)" "YES"
174 ifeq "$(TargetOS_CPP)" "solaris2"
175 # On Darwin we don't need to generate binary containing probes defined
176 # in DTrace script, but DTrace on Solaris expects generation of binary
177 # from the DTrace probes definitions
178 rts_$1_DTRACE_OBJS = rts/dist/build/RtsProbes.$$($1_osuf)
179
180 rts/dist/build/RtsProbes.$$($1_osuf) : $$(rts_$1_OBJS)
181 $(DTRACE) -G -C $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) -DDTRACE -s rts/RtsProbes.d -o \
182 $$@ $$(rts_$1_OBJS)
183 endif
184 endif
185
186 rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
187
188 # If we're compiling on windows, enforce that we only support XP+
189 # Adding this here means it doesn't have to be done in individual .c files
190 # and also centralizes the versioning.
191 ifeq "$$(TargetOS_CPP)" "mingw32"
192 rts_dist_$1_CC_OPTS += -DWINVER=$(rts_WINVER)
193 endif
194
195 ifneq "$$(UseSystemLibFFI)" "YES"
196 rts_dist_FFI_SO = rts/dist/build/lib$$(LIBFFI_NAME)$$(soext)
197 else
198 rts_dist_FFI_SO =
199 endif
200
201 # Making a shared library for the RTS.
202 ifneq "$$(findstring dyn, $1)" ""
203 ifeq "$$(TargetOS_CPP)" "mingw32"
204 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/dist/libs.depend rts/dist/build/$$(LIBFFI_DLL)
205 "$$(RM)" $$(RM_OPTS) $$@
206 "$$(rts_dist_HC)" -this-unit-id rts -shared -dynamic -dynload deploy \
207 -no-auto-link-packages -Lrts/dist/build -l$$(LIBFFI_NAME) \
208 `cat rts/dist/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) \
209 $$(rts_dist_$1_GHC_LD_OPTS) \
210 -o $$@
211 else
212 ifneq "$$(UseSystemLibFFI)" "YES"
213 LIBFFI_LIBS = -Lrts/dist/build -l$$(LIBFFI_NAME)
214 ifeq "$$(TargetElf)" "YES"
215 LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,'$$$$ORIGIN' -optl-Wl,-zorigin
216 endif
217 ifeq "$(TargetOS_CPP)" "darwin"
218 LIBFFI_LIBS += -optl-Wl,-rpath -optl-Wl,@loader_path
219 endif
220
221 else
222 # flags will be taken care of in rts/dist/libs.depend
223 LIBFFI_LIBS =
224 endif
225 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/dist/libs.depend $$(rts_dist_FFI_SO)
226 "$$(RM)" $$(RM_OPTS) $$@
227 "$$(rts_dist_HC)" -this-unit-id rts -shared -dynamic -dynload deploy \
228 -no-auto-link-packages $$(LIBFFI_LIBS) `cat rts/dist/libs.depend` $$(rts_$1_OBJS) \
229 $$(rts_dist_$1_GHC_LD_OPTS) \
230 $$(rts_$1_DTRACE_OBJS) -o $$@
231 endif
232 else
233 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS)
234 "$$(RM)" $$(RM_OPTS) $$@
235 echo $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \
236 $$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@
237
238 ifneq "$$(UseSystemLibFFI)" "YES"
239 $$(rts_$1_LIB) : rts/dist/build/libC$$(LIBFFI_NAME)$$($1_libsuf)
240 rts/dist/build/libC$$(LIBFFI_NAME)$$($1_libsuf): libffi/build/inst/lib/libffi.a
241 cp $$< $$@
242 endif
243
244 endif
245
246 endif
247
248 endef
249
250 # And expand the above for each way:
251 $(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way))))
252
253 $(eval $(call distdir-opts,rts,dist,1))
254
255 #-----------------------------------------------------------------------------
256 # Flags for compiling every file
257
258 # We like plenty of warnings.
259 WARNING_OPTS += -Wall
260 ifeq "$(GccLT34)" "YES"
261 WARNING_OPTS += -W
262 else
263 WARNING_OPTS += -Wextra
264 endif
265 WARNING_OPTS += -Wstrict-prototypes
266 WARNING_OPTS += -Wmissing-prototypes
267 WARNING_OPTS += -Wmissing-declarations
268 WARNING_OPTS += -Winline
269 WARNING_OPTS += -Waggregate-return
270 WARNING_OPTS += -Wpointer-arith
271 WARNING_OPTS += -Wmissing-noreturn
272 WARNING_OPTS += -Wnested-externs
273 WARNING_OPTS += -Wredundant-decls
274 ifeq "$(GccLT46)" "NO"
275 WARNING_OPTS += -Wundef
276 endif
277
278 # These ones are hard to avoid:
279 #WARNING_OPTS += -Wconversion
280 #WARNING_OPTS += -Wbad-function-cast
281 #WARNING_OPTS += -Wshadow
282 #WARNING_OPTS += -Wcast-qual
283
284 # This one seems buggy on GCC 4.1.2, which is the only GCC version we
285 # have that can bootstrap the SPARC build. We end up with lots of supurious
286 # warnings of the form "cast increases required alignment of target type".
287 # Some legitimate warnings can be fixed by adding an intermediate cast to
288 # (void*), but we get others in rts/sm/GCUtils.c concerning the gct var
289 # that look innocuous to me. We could enable this again once we deprecate
290 # support for registerised builds on this arch. -- BL 2010/02/03
291 # WARNING_OPTS += -Wcast-align
292
293 STANDARD_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) -Irts -Irts/dist/build
294 # COMPILING_RTS is only used when building Win32 DLL support.
295 STANDARD_OPTS += -DCOMPILING_RTS
296
297 # HC_OPTS is included in both .c and .cmm compilations, whereas CC_OPTS is
298 # only included in .c compilations. HC_OPTS included the WAY_* opts, which
299 # must be included in both types of compilations.
300
301 rts_CC_OPTS += $(WARNING_OPTS)
302 rts_CC_OPTS += $(STANDARD_OPTS)
303
304 rts_HC_OPTS += $(STANDARD_OPTS) -this-unit-id rts
305
306 ifneq "$(GhcWithSMP)" "YES"
307 rts_CC_OPTS += -DNOSMP
308 rts_HC_OPTS += -optc-DNOSMP
309 endif
310
311 ifeq "$(UseLibFFIForAdjustors)" "YES"
312 rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS
313 endif
314
315 # We *want* type-checking of hand-written cmm.
316 rts_HC_OPTS += -dcmm-lint
317
318 # -fno-strict-aliasing is required for the runtime, because we often
319 # use a variety of types to represent closure pointers (StgPtr,
320 # StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is
321 # allowed to assume that these pointers do not alias. eg. without
322 # this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the
323 # upd_evacuee() assignments get moved before the object copy.
324 rts_CC_OPTS += -fno-strict-aliasing
325
326 rts_CC_OPTS += -fno-common
327
328 ifeq "$(BeConservative)" "YES"
329 rts_CC_OPTS += -DBE_CONSERVATIVE
330 endif
331
332 # Set Windows version
333 ifeq "$$(TargetOS_CPP)" "mingw32"
334 rts_CC_OPTS += -DWINVER=$(rts_WINVER)
335 endif
336
337 #-----------------------------------------------------------------------------
338 # Flags for compiling specific files
339 rts/RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
340 rts/RtsUtils_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
341 rts/Trace_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\"
342 #
343 rts/RtsUtils_CC_OPTS += -DHostPlatform=\"$(HOSTPLATFORM)\"
344 rts/RtsUtils_CC_OPTS += -DHostArch=\"$(HostArch_CPP)\"
345 rts/RtsUtils_CC_OPTS += -DHostOS=\"$(HostOS_CPP)\"
346 rts/RtsUtils_CC_OPTS += -DHostVendor=\"$(HostVendor_CPP)\"
347 #
348 rts/RtsUtils_CC_OPTS += -DBuildPlatform=\"$(BUILDPLATFORM)\"
349 rts/RtsUtils_CC_OPTS += -DBuildArch=\"$(BuildArch_CPP)\"
350 rts/RtsUtils_CC_OPTS += -DBuildOS=\"$(BuildOS_CPP)\"
351 rts/RtsUtils_CC_OPTS += -DBuildVendor=\"$(BuildVendor_CPP)\"
352 #
353 rts/RtsUtils_CC_OPTS += -DTargetPlatform=\"$(TARGETPLATFORM)\"
354 rts/RtsUtils_CC_OPTS += -DTargetArch=\"$(TargetArch_CPP)\"
355 rts/RtsUtils_CC_OPTS += -DTargetOS=\"$(TargetOS_CPP)\"
356 rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\"
357 #
358 rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\"
359 rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\"
360
361 # Compile various performance-critical pieces *without* -fPIC -dynamic
362 # even when building a shared library. If we don't do this, then the
363 # GC runs about 50% slower on x86 due to the overheads of PIC. The
364 # cost of doing this is a little runtime linking and less sharing, but
365 # not much.
366 #
367 # On x86_64 this doesn't work, because all objects in a shared library
368 # must be compiled with -fPIC (since the 32-bit relocations generated
369 # by the default small memory can't be resolved at runtime). So we
370 # only do this on i386.
371 #
372 # This apparently doesn't work on OS X (Darwin) nor on Solaris.
373 # On Darwin we get errors of the form
374 #
375 # 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
376 #
377 # and lots of these warnings:
378 #
379 # ld: warning codegen in _stg_ap_pppv_fast (offset 0x0000005E) prevents image from loading in dyld shared cache
380 #
381 # On Solaris we get errors like:
382 #
383 # Text relocation remains referenced
384 # against symbol offset in file
385 # .rodata (section) 0x11 rts/dist/build/Apply.dyn_o
386 # ...
387 # ld: fatal: relocations remain against allocatable but non-writable sections
388 # collect2: ld returned 1 exit status
389
390 ifeq "$(TargetArch_CPP)" "i386"
391 i386_SPEED_HACK := "YES"
392 ifeq "$(TargetOS_CPP)" "darwin"
393 i386_SPEED_HACK := "NO"
394 endif
395 ifeq "$(TargetOS_CPP)" "solaris2"
396 i386_SPEED_HACK := "NO"
397 endif
398 endif
399
400 ifeq "$(TargetArch_CPP)" "i386"
401 ifeq "$(i386_SPEED_HACK)" "YES"
402 rts/sm/Evac_HC_OPTS += -fno-PIC
403 rts/sm/Evac_thr_HC_OPTS += -fno-PIC
404 rts/sm/Scav_HC_OPTS += -fno-PIC
405 rts/sm/Scav_thr_HC_OPTS += -fno-PIC
406 rts/sm/Compact_HC_OPTS += -fno-PIC
407 rts/sm/GC_HC_OPTS += -fno-PIC
408
409 # -static is also necessary for these bits, otherwise the NCG
410 # -generates dynamic references:
411 rts/Updates_HC_OPTS += -fno-PIC -static
412 rts/StgMiscClosures_HC_OPTS += -fno-PIC -static
413 rts/PrimOps_HC_OPTS += -fno-PIC -static
414 rts/Apply_HC_OPTS += -fno-PIC -static
415 rts/dist/build/AutoApply_HC_OPTS += -fno-PIC -static
416 endif
417 endif
418
419 # add CFLAGS for libffi
420 # ffi.h triggers prototype warnings, so disable them here:
421 ifeq "$(UseSystemLibFFI)" "YES"
422 LIBFFI_CFLAGS = $(addprefix -I,$(FFIIncludeDir))
423 else
424 LIBFFI_CFLAGS =
425 endif
426 rts/Interpreter_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
427 rts/Adjustor_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
428 rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes $(LIBFFI_CFLAGS)
429
430 # inlining warnings happen in Compact
431 rts/sm/Compact_CC_OPTS += -Wno-inline
432
433 # emits warnings about call-clobbered registers on x86_64
434 rts/StgCRun_CC_OPTS += -w
435
436 rts/RetainerProfile_CC_OPTS += -w
437 rts/RetainerSet_CC_OPTS += -Wno-format
438 # On Windows:
439 rts/win32/ConsoleHandler_CC_OPTS += -w
440 rts/win32/ThrIOManager_CC_OPTS += -w
441 # The above warning suppression flags are a temporary kludge.
442 # While working on this module you are encouraged to remove it and fix
443 # any warnings in the module. See
444 # http://ghc.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings
445 # for details
446
447 # Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0)
448 ifneq "$(CC_CLANG_BACKEND)" "1"
449 rts/sm/Compact_CC_OPTS += -finline-limit=2500
450 endif
451
452 # -O3 helps unroll some loops (especially in copy() with a constant argument).
453 rts/sm/Evac_CC_OPTS += -funroll-loops
454 rts/sm/Evac_thr_HC_OPTS += -optc-funroll-loops
455
456
457 #-----------------------------------------------------------------------------
458 # Use system provided libffi
459
460 ifeq "$(UseSystemLibFFI)" "YES"
461
462 rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=$(FFIIncludeDir)
463 rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=$(FFILibDir)
464 rts_PACKAGE_CPP_OPTS += '-DFFI_LIB='
465
466 else # UseSystemLibFFI==YES
467
468 rts_PACKAGE_CPP_OPTS += -DFFI_INCLUDE_DIR=
469 rts_PACKAGE_CPP_OPTS += -DFFI_LIB_DIR=
470 rts_PACKAGE_CPP_OPTS += '-DFFI_LIB="C$(LIBFFI_NAME)"'
471
472 endif
473
474 # -----------------------------------------------------------------------------
475 # dependencies
476
477 rts_WAYS_DASHED = $(subst $(space),,$(patsubst %,-%,$(strip $(rts_WAYS))))
478 rts_dist_depfile_base = rts/dist/build/.depend$(rts_WAYS_DASHED)
479
480 rts_dist_C_SRCS = $(rts_C_SRCS) $(rts_thr_EXTRA_C_SRCS)
481 rts_dist_S_SRCS = $(rts_S_SRCS)
482 rts_dist_CMM_SRCS = $(rts_CMM_SRCS)
483 rts_dist_C_FILES = $(rts_dist_C_SRCS)
484 rts_dist_S_FILES = $(rts_dist_S_SRCS)
485 rts_dist_CMM_FILES = $(rts_dist_CMM_SRCS)
486
487 # Hack: we define every way-related option here, so that we get (hopefully)
488 # a superset of the dependencies. To do this properly, we should generate
489 # a different set of dependencies for each way. Further hack: PROFILING an
490
491 # TICKY_TICKY can't be used together, so we omit TICKY_TICKY for now.
492 rts_dist_MKDEPENDC_OPTS += -DPROFILING -DTHREADED_RTS -DDEBUG
493
494 ifeq "$(USE_DTRACE)" "YES"
495
496 rts_dist_MKDEPENDC_OPTS += -Irts/dist/build
497
498 endif
499
500 $(eval $(call dependencies,rts,dist,1))
501
502 $(rts_dist_depfile_c_asm) : $(DTRACEPROBES_H)
503 ifneq "$(UseSystemLibFFI)" "YES"
504 $(rts_dist_depfile_c_asm) : $(libffi_HEADERS)
505 endif
506
507 # -----------------------------------------------------------------------------
508 # compile dtrace probes if dtrace is supported
509
510 ifeq "$(USE_DTRACE)" "YES"
511
512 rts_CC_OPTS += -DDTRACE
513 rts_HC_OPTS += -DDTRACE
514
515 # Apple's dtrace (the only one supported by ghc at the moment) uses
516 # gcc as its preprocessor. If gcc isn't at /usr/bin/gcc, or we need
517 # to force it to use a different gcc, we need to give the path in
518 # the option cpppath.
519
520 ifeq "$(TargetOS_CPP)" "darwin"
521 # Darwin has a flag to tell dtrace which cpp to use.
522 # Unfortunately, this isn't supported on Solaris (See Solaris Dynamic Tracing
523 # Guide, Chapter 16, for the configuration variables available on Solaris)
524 DTRACE_FLAGS = -x cpppath=$(CC)
525 endif
526
527 DTRACEPROBES_SRC = rts/RtsProbes.d
528 $(DTRACEPROBES_H): $(DTRACEPROBES_SRC) includes/ghcplatform.h | $$(dir $$@)/.
529 "$(DTRACE)" $(filter -I%,$(rts_CC_OPTS)) -C $(DTRACE_FLAGS) -h -o $@ -s $<
530 endif
531
532 # -----------------------------------------------------------------------------
533 # The RTS package config
534
535 # If -DDEBUG is in effect, adjust package conf accordingly..
536 ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" ""
537 rts_PACKAGE_CPP_OPTS += -DDEBUG
538 endif
539
540 ifeq "$(HaveLibMingwEx)" "YES"
541 rts_PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX
542 endif
543
544 $(eval $(call manual-package-config,rts))
545
546 rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM)
547
548 # -----------------------------------------------------------------------------
549 # installing
550
551 RTS_INSTALL_LIBS += $(ALL_RTS_LIBS)
552 ifneq "$(UseSystemLibFFI)" "YES"
553 RTS_INSTALL_LIBS += $(wildcard rts/dist/build/lib$(LIBFFI_NAME)*$(soext)*)
554 RTS_INSTALL_LIBS += $(foreach w,$(filter-out %dyn,$(rts_WAYS)),rts/dist/build/libC$(LIBFFI_NAME)$($w_libsuf))
555 endif
556
557 ifneq "$(UseSystemLibFFI)" "YES"
558 install: install_libffi_headers
559 endif
560
561 .PHONY: install_libffi_headers
562 install_libffi_headers :
563 $(INSTALL_DIR) "$(DESTDIR)$(ghcheaderdir)"
564 $(INSTALL_HEADER) $(INSTALL_OPTS) $(libffi_HEADERS) "$(DESTDIR)$(ghcheaderdir)/"
565
566 # -----------------------------------------------------------------------------
567 # cleaning
568
569 $(eval $(call clean-target,rts,dist,rts/dist))
570
571 BINDIST_EXTRAS += rts/package.conf.in
572