Drop copy step from the rts/ghc.mk
authorMoritz Angermann <moritz.angermann@gmail.com>
Tue, 28 Feb 2017 16:09:22 +0000 (11:09 -0500)
committerBen Gamari <ben@smart-cactus.org>
Tue, 28 Feb 2017 20:43:38 +0000 (15:43 -0500)
Recently I've used a different build system for building the
rts (Xcode).  And in doing so, I looked through the rts/ghc.mk
to figure out how to build the rts.

In general it's quite straight forward to just compile all the
c files with the proper flags.

However there is one rather awkward copy step that copies some
files for special handling for the rts way.

I'm wondering if the proposed solution in this diff is better
or worse than the current situation?

The idea is to keep the files, but use #includes to produce
identical files with just an additional define. It does however
produce empty objects for non threaded ways.

Reviewers: ezyang, bgamari, austin, erikd, simonmar, rwbarton

Reviewed By: bgamari, simonmar, rwbarton

Subscribers: rwbarton, thomie, snowleopard

Differential Revision: https://phabricator.haskell.org/D3237

rts/ghc.mk
rts/sm/Evac_thr.c [new file with mode: 0644]
rts/sm/Scav_thr.c [new file with mode: 0644]

index 89c5a0b..b756d94 100644 (file)
@@ -68,10 +68,6 @@ rts_AUTO_APPLY_CMM = rts/dist/build/AutoApply.cmm
 $(rts_AUTO_APPLY_CMM): $$(genapply_INPLACE)
        "$(genapply_INPLACE)" >$@
 
-rts/dist/build/sm/Evac_thr.c : rts/sm/Evac.c | $$(dir $$@)/.
-       cp $< $@
-rts/dist/build/sm/Scav_thr.c : rts/sm/Scav.c | $$(dir $$@)/.
-       cp $< $@
 
 rts_H_FILES := $(wildcard rts/*.h rts/*/*.h)
 
@@ -157,9 +153,6 @@ endif
 rts_dist_$1_CC_OPTS += -DDYNAMIC
 endif
 
-ifneq "$$(findstring thr, $1)" ""
-rts_$1_EXTRA_C_SRCS  =  rts/dist/build/sm/Evac_thr.c rts/dist/build/sm/Scav_thr.c
-endif
 
 $(call distdir-way-opts,rts,dist,$1,1) # 1 because the rts is built with stage1
 $(call c-suffix-rules,rts,dist,$1,YES)
@@ -452,12 +445,8 @@ endif
 
 # -O3 helps unroll some loops (especially in copy() with a constant argument).
 rts/sm/Evac_CC_OPTS += -funroll-loops
-rts/dist/build/sm/Evac_thr_HC_OPTS += -optc-funroll-loops
+rts/sm/Evac_thr_HC_OPTS += -optc-funroll-loops
 
-# These files are just copies of sm/Evac.c and sm/Scav.c respectively,
-# but compiled with -DPARALLEL_GC.
-rts/dist/build/sm/Evac_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm
-rts/dist/build/sm/Scav_thr_CC_OPTS += -DPARALLEL_GC -Irts/sm
 
 #-----------------------------------------------------------------------------
 # Use system provided libffi
diff --git a/rts/sm/Evac_thr.c b/rts/sm/Evac_thr.c
new file mode 100644 (file)
index 0000000..4fff4ec
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef THREADED_RTS
+#define PARALLEL_GC
+#include "Evac.c"
+#endif
diff --git a/rts/sm/Scav_thr.c b/rts/sm/Scav_thr.c
new file mode 100644 (file)
index 0000000..372e779
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef THREADED_RTS
+#define PARALLEL_GC
+#include "Scav.c"
+#endif