Commit bf281580 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Get Windows building dynlibs again

parent 4dd52f2a
......@@ -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.
......
......@@ -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 = :
......
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment