Get Windows building dynlibs again
authorIan Lynagh <igloo@earth.li>
Tue, 18 Oct 2011 11:07:29 +0000 (12:07 +0100)
committerIan Lynagh <igloo@earth.li>
Tue, 18 Oct 2011 11:07:29 +0000 (12:07 +0100)
compiler/ghc.mk
mk/validate-settings.mk
rts/ghc.mk

index 43b609b..54dfa3e 100644 (file)
@@ -265,8 +265,6 @@ PRIMOP_BITS = compiler/primop-data-decl.hs-incl        \
 compiler_CPP_OPTS += -I$(GHC_INCLUDE_DIR)
 compiler_CPP_OPTS += ${GhcCppOpts}
 
-compiler/stage2/build/LibFFI.hs : $(ffi_HEADER)
-
 $(PRIMOPS_TXT) compiler/parser/Parser.y: %: %.pp compiler/stage1/$(PLATFORM_H)
        $(CPP) $(RAWCPP_FLAGS) -P $(compiler_CPP_OPTS) -x c $< | grep -v '^#pragma GCC' > $@
 
@@ -493,6 +491,19 @@ ifeq "$(GhcVersion)" "6.12.2"
 compiler/hsSyn/HsLit_HC_OPTS     += -fomit-interface-pragmas
 endif
 
+# LibFFI.hs #includes ffi.h
+compiler/stage2/build/LibFFI.hs : $(ffi_HEADER)
+# On Windows it seems we also need to link directly to libffi
+ifeq  "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+define windowsDynLinkToFfi
+# $1 = way
+ifneq "$$(findstring dyn, $1)" ""
+compiler_stage2_$1_ALL_HC_OPTS += -lffi-5
+endif
+endef
+$(foreach way,$(GhcLibWays),$(eval $(call windowsDynLinkToFfi,$(way))))
+endif
+
 # Note [munge-stage1-package-config]
 # Strip the date/patchlevel from the version of stage1.  See Note
 # [fiddle-stage1-version] above.
index e42c6c5..00d4657 100644 (file)
@@ -27,12 +27,7 @@ GhcStage2HcOpts += -O
 # running of the tests, and faster building of the utils to be installed
 
 GhcLibHcOpts    += -O -dcore-lint
-ifeq "$(Windows)" "YES"
-# This is a temporary hack to workaround a libffi build problem
-GhcLibWays     := $(filter v,$(GhcLibWays))
-else
 GhcLibWays     := $(filter v dyn,$(GhcLibWays))
-endif
 SplitObjs       = NO
 NoFibWays       =
 STRIP_CMD       = :
index fa118c1..54c941d 100644 (file)
@@ -83,21 +83,20 @@ rts/libs.depend : $(GHC_PKG_INPLACE)
 #      These are made from rts/win32/libHS*.def which contain lists of
 #      all the symbols in those libraries used by the RTS.
 #
-ifneq "$$(findstring dyn, $1)" ""
 ifeq  "$(HOSTPLATFORM)" "i386-unknown-mingw32" 
 
 ALL_RTS_DEF_LIBNAMES   = base ghc-prim
 ALL_RTS_DEF_LIBS       = \
        rts/dist/build/win32/libHSbase.dll.a \
        rts/dist/build/win32/libHSghc-prim.dll.a \
-       rts/dist/build/win32/libHSffi.dll.a 
+       libffi/build/inst/lib/libffi.dll.a
 
 # -- import libs for the regular Haskell libraries
 define make-importlib-def # args $1 = lib name
 rts/dist/build/win32/libHS$1.def : rts/win32/libHS$1.def
        cat rts/win32/libHS$1.def \
                | sed "s/@LibVersion@/$$(libraries/$1_dist-install_VERSION)/" \
-               | sed "s/@ProjectVersion@/$(ProjectVersion)/" \
+               | sed "s/@ProjectVersion@/$$(ProjectVersion)/" \
                > rts/dist/build/win32/libHS$1.def
 
 rts/dist/build/win32/libHS$1.dll.a : rts/dist/build/win32/libHS$1.def
@@ -105,18 +104,6 @@ rts/dist/build/win32/libHS$1.dll.a : rts/dist/build/win32/libHS$1.def
                        -l rts/dist/build/win32/libHS$1.dll.a
 endef
 $(foreach lib,$(ALL_RTS_DEF_LIBNAMES),$(eval $(call make-importlib-def,$(lib))))
-
-
-# -- import libs for libffi
-rts/dist/build/win32/libHSffi.def : rts/win32/libHSffi.def
-       cat rts/win32/libHSffi.def \
-               | sed "s/@ProjectVersion@/$(ProjectVersion)/" \
-               > rts/dist/build/win32/libHSffi.def
-
-rts/dist/build/win32/libHSffi.dll.a : rts/dist/build/win32/libHSffi.def
-       "$(DLLTOOL)"    -d rts/dist/build/win32/libHSffi.def \
-                       -l rts/dist/build/win32/libHSffi.dll.a
-endif
 endif
 
 ifneq "$(BINDIST)" "YES"
@@ -130,6 +117,9 @@ $(rts_ffi_objs_stamp): $(libffi_STATIC_LIB) | $$(dir $$@)/.
 # depend on libffi.so, but copy libffi.so*
 rts/dist/build/libffi$(soext): libffi/build/inst/lib/libffi$(soext)
        cp libffi/build/inst/lib/libffi$(soext)* rts/dist/build
+
+rts/dist/build/libffi-5.dll: libffi/build/inst/bin/libffi-5.dll
+       cp $< $@
 endif
 
 #-----------------------------------------------------------------------------
@@ -184,10 +174,10 @@ rts_dist_$1_CC_OPTS += -DRtsWay=\"rts_$1\"
 # Making a shared library for the RTS.
 ifneq "$$(findstring dyn, $1)" ""
 ifeq "$$(HOSTPLATFORM)" "i386-unknown-mingw32"
-$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend
+$$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) rts/libs.depend rts/dist/build/libffi-5.dll
        "$$(RM)" $$(RM_OPTS) $$@
        "$$(rts_dist_HC)" -package-name rts -shared -dynamic -dynload deploy \
-         -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
+         -no-auto-link-packages -Lrts/dist/build -lffi-5 `cat rts/libs.depend` $$(rts_$1_OBJS) $$(ALL_RTS_DEF_LIBS) -o $$@
 else
 $$(rts_$1_LIB) : $$(rts_$1_OBJS) $$(rts_$1_DTRACE_OBJS) rts/libs.depend rts/dist/build/libffi$$(soext)
        "$$(RM)" $$(RM_OPTS) $$@
@@ -526,6 +516,7 @@ endif
 
 INSTALL_LIBS += $(ALL_RTS_LIBS)
 INSTALL_LIBS += $(wildcard rts/dist/build/libffi$(soext)*)
+INSTALL_LIBS += $(wildcard rts/dist/build/libffi-5.dll)
 
 # -----------------------------------------------------------------------------
 # cleaning