Break recursive imports between the RTS and base library on Windows.
authorBen.Lippmeier@anu.edu.au <unknown>
Fri, 6 Nov 2009 06:27:32 +0000 (06:27 +0000)
committerBen.Lippmeier@anu.edu.au <unknown>
Fri, 6 Nov 2009 06:27:32 +0000 (06:27 +0000)
The file rts/win32/libHSbase.def contains a list of all the
symbols from the base library that the RTS needs.

When building the RTS into a DLL on Windows, we want to link the DLL
for the RTS before we link the DLL for the base library. We use
libHSbase.def to make the "import library" libHSbase.so.a, which
contains stubs for each of the symbols from the base library that
the RTS needs.

rts/ghc.mk
rts/win32/libHSbase.def [new file with mode: 0644]

index 25fcb4f..220103d 100644 (file)
@@ -108,11 +108,23 @@ rts_$1_OBJS = $$(rts_$1_C_OBJS) $$(rts_$1_S_OBJS) $$(rts_$1_CMM_OBJS)
 
 rts_dist_$1_CC_OPTS += -DRtsWay=$$(DQ)rts_$1$$(DQ)
 
 
 rts_dist_$1_CC_OPTS += -DRtsWay=$$(DQ)rts_$1$$(DQ)
 
+
+# Making a shared library for the RTS.
+#      On Windows, as the RTS and base library has recursive imports
+#      we have to break the loop with a import library (libHSbase.so.a)
+#      This is made from rts/win32/libHSbase.def which contains a list of
+#      all the symbols in the base library used by the RTS.
 ifneq "$$(findstring dyn, $1)" ""
 $$(rts_$1_LIB) : $$(rts_$1_OBJS) rts/libs.depend
        "$$(RM)" $$(RM_OPTS) $$@
 ifneq "$$(findstring dyn, $1)" ""
 $$(rts_$1_LIB) : $$(rts_$1_OBJS) rts/libs.depend
        "$$(RM)" $$(RM_OPTS) $$@
+  ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+       dlltool -d rts/win32/libHSbase.def -l rts/dist/build/win32/libHSbase.so.a
+       "$$(rts_dist_HC)" -shared -dynamic -dynload deploy \
+         -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) rts/dist/build/win32/libHSbase.so.a -o $$@
+  else
        "$$(rts_dist_HC)" -shared -dynamic -dynload deploy \
          -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) -o $$@
        "$$(rts_dist_HC)" -shared -dynamic -dynload deploy \
          -no-auto-link-packages `cat rts/libs.depend` $$(rts_$1_OBJS) -o $$@
+  endif
 else
 $$(rts_$1_LIB) : $$(rts_$1_OBJS)
        "$$(RM)" $$(RM_OPTS) $$@
 else
 $$(rts_$1_LIB) : $$(rts_$1_OBJS)
        "$$(RM)" $$(RM_OPTS) $$@
diff --git a/rts/win32/libHSbase.def b/rts/win32/libHSbase.def
new file mode 100644 (file)
index 0000000..5f534e0
--- /dev/null
@@ -0,0 +1,64 @@
+
+LIBRARY base
+
+EXPORTS
+
+       ffi_call
+       ffi_prep_cif
+       ffi_call
+       ffi_type_void
+       ffi_type_float
+       ffi_type_double
+       ffi_type_sint64
+       ffi_type_uint64
+       ffi_type_sint32
+       ffi_type_uint32
+       ffi_type_sint16
+       ffi_type_uint16
+       ffi_type_sint8
+       ffi_type_uint8
+       ffi_type_pointer
+
+       ghczmprim_GHCziBool_True_closure
+       ghczmprim_GHCziBool_False_closure
+       ghczmprim_GHCziTypes_Czh_con_info
+       ghczmprim_GHCziTypes_Izh_con_info
+       ghczmprim_GHCziTypes_Fzh_con_info
+       ghczmprim_GHCziTypes_Dzh_con_info
+       ghczmprim_GHCziTypes_Czh_static_info
+       ghczmprim_GHCziTypes_Izh_static_info
+
+       base_GHCziInt_I8zh_con_info
+       base_GHCziInt_I16zh_con_info
+       base_GHCziInt_I32zh_con_info
+       base_GHCziInt_I64zh_con_info
+
+       base_GHCziWord_Wzh_con_info
+       base_GHCziWord_W8zh_con_info
+       base_GHCziWord_W16zh_con_info
+       base_GHCziWord_W32zh_con_info
+       base_GHCziWord_W64zh_con_info
+
+       base_GHCziStable_StablePtr_con_info
+
+       base_GHCziPack_unpackCString_closure
+
+       base_GHCziTopHandler_runIO_closure
+       base_GHCziTopHandler_runNonIO_closure
+
+       base_GHCziIOziException_stackOverflow_closure
+       base_GHCziIOziException_heapOverflow_closure
+
+       base_GHCziPtr_Ptr_con_info
+       base_GHCziPtr_FunPtr_con_info
+
+       base_GHCziWeak_runFinalizzerBatch_closure
+       base_GHCziPack_unpackCString_closure
+       base_GHCziIOziException_blockedIndefinitelyOnMVar_closure
+       base_GHCziIOziException_blockedIndefinitelyOnSTM_closure
+       base_GHCziIOziException_stackOverflow_closure
+
+       base_ControlziExceptionziBase_nonTermination_closure
+       base_ControlziExceptionziBase_nestedAtomically_closure
+
+