| 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://hackage.haskell.org/trac/ghc/wiki/Building/Architecture |
|---|
| 9 | # http://hackage.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 | # merge GhcLibWays and GhcRTSWays but strip out duplicates |
|---|
| 20 | rts_WAYS = $(GhcLibWays) $(filter-out $(GhcLibWays),$(GhcRTSWays)) |
|---|
| 21 | rts_dist_WAYS = $(rts_WAYS) |
|---|
| 22 | |
|---|
| 23 | ALL_RTS_LIBS = $(foreach way,$(rts_WAYS),rts/dist/build/libHSrts$($(way)_libsuf)) |
|---|
| 24 | all_rts : $(ALL_RTS_LIBS) |
|---|
| 25 | |
|---|
| 26 | # ----------------------------------------------------------------------------- |
|---|
| 27 | # Defining the sources |
|---|
| 28 | |
|---|
| 29 | ALL_DIRS = hooks parallel sm eventlog |
|---|
| 30 | |
|---|
| 31 | ifeq "$(HostOS_CPP)" "mingw32" |
|---|
| 32 | ALL_DIRS += win32 |
|---|
| 33 | else |
|---|
| 34 | ALL_DIRS += posix |
|---|
| 35 | endif |
|---|
| 36 | |
|---|
| 37 | EXCLUDED_SRCS := |
|---|
| 38 | EXCLUDED_SRCS += rts/parallel/SysMan.c |
|---|
| 39 | EXCLUDED_SRCS += $(wildcard rts/Vis*.c) |
|---|
| 40 | |
|---|
| 41 | rts_C_SRCS := $(filter-out $(EXCLUDED_SRCS),$(wildcard rts/*.c $(foreach dir,$(ALL_DIRS),rts/$(dir)/*.c))) |
|---|
| 42 | rts_CMM_SRCS := $(wildcard rts/*.cmm) |
|---|
| 43 | |
|---|
| 44 | # Don't compile .S files when bootstrapping a new arch |
|---|
| 45 | ifneq "$(PORTING_HOST)" "YES" |
|---|
| 46 | ifneq "$(findstring $(TargetArch_CPP), i386 powerpc powerpc64)" "" |
|---|
| 47 | rts_S_SRCS += rts/AdjustorAsm.S |
|---|
| 48 | endif |
|---|
| 49 | endif |
|---|
| 50 | |
|---|
| 51 | ifeq "$(GhcUnregisterised)" "YES" |
|---|
| 52 | GENAPPLY_OPTS = -u |
|---|
| 53 | endif |
|---|
| 54 | |
|---|
| 55 | rts_AUTO_APPLY_CMM = rts/dist/build/AutoApply.cmm |
|---|
| 56 | |
|---|
| 57 | $(rts_AUTO_APPLY_CMM): $(GENAPPLY_INPLACE) |
|---|
| 58 | "$(GENAPPLY_INPLACE)" >$@ |
|---|
| 59 | |
|---|
| 60 | rts/dist/build/sm/Evac_thr.c : rts/sm/Evac.c | $$(dir $$@)/. |
|---|
| 61 | cp $< $@ |
|---|
| 62 | rts/dist/build/sm/Scav_thr.c : rts/sm/Scav.c | $$(dir $$@)/. |
|---|
| 63 | cp $< $@ |
|---|
| 64 | |
|---|
| 65 | rts_H_FILES := $(wildcard rts/*.h rts/*/*.h) |
|---|
| 66 | |
|---|
| 67 | ifeq "$(USE_DTRACE)" "YES" |
|---|
| 68 | DTRACEPROBES_H = rts/dist/build/RtsProbes.h |
|---|
| 69 | rts_H_FILES += $(DTRACEPROBES_H) |
|---|
| 70 | endif |
|---|
| 71 | |
|---|
| 72 | # collect the -l flags that we need to link the rts dyn lib. |
|---|
| 73 | rts/libs.depend : $(GHC_PKG_INPLACE) |
|---|
| 74 | "$(GHC_PKG_INPLACE)" field rts extra-libraries \ |
|---|
| 75 | | sed -e 's/^extra-libraries: //' -e 's/\([a-z0-9]*\)[ ]*/-l\1 /g' > $@ |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | # ---------------------------------------------------------------------------- |
|---|
| 79 | # On Windows, as the RTS and base libraries have recursive imports, |
|---|
| 80 | # we have to break the loop with "import libraries". |
|---|
| 81 | # These are made from rts/win32/libHS*.def which contain lists of |
|---|
| 82 | # all the symbols in those libraries used by the RTS. |
|---|
| 83 | # |
|---|
| 84 | ifeq "$(HostOS_CPP)" "mingw32" |
|---|
| 85 | |
|---|
| 86 | ALL_RTS_DEF_LIBNAMES = base ghc-prim |
|---|
| 87 | ALL_RTS_DEF_LIBS = \ |
|---|
| 88 | rts/dist/build/win32/libHSbase.dll.a \ |
|---|
| 89 | rts/dist/build/win32/libHSghc-prim.dll.a |
|---|
| 90 | |
|---|
| 91 | # -- import libs for the regular Haskell libraries |
|---|
| 92 | define make-importlib-def # args $1 = lib name |
|---|
| 93 | rts/dist/build/win32/libHS$1.def : rts/win32/libHS$1.def |
|---|
| 94 | cat rts/win32/libHS$1.def \ |
|---|
| 95 | | sed "s/@LibVersion@/$$(libraries/$1_dist-install_VERSION)/" \ |
|---|
| 96 | | sed "s/@ProjectVersion@/$$(ProjectVersion)/" \ |
|---|
| 97 | > rts/dist/build/win32/libHS$1.def |
|---|
| 98 | |
|---|
| 99 | rts/dist/build/win32/libHS$1.dll.a : rts/dist/build/win32/libHS$1.def |
|---|
| 100 | "$$(DLLTOOL)" -d rts/dist/build/win32/libHS$1.def \ |
|---|
| 101 | -l rts/dist/build/win32/libHS$1.dll.a |
|---|
| 102 | endef |
|---|
| 103 | $(foreach lib,$(ALL_RTS_DEF_LIBNAMES),$(eval $(call make-importlib-def,$(lib)))) |
|---|
| 104 | endif |
|---|
| 105 | |
|---|
| 106 | ifneq "$(BINDIST)" "YES" |
|---|
| 107 | rts_ffi_objs_stamp = rts/dist/ffi/stamp |
|---|
| 108 | rts_ffi_objs = rts/dist/ffi/*.o |
|---|
| 109 | $(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) $(TOUCH_DEP) | $$(dir $$@)/. |
|---|
| 110 | cd rts/dist/ffi && $(AR) x ../../../$(libffi_STATIC_LIB) |
|---|
| 111 | "$(TOUCH_CMD)" $@ |
|---|
| 112 | |
|---|
| 113 | # This is a little hacky. We don't know the SO version, so we only |
|---|
| 114 | # depend on libffi.so, but copy libffi.so* |
|---|
| 115 | rts/dist/build/libffi$(soext): libffi/build/inst/lib/libffi$(soext) |
|---|
| 116 | cp libffi/build/inst/lib/libffi$(soext)* rts/dist/build |
|---|
| 117 | |
|---|
| 118 | rts/dist/build/$(LIBFFI_DLL): libffi/build/inst/bin/$(LIBFFI_DLL) |
|---|
| 119 | cp $< $@ |
|---|
| 120 | endif |
|---|
| 121 | |
|---|
| 122 | #----------------------------------------------------------------------------- |
|---|
| 123 | # Building one way |
|---|
| 124 | define build-rts-way # args: $1 = way |
|---|
| 125 | |
|---|
| 126 | ifneq "$$(BINDIST)" "YES" |
|---|
| 127 | |
|---|
| 128 | # The per-way CC_OPTS |
|---|
| 129 | ifneq "$$(findstring debug, $1)" "" |
|---|
| 130 | rts_dist_$1_HC_OPTS = |
|---|
| 131 | rts_dist_$1_CC_OPTS = -g -O0 |
|---|
| 132 | else |
|---|
| 133 | rts_dist_$1_HC_OPTS = $$(GhcRtsHcOpts) |
|---|
| 134 | rts_dist_$1_CC_OPTS = $$(GhcRtsCcOpts) |
|---|
| 135 | endif |
|---|
| 136 | |
|---|
| 137 | ifneq "$$(findstring dyn, $1)" "" |
|---|
| 138 | ifeq "$$(HostOS_CPP)" "mingw32" |
|---|
| 139 | rts_dist_$1_CC_OPTS += -DCOMPILING_WINDOWS_DLL |
|---|
| 140 | endif |
|---|
| 141 | endif |
|---|
| 142 | |
|---|
| 143 | ifneq "$$(findstring thr, $1)" "" |
|---|
| 144 | rts_$1_EXTRA_C_SRCS = rts/dist/build/sm/Evac_thr.c rts/dist/build/sm/Scav_thr.c |
|---|
| 145 | endif |
|---|
| 146 | |
|---|
| 147 | $(call distdir-way-opts,rts,dist,$1) |
|---|
| 148 | $(call c-suffix-rules,rts,dist,$1,YES) |
|---|
| 149 | $(call cmm-suffix-rules,rts,dist,$1) |
|---|
| 150 | $(call hs-suffix-rules-srcdir,rts,dist,$1,.) |
|---|
| 151 | # hs-suffix-rules-srcdir is needed when BootingFromHc to get the .hc rules |
|---|
| 152 | |
|---|
| 153 | rts_$1_LIB_NAME = libHSrts$$($1_libsuf) |
|---|
| 154 | rts_$1_LIB = rts/dist/build/$$(rts_$1_LIB_NAME) |
|---|
| 155 | |
|---|
| 156 | rts_$1_C_OBJS = $$(patsubst rts/%.c,rts/dist/build/%.$$($1_osuf),$$(rts_C_SRCS)) $$(patsubst %.c,%.$$($1_osuf),$$(rts_$1_EXTRA_C_SRCS)) |
|---|
| 157 | rts_$1_S_OBJS = $$(patsubst rts/%.S,rts/dist/build/%.$$($1_osuf),$$(rts_S_SRCS)) |
|---|
| 158 | rts_$1_CMM_OBJS = $$(patsubst rts/%.cmm,rts/dist/build/%.$$($1_osuf),$$(rts_CMM_SRCS)) $$(patsubst %.cmm,%.$$($1_osuf),$$(rts_AUTO_APPLY_CMM)) |
|---|
| 159 | |
|---|
| 160 | rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS) |
|---|
| 161 | |
|---|
| 162 | ifeq "$(USE_DTRACE)" "YES" |
|---|
| 163 | ifeq "$(TargetOS_CPP)" "solaris2" |
|---|
| 164 | # On Darwin we don't need to generate binary containing probes defined |
|---|
| 165 | # in DTrace script, but DTrace on Solaris expects generation of binary |
|---|
| 166 | # from the DTrace probes definitions |
|---|
| 167 | rts_$1_DTRACE_OBJS = rts/dist/build/RtsProbes.$$($1_osuf) |
|---|
| 168 | |
|---|
| 169 | rts/dist/build/RtsProbes.$$($1_osuf) : $$(rts_$1_OBJS) |
|---|
| 170 | $(DTRACE) -G -C $$(addprefix -I,$$(GHC_INCLUDE_DIRS)) -DDTRACE -s rts/RtsProbes.d -o \ |
|---|
| 171 | $$@ $$(rts_$1_OBJS) |
|---|
| 172 | endif |
|---|
| 173 | endif |
|---|
| 174 | |
|---|
| 175 | rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\" |
|---|
| 176 | |
|---|
| 177 | # Making a shared library for the RTS. |
|---|
| 178 | ifneq "$$(findstring dyn, $1)" "" |
|---|
| 179 | ifeq "$$(HostOS_CPP)" "mingw32" |
|---|
| 180 | $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend rts/dist/build/$$(LIBFFI_DLL) |
|---|
| 181 | "$$(RM)" $$(RM_OPTS) $$@ |
|---|
| 182 | "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \ |
|---|
| 183 | -no-auto-link-packages -Lrts/dist/build -l$(LIBFFI_WINDOWS_LIB) `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@ |
|---|
| 184 | else |
|---|
| 185 | $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend rts/dist/build/libffi$$(soext) |
|---|
| 186 | "$$(RM)" $$(RM_OPTS) $$@ |
|---|
| 187 | "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \ |
|---|
| 188 | -no-auto-link-packages -Lrts/dist/build -lffi `cat rts/libs.depend` $$(rts_$1_OBJS) \ |
|---|
| 189 | $$(rts_$1_DTRACE_OBJS) -o $$@ |
|---|
| 190 | ifeq "$$(darwin_HOST_OS)" "1" |
|---|
| 191 | # Ensure library's install name is correct before anyone links with it. |
|---|
| 192 | install_name_tool -id $$(ghclibdir)/$$(rts_$1_LIB_NAME) $$@ |
|---|
| 193 | endif |
|---|
| 194 | endif |
|---|
| 195 | else |
|---|
| 196 | $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) $$(rts_ffi_objs_stamp) |
|---|
| 197 | "$$(RM)" $$(RM_OPTS) $$@ |
|---|
| 198 | echo $$(rts_ffi_objs) $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) | "$$(XARGS)" $$(XARGS_OPTS) "$$(AR_STAGE1)" \ |
|---|
| 199 | $$(AR_OPTS_STAGE1) $$(EXTRA_AR_ARGS_STAGE1) $$@ |
|---|
| 200 | endif |
|---|
| 201 | |
|---|
| 202 | endif |
|---|
| 203 | |
|---|
| 204 | endef |
|---|
| 205 | |
|---|
| 206 | # And expand the above for each way: |
|---|
| 207 | $(foreach way,$(rts_WAYS),$(eval $(call build-rts-way,$(way)))) |
|---|
| 208 | |
|---|
| 209 | #----------------------------------------------------------------------------- |
|---|
| 210 | # Flags for compiling every file |
|---|
| 211 | |
|---|
| 212 | # We like plenty of warnings. |
|---|
| 213 | WARNING_OPTS += -Wall |
|---|
| 214 | ifeq "$(GccLT34)" "YES" |
|---|
| 215 | WARNING_OPTS += -W |
|---|
| 216 | else |
|---|
| 217 | WARNING_OPTS += -Wextra |
|---|
| 218 | endif |
|---|
| 219 | WARNING_OPTS += -Wstrict-prototypes |
|---|
| 220 | WARNING_OPTS += -Wmissing-prototypes |
|---|
| 221 | WARNING_OPTS += -Wmissing-declarations |
|---|
| 222 | WARNING_OPTS += -Winline |
|---|
| 223 | WARNING_OPTS += -Waggregate-return |
|---|
| 224 | WARNING_OPTS += -Wpointer-arith |
|---|
| 225 | WARNING_OPTS += -Wmissing-noreturn |
|---|
| 226 | WARNING_OPTS += -Wnested-externs |
|---|
| 227 | WARNING_OPTS += -Wredundant-decls |
|---|
| 228 | |
|---|
| 229 | # These ones are hard to avoid: |
|---|
| 230 | #WARNING_OPTS += -Wconversion |
|---|
| 231 | #WARNING_OPTS += -Wbad-function-cast |
|---|
| 232 | #WARNING_OPTS += -Wshadow |
|---|
| 233 | #WARNING_OPTS += -Wcast-qual |
|---|
| 234 | |
|---|
| 235 | # This one seems buggy on GCC 4.1.2, which is the only GCC version we |
|---|
| 236 | # have that can bootstrap the SPARC build. We end up with lots of supurious |
|---|
| 237 | # warnings of the form "cast increases required alignment of target type". |
|---|
| 238 | # Some legitimate warnings can be fixed by adding an intermediate cast to |
|---|
| 239 | # (void*), but we get others in rts/sm/GCUtils.c concerning the gct var |
|---|
| 240 | # that look innocuous to me. We could enable this again once we deprecate |
|---|
| 241 | # support for registerised builds on this arch. -- BL 2010/02/03 |
|---|
| 242 | # WARNING_OPTS += -Wcast-align |
|---|
| 243 | |
|---|
| 244 | STANDARD_OPTS += $(addprefix -I,$(GHC_INCLUDE_DIRS)) -Irts -Irts/dist/build |
|---|
| 245 | # COMPILING_RTS is only used when building Win32 DLL support. |
|---|
| 246 | STANDARD_OPTS += -DCOMPILING_RTS |
|---|
| 247 | |
|---|
| 248 | # HC_OPTS is included in both .c and .cmm compilations, whereas CC_OPTS is |
|---|
| 249 | # only included in .c compilations. HC_OPTS included the WAY_* opts, which |
|---|
| 250 | # must be included in both types of compilations. |
|---|
| 251 | |
|---|
| 252 | rts_CC_OPTS += $(WARNING_OPTS) |
|---|
| 253 | rts_CC_OPTS += $(STANDARD_OPTS) |
|---|
| 254 | |
|---|
| 255 | rts_HC_OPTS += $(STANDARD_OPTS) -package-name rts |
|---|
| 256 | |
|---|
| 257 | ifneq "$(GhcWithSMP)" "YES" |
|---|
| 258 | rts_CC_OPTS += -DNOSMP |
|---|
| 259 | rts_HC_OPTS += -optc-DNOSMP |
|---|
| 260 | endif |
|---|
| 261 | |
|---|
| 262 | ifeq "$(UseLibFFIForAdjustors)" "YES" |
|---|
| 263 | rts_CC_OPTS += -DUSE_LIBFFI_FOR_ADJUSTORS |
|---|
| 264 | endif |
|---|
| 265 | |
|---|
| 266 | # Mac OS X: make sure we compile for the right OS version |
|---|
| 267 | rts_CC_OPTS += $(MACOSX_DEPLOYMENT_CC_OPTS) |
|---|
| 268 | rts_HC_OPTS += $(addprefix -optc, $(MACOSX_DEPLOYMENT_CC_OPTS)) |
|---|
| 269 | rts_LD_OPTS += $(addprefix -optl, $(MACOSX_DEPLOYMENT_LD_OPTS)) |
|---|
| 270 | |
|---|
| 271 | # We *want* type-checking of hand-written cmm. |
|---|
| 272 | rts_HC_OPTS += -dcmm-lint |
|---|
| 273 | |
|---|
| 274 | # -fno-strict-aliasing is required for the runtime, because we often |
|---|
| 275 | # use a variety of types to represent closure pointers (StgPtr, |
|---|
| 276 | # StgClosure, StgMVar, etc.), and without -fno-strict-aliasing gcc is |
|---|
| 277 | # allowed to assume that these pointers do not alias. eg. without |
|---|
| 278 | # this flag we get problems in sm/Evac.c:copy() with gcc 3.4.3, the |
|---|
| 279 | # upd_evacee() assigments get moved before the object copy. |
|---|
| 280 | rts_CC_OPTS += -fno-strict-aliasing |
|---|
| 281 | |
|---|
| 282 | rts_CC_OPTS += -fno-common |
|---|
| 283 | |
|---|
| 284 | ifeq "$(BeConservative)" "YES" |
|---|
| 285 | rts_CC_OPTS += -DBE_CONSERVATIVE |
|---|
| 286 | endif |
|---|
| 287 | |
|---|
| 288 | #----------------------------------------------------------------------------- |
|---|
| 289 | # Flags for compiling specific files |
|---|
| 290 | |
|---|
| 291 | # If RtsMain.c is built with optimisation then the SEH exception stuff on |
|---|
| 292 | # Windows gets confused. |
|---|
| 293 | # This has to be in HC rather than CC opts, as otherwise there's a |
|---|
| 294 | # -optc-O2 that comes after it. |
|---|
| 295 | rts/RtsMain_HC_OPTS += -optc-O0 |
|---|
| 296 | |
|---|
| 297 | rts/RtsMessages_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\" |
|---|
| 298 | rts/RtsUtils_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\" |
|---|
| 299 | rts/Trace_CC_OPTS += -DProjectVersion=\"$(ProjectVersion)\" |
|---|
| 300 | # |
|---|
| 301 | rts/RtsUtils_CC_OPTS += -DHostPlatform=\"$(HOSTPLATFORM)\" |
|---|
| 302 | rts/RtsUtils_CC_OPTS += -DHostArch=\"$(HostArch_CPP)\" |
|---|
| 303 | rts/RtsUtils_CC_OPTS += -DHostOS=\"$(HostOS_CPP)\" |
|---|
| 304 | rts/RtsUtils_CC_OPTS += -DHostVendor=\"$(HostVendor_CPP)\" |
|---|
| 305 | # |
|---|
| 306 | rts/RtsUtils_CC_OPTS += -DBuildPlatform=\"$(BUILDPLATFORM)\" |
|---|
| 307 | rts/RtsUtils_CC_OPTS += -DBuildArch=\"$(BuildArch_CPP)\" |
|---|
| 308 | rts/RtsUtils_CC_OPTS += -DBuildOS=\"$(BuildOS_CPP)\" |
|---|
| 309 | rts/RtsUtils_CC_OPTS += -DBuildVendor=\"$(BuildVendor_CPP)\" |
|---|
| 310 | # |
|---|
| 311 | rts/RtsUtils_CC_OPTS += -DTargetPlatform=\"$(TARGETPLATFORM)\" |
|---|
| 312 | rts/RtsUtils_CC_OPTS += -DTargetArch=\"$(TargetArch_CPP)\" |
|---|
| 313 | rts/RtsUtils_CC_OPTS += -DTargetOS=\"$(TargetOS_CPP)\" |
|---|
| 314 | rts/RtsUtils_CC_OPTS += -DTargetVendor=\"$(TargetVendor_CPP)\" |
|---|
| 315 | # |
|---|
| 316 | rts/RtsUtils_CC_OPTS += -DGhcUnregisterised=\"$(GhcUnregisterised)\" |
|---|
| 317 | rts/RtsUtils_CC_OPTS += -DGhcEnableTablesNextToCode=\"$(GhcEnableTablesNextToCode)\" |
|---|
| 318 | |
|---|
| 319 | # Compile various performance-critical pieces *without* -fPIC -dynamic |
|---|
| 320 | # even when building a shared library. If we don't do this, then the |
|---|
| 321 | # GC runs about 50% slower on x86 due to the overheads of PIC. The |
|---|
| 322 | # cost of doing this is a little runtime linking and less sharing, but |
|---|
| 323 | # not much. |
|---|
| 324 | # |
|---|
| 325 | # On x86_64 this doesn't work, because all objects in a shared library |
|---|
| 326 | # must be compiled with -fPIC (since the 32-bit relocations generated |
|---|
| 327 | # by the default small memory can't be resolved at runtime). So we |
|---|
| 328 | # only do this on i386. |
|---|
| 329 | # |
|---|
| 330 | # This apparently doesn't work on OS X (Darwin) nor on Solaris. |
|---|
| 331 | # On Darwin we get errors of the form |
|---|
| 332 | # |
|---|
| 333 | # 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 |
|---|
| 334 | # |
|---|
| 335 | # and lots of these warnings: |
|---|
| 336 | # |
|---|
| 337 | # ld: warning codegen in _stg_ap_pppv_fast (offset 0x0000005E) prevents image from loading in dyld shared cache |
|---|
| 338 | # |
|---|
| 339 | # On Solaris we get errors like: |
|---|
| 340 | # |
|---|
| 341 | # Text relocation remains referenced |
|---|
| 342 | # against symbol offset in file |
|---|
| 343 | # .rodata (section) 0x11 rts/dist/build/Apply.dyn_o |
|---|
| 344 | # ... |
|---|
| 345 | # ld: fatal: relocations remain against allocatable but non-writable sections |
|---|
| 346 | # collect2: ld returned 1 exit status |
|---|
| 347 | |
|---|
| 348 | ifeq "$(TargetArch_CPP)" "i386" |
|---|
| 349 | i386_SPEED_HACK := "YES" |
|---|
| 350 | ifeq "$(TargetOS_CPP)" "darwin" |
|---|
| 351 | i386_SPEED_HACK := "NO" |
|---|
| 352 | endif |
|---|
| 353 | ifeq "$(TargetOS_CPP)" "solaris2" |
|---|
| 354 | i386_SPEED_HACK := "NO" |
|---|
| 355 | endif |
|---|
| 356 | endif |
|---|
| 357 | |
|---|
| 358 | ifeq "$(TargetArch_CPP)" "i386" |
|---|
| 359 | ifeq "$(i386_SPEED_HACK)" "YES" |
|---|
| 360 | rts/sm/Evac_HC_OPTS += -fno-PIC |
|---|
| 361 | rts/sm/Evac_thr_HC_OPTS += -fno-PIC |
|---|
| 362 | rts/sm/Scav_HC_OPTS += -fno-PIC |
|---|
| 363 | rts/sm/Scav_thr_HC_OPTS += -fno-PIC |
|---|
| 364 | rts/sm/Compact_HC_OPTS += -fno-PIC |
|---|
| 365 | rts/sm/GC_HC_OPTS += -fno-PIC |
|---|
| 366 | |
|---|
| 367 | # -static is also necessary for these bits, otherwise the NCG |
|---|
| 368 | # -generates dynamic references: |
|---|
| 369 | rts/Updates_HC_OPTS += -fno-PIC -static |
|---|
| 370 | rts/StgMiscClosures_HC_OPTS += -fno-PIC -static |
|---|
| 371 | rts/PrimOps_HC_OPTS += -fno-PIC -static |
|---|
| 372 | rts/Apply_HC_OPTS += -fno-PIC -static |
|---|
| 373 | rts/dist/build/AutoApply_HC_OPTS += -fno-PIC -static |
|---|
| 374 | endif |
|---|
| 375 | endif |
|---|
| 376 | |
|---|
| 377 | # ffi.h triggers prototype warnings, so disable them here: |
|---|
| 378 | rts/Interpreter_CC_OPTS += -Wno-strict-prototypes |
|---|
| 379 | rts/Adjustor_CC_OPTS += -Wno-strict-prototypes |
|---|
| 380 | rts/sm/Storage_CC_OPTS += -Wno-strict-prototypes |
|---|
| 381 | |
|---|
| 382 | # inlining warnings happen in Compact |
|---|
| 383 | rts/sm/Compact_CC_OPTS += -Wno-inline |
|---|
| 384 | |
|---|
| 385 | # emits warnings about call-clobbered registers on x86_64 |
|---|
| 386 | rts/StgCRun_CC_OPTS += -w |
|---|
| 387 | |
|---|
| 388 | rts/RetainerProfile_CC_OPTS += -w |
|---|
| 389 | rts/RetainerSet_CC_OPTS += -Wno-format |
|---|
| 390 | # On Windows: |
|---|
| 391 | rts/win32/ConsoleHandler_CC_OPTS += -w |
|---|
| 392 | rts/win32/ThrIOManager_CC_OPTS += -w |
|---|
| 393 | # The above warning supression flags are a temporary kludge. |
|---|
| 394 | # While working on this module you are encouraged to remove it and fix |
|---|
| 395 | # any warnings in the module. See |
|---|
| 396 | # http://hackage.haskell.org/trac/ghc/wiki/WorkingConventions#Warnings |
|---|
| 397 | # for details |
|---|
| 398 | |
|---|
| 399 | # Without this, thread_obj will not be inlined (at least on x86 with GCC 4.1.0) |
|---|
| 400 | rts/sm/Compact_CC_OPTS += -finline-limit=2500 |
|---|
| 401 | |
|---|
| 402 | # -O3 helps unroll some loops (especially in copy() with a constant argument). |
|---|
| 403 | rts/sm/Evac_CC_OPTS += -funroll-loops |
|---|
| 404 | rts/dist/build/sm/Evac_thr_HC_OPTS += -optc-funroll-loops |
|---|
| 405 | |
|---|
| 406 | # These files are just copies of sm/Evac.c and sm/Scav.c respectively, |
|---|
| 407 | # but compiled with -DPARALLEL_GC. |
|---|
| 408 | rts/dist/build/sm/Evac_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm |
|---|
| 409 | rts/dist/build/sm/Scav_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm |
|---|
| 410 | |
|---|
| 411 | #----------------------------------------------------------------------------- |
|---|
| 412 | # Add PAPI library if needed |
|---|
| 413 | |
|---|
| 414 | ifeq "$(GhcRtsWithPapi)" "YES" |
|---|
| 415 | |
|---|
| 416 | rts_CC_OPTS += -DUSE_PAPI |
|---|
| 417 | |
|---|
| 418 | rts_PACKAGE_CPP_OPTS += -DUSE_PAPI |
|---|
| 419 | rts_PACKAGE_CPP_OPTS += -DPAPI_INCLUDE_DIR=$(PapiIncludeDir) |
|---|
| 420 | rts_PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR=$(PapiLibDir) |
|---|
| 421 | |
|---|
| 422 | ifneq "$(PapiIncludeDir)" "" |
|---|
| 423 | rts_HC_OPTS += -I$(PapiIncludeDir) |
|---|
| 424 | rts_CC_OPTS += -I$(PapiIncludeDir) |
|---|
| 425 | rts_HSC2HS_OPTS += -I$(PapiIncludeDir) |
|---|
| 426 | endif |
|---|
| 427 | ifneq "$(PapiLibDirs)" "" |
|---|
| 428 | rts_LD_OPTS += -L$(PapiLibDirs) |
|---|
| 429 | endif |
|---|
| 430 | |
|---|
| 431 | else # GhcRtsWithPapi==YES |
|---|
| 432 | |
|---|
| 433 | rts_PACKAGE_CPP_OPTS += -DPAPI_INCLUDE_DIR="" |
|---|
| 434 | rts_PACKAGE_CPP_OPTS += -DPAPI_LIB_DIR="" |
|---|
| 435 | |
|---|
| 436 | endif |
|---|
| 437 | |
|---|
| 438 | # ----------------------------------------------------------------------------- |
|---|
| 439 | # dependencies |
|---|
| 440 | |
|---|
| 441 | rts_WAYS_DASHED = $(subst $(space),,$(patsubst %,-%,$(strip $(rts_WAYS)))) |
|---|
| 442 | rts_dist_depfile_base = rts/dist/build/.depend$(rts_WAYS_DASHED) |
|---|
| 443 | |
|---|
| 444 | rts_dist_C_SRCS = $(rts_C_SRCS) $(rts_thr_EXTRA_C_SRCS) |
|---|
| 445 | rts_dist_S_SRCS = $(rts_S_SRCS) |
|---|
| 446 | rts_dist_C_FILES = $(rts_C_SRCS) $(rts_thr_EXTRA_C_SRCS) $(rts_S_SRCS) |
|---|
| 447 | |
|---|
| 448 | # Hack: we define every way-related option here, so that we get (hopefully) |
|---|
| 449 | # a superset of the dependencies. To do this properly, we should generate |
|---|
| 450 | # a different set of dependencies for each way. Further hack: PROFILING an |
|---|
| 451 | |
|---|
| 452 | # TICKY_TICKY can't be used together, so we omit TICKY_TICKY for now. |
|---|
| 453 | rts_dist_MKDEPENDC_OPTS += -DPROFILING -DTHREADED_RTS -DDEBUG |
|---|
| 454 | |
|---|
| 455 | ifeq "$(USE_DTRACE)" "YES" |
|---|
| 456 | |
|---|
| 457 | rts_dist_MKDEPENDC_OPTS += -Irts/dist/build |
|---|
| 458 | |
|---|
| 459 | endif |
|---|
| 460 | |
|---|
| 461 | $(eval $(call dependencies,rts,dist,1)) |
|---|
| 462 | |
|---|
| 463 | $(rts_dist_depfile_c_asm) : $(libffi_HEADERS) $(DTRACEPROBES_H) |
|---|
| 464 | |
|---|
| 465 | # ----------------------------------------------------------------------------- |
|---|
| 466 | # compile dtrace probes if dtrace is supported |
|---|
| 467 | |
|---|
| 468 | ifeq "$(USE_DTRACE)" "YES" |
|---|
| 469 | |
|---|
| 470 | rts_CC_OPTS += -DDTRACE |
|---|
| 471 | rts_HC_OPTS += -DDTRACE |
|---|
| 472 | |
|---|
| 473 | # Apple's dtrace (the only one supported by ghc at the moment) uses |
|---|
| 474 | # gcc as its preprocessor. If gcc isn't at /usr/bin/gcc, or we need |
|---|
| 475 | # to force it to use a different gcc, we need to give the path in |
|---|
| 476 | # the option cpppath. |
|---|
| 477 | |
|---|
| 478 | ifeq "$(TargetOS_CPP)" "darwin" |
|---|
| 479 | # Darwin has a flag to tell dtrace which cpp to use. |
|---|
| 480 | # Unfortunately, this isn't supported on Solaris (See Solaris Dynamic Tracing |
|---|
| 481 | # Guide, Chapter 16, for the configuration variables available on Solaris) |
|---|
| 482 | DTRACE_FLAGS = -x cpppath=$(WhatGccIsCalled) |
|---|
| 483 | endif |
|---|
| 484 | |
|---|
| 485 | DTRACEPROBES_SRC = rts/RtsProbes.d |
|---|
| 486 | $(DTRACEPROBES_H): $(DTRACEPROBES_SRC) includes/ghcplatform.h | $$(dir $$@)/. |
|---|
| 487 | "$(DTRACE)" $(filter -I%,$(rts_CC_OPTS)) -C $(DTRACE_FLAGS) -h -o $@ -s $< |
|---|
| 488 | endif |
|---|
| 489 | |
|---|
| 490 | # ----------------------------------------------------------------------------- |
|---|
| 491 | # The RTS package config |
|---|
| 492 | |
|---|
| 493 | # If -DDEBUG is in effect, adjust package conf accordingly.. |
|---|
| 494 | ifneq "$(strip $(filter -optc-DDEBUG,$(GhcRtsHcOpts)))" "" |
|---|
| 495 | rts_PACKAGE_CPP_OPTS += -DDEBUG |
|---|
| 496 | endif |
|---|
| 497 | |
|---|
| 498 | ifeq "$(HaveLibMingwEx)" "YES" |
|---|
| 499 | rts_PACKAGE_CPP_OPTS += -DHAVE_LIBMINGWEX |
|---|
| 500 | endif |
|---|
| 501 | |
|---|
| 502 | $(eval $(call manual-package-config,rts)) |
|---|
| 503 | |
|---|
| 504 | ifneq "$(BootingFromHc)" "YES" |
|---|
| 505 | rts/package.conf.inplace : $(includes_H_CONFIG) $(includes_H_PLATFORM) |
|---|
| 506 | endif |
|---|
| 507 | |
|---|
| 508 | # ----------------------------------------------------------------------------- |
|---|
| 509 | # installing |
|---|
| 510 | |
|---|
| 511 | INSTALL_LIBS += $(ALL_RTS_LIBS) |
|---|
| 512 | INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*) |
|---|
| 513 | INSTALL_LIBS += $(wildcard rts/dist/build/$(LIBFFI_DLL)) |
|---|
| 514 | |
|---|
| 515 | install: install_libffi_headers |
|---|
| 516 | |
|---|
| 517 | .PHONY: install_libffi_headers |
|---|
| 518 | install_libffi_headers : |
|---|
| 519 | $(call INSTALL_DIR,"$(DESTDIR)$(ghcheaderdir)") |
|---|
| 520 | $(call INSTALL_HEADER,$(INSTALL_OPTS),$(libffi_HEADERS),"$(DESTDIR)$(ghcheaderdir)/") |
|---|
| 521 | |
|---|
| 522 | # ----------------------------------------------------------------------------- |
|---|
| 523 | # cleaning |
|---|
| 524 | |
|---|
| 525 | $(eval $(call clean-target,rts,dist,rts/dist)) |
|---|
| 526 | |
|---|
| 527 | BINDIST_EXTRAS += rts/package.conf.in |
|---|