Working towards fixing DLLs on Win64
authorIan Lynagh <igloo@earth.li>
Sun, 6 May 2012 01:21:17 +0000 (02:21 +0100)
committerIan Lynagh <igloo@earth.li>
Sun, 6 May 2012 01:21:17 +0000 (02:21 +0100)
includes/RtsAPI.h
includes/stg/DLL.h
rts/Linker.c
rts/RetainerProfile.c
rts/RtsDllMain.c
rts/RtsDllMain.h
rts/StgMiscClosures.cmm
rts/ghc.mk
rts/sm/Evac.c
rts/sm/Scav.c
rts/win32/ThrIOManager.c

index 7f41ebc..ca87662 100644 (file)
@@ -232,7 +232,7 @@ SchedulerStatus rts_getSchedStatus (Capability *cap);
 //     Note that RtsAPI.h is also included by foreign export stubs in
 //     the base package itself.
 //
-#if defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH) && defined(__PIC__) && !defined(COMPILING_BASE_PACKAGE)
+#if defined(COMPILING_WINDOWS_DLL) && !defined(COMPILING_BASE_PACKAGE)
 __declspec(dllimport) extern StgWord base_GHCziTopHandler_runIO_closure[];
 __declspec(dllimport) extern StgWord base_GHCziTopHandler_runNonIO_closure[];
 #else
index b7030b0..ec64404 100644 (file)
@@ -14,7 +14,7 @@
 #ifndef __STGDLL_H__
 #define __STGDLL_H__ 1
 
-#if defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH)
+#if defined(COMPILING_WINDOWS_DLL)
 #  define DLL_IMPORT_DATA_REF(x) (_imp__##x)
 #  define DLL_IMPORT_DATA_VARNAME(x) *_imp__##x
 #  if __GNUC__ && !defined(__declspec)
@@ -45,7 +45,7 @@
 #else
 #define DLL_IMPORT
 #define DLL_IMPORT_RTS DLLIMPORT
-# if defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH)
+# if defined(COMPILING_WINDOWS_DLL)
 #  define DLL_IMPORT_DATA_VAR(x) _imp__##x
 # else
 #  define DLL_IMPORT_DATA_VAR(x) x
index ae77e68..26f734c 100644 (file)
@@ -986,7 +986,7 @@ typedef struct _RtsSymbolVal {
 // We don't do this when compiling to Windows DLLs at the moment because
 //      it doesn't support cross package data references well.
 //
-#if defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH)
+#if defined(COMPILING_WINDOWS_DLL)
 #define RTS_INTCHAR_SYMBOLS
 #else
 #define RTS_INTCHAR_SYMBOLS                             \
@@ -1314,7 +1314,7 @@ typedef struct _RtsSymbolVal {
 
 /* entirely bogus claims about types of these symbols */
 #define SymI_NeedsProto(vvv)  extern void vvv(void);
-#if defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH)
+#if defined(COMPILING_WINDOWS_DLL)
 #define SymE_HasProto(vvv)    SymE_HasProto(vvv);
 #define SymE_NeedsProto(vvv)    extern void _imp__ ## vvv (void);
 #else
index 028b3e3..4bbc338 100644 (file)
@@ -366,7 +366,7 @@ find_srt( stackPos *info )
        bitmap = info->next.srt.srt_bitmap;
        while (bitmap != 0) {
            if ((bitmap & 1) != 0) {
-#if defined(__PIC__) && defined(mingw32_HOST_OS)
+#if defined(COMPILING_WINDOWS_DLL)
                if ((unsigned long)(*(info->next.srt.srt)) & 0x1)
                    c = (* (StgClosure **)((unsigned long)*(info->next.srt.srt)) & ~0x1);
                else
@@ -1235,7 +1235,7 @@ retainSRT (StgClosure **srt, nat srt_bitmap, StgClosure *c, retainer c_child_r)
 
   while (bitmap != 0) {
       if ((bitmap & 1) != 0) {
-#if defined(__PIC__) && defined(mingw32_HOST_OS)
+#if defined(COMPILING_WINDOWS_DLL)
          if ( (unsigned long)(*srt) & 0x1 ) {
              retainClosure(* (StgClosure**) ((unsigned long) (*srt) & ~0x1), 
                            c, c_child_r);
index 2081e62..06c5655 100644 (file)
@@ -16,7 +16,7 @@
 #endif
 
 /* I'd be mildly surprised if this wasn't defined, but still. */
-#if defined(__PIC__) && defined(mingw32_HOST_OS)
+#if defined(COMPILING_WINDOWS_DLL)
 BOOL
 WINAPI
 DllMain ( HINSTANCE hInstance STG_UNUSED
@@ -40,4 +40,4 @@ DllMain ( HINSTANCE hInstance STG_UNUSED
   return TRUE;
 }
 
-#endif /* defined(__PIC__) && defined(mingw32_HOST_OS) */
+#endif
index fc28d90..d781127 100644 (file)
@@ -6,7 +6,7 @@
 #endif
 
 /* I'd be mildly surprised if this wasn't defined, but still. */
-#if defined(__PIC__) && defined(mingw32_HOST_OS)
+#if defined(COMPILING_WINDOWS_DLL)
 BOOL
 WINAPI
 DllMain ( HINSTANCE hInstance
index 763c85b..b991261 100644 (file)
@@ -576,7 +576,7 @@ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE
    replace them with references to the static objects.
    ------------------------------------------------------------------------- */
 
-#if defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH)
+#if defined(COMPILING_WINDOWS_DLL)
 /*
  * When sticking the RTS in a Windows DLL, we delay populating the
  * Charlike and Intlike tables until load-time, which is only
@@ -601,7 +601,7 @@ INFO_TABLE_CONSTR(stg_MVAR_TSO_QUEUE,2,0,0,PRIM,"MVAR_TSO_QUEUE","MVAR_TSO_QUEUE
  * on the fact that static closures live in the data section.
  */
 
-#if !(defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH))
+#if !(defined(COMPILING_WINDOWS_DLL))
 section "data" {
  stg_CHARLIKE_closure:
     CHARLIKE_HDR(0)
@@ -899,4 +899,4 @@ section "data" {
     INTLIKE_HDR(16)  /* MAX_INTLIKE == 16 */
 }
 
-#endif // !(defined(__PIC__) && defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH))
+#endif
index 70a7330..5ae6b1a 100644 (file)
@@ -134,6 +134,12 @@ rts_dist_$1_HC_OPTS = $$(GhcRtsHcOpts)
 rts_dist_$1_CC_OPTS = $$(GhcRtsCcOpts)
 endif
 
+ifneq "$$(findstring dyn, $1)" ""
+ifeq "$$(HostOS_CPP)" "mingw32" 
+rts_dist_$1_CC_OPTS += -DCOMPILING_WINDOWS_DLL
+endif
+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
index fdb5477..20a5b09 100644 (file)
@@ -555,7 +555,7 @@ loop:
   //
   case CONSTR_0_1:
   {   
-#if defined(__PIC__) && defined(mingw32_HOST_OS) 
+#if defined(COMPILING_WINDOWS_DLL)
       copy_tag_nolock(p,info,q,sizeofW(StgHeader)+1,gen_no,tag);
 #else
       StgWord w = (StgWord)q->payload[0];
index 881d427..e7e02e6 100644 (file)
@@ -313,7 +313,7 @@ scavenge_srt (StgClosure **srt, nat srt_bitmap)
 
   while (bitmap != 0) {
       if ((bitmap & 1) != 0) {
-#if defined(__PIC__) && defined(mingw32_HOST_OS)
+#if defined(COMPILING_WINDOWS_DLL)
          // Special-case to handle references to closures hiding out in DLLs, since
          // double indirections required to get at those. The code generator knows
          // which is which when generating the SRT, so it stores the (indirect)
index 9561ea6..234d4dc 100644 (file)
@@ -152,7 +152,7 @@ ioManagerStart (void)
     Capability *cap;\r
     if (io_manager_event == INVALID_HANDLE_VALUE) {\r
        cap = rts_lock();\r
-#if defined(mingw32_HOST_OS) && defined(i386_HOST_ARCH) && defined(__PIC__)\r
+#if defined(COMPILING_WINDOWS_DLL)\r
         rts_evalIO(&cap,_imp__base_GHCziConcziIO_ensureIOManagerIsRunning_closure,NULL);\r
 #else\r
         rts_evalIO(&cap,&base_GHCziConcziIO_ensureIOManagerIsRunning_closure,NULL);\r