Marge Bot pushed to branch master at Glasgow Haskell Compiler / GHC
Commits:
-
b8cfa8f7
by Cheng Shao at 2025-09-19T18:29:01-04:00
8 changed files:
- โ rts/RtsDllMain.c
- โ rts/RtsDllMain.h
- rts/RtsSymbols.c
- rts/StgMiscClosures.cmm
- rts/include/RtsAPI.h
- rts/include/stg/DLL.h
- rts/rts.cabal
- rts/sm/Evac.c
Changes:
| 1 | -/* -----------------------------------------------------------------------------
|
|
| 2 | - *
|
|
| 3 | - * (c) The GHC Team 1999-2000
|
|
| 4 | - *
|
|
| 5 | - * Entry point for RTS-in-a-DLL
|
|
| 6 | - *
|
|
| 7 | - * ---------------------------------------------------------------------------*/
|
|
| 8 | - |
|
| 9 | -#include "rts/PosixSource.h"
|
|
| 10 | -#include "Rts.h"
|
|
| 11 | -#include "RtsAPI.h"
|
|
| 12 | -#include "RtsDllMain.h"
|
|
| 13 | - |
|
| 14 | -#if defined(HAVE_WINDOWS_H)
|
|
| 15 | -#include <windows.h>
|
|
| 16 | -#endif
|
|
| 17 | - |
|
| 18 | -/* I'd be mildly surprised if this wasn't defined, but still. */
|
|
| 19 | -#if defined(COMPILING_WINDOWS_DLL)
|
|
| 20 | -BOOL
|
|
| 21 | -WINAPI
|
|
| 22 | -DllMain ( HINSTANCE hInstance STG_UNUSED
|
|
| 23 | - , DWORD reason
|
|
| 24 | - , LPVOID reserved STG_UNUSED
|
|
| 25 | - )
|
|
| 26 | -{
|
|
| 27 | - /*
|
|
| 28 | - * Note: the DllMain() doesn't call startupHaskell() for you,
|
|
| 29 | - * that is the task of users of the RTS. The reason is
|
|
| 30 | - * that *you* want to be able to control the arguments
|
|
| 31 | - * you pass to the RTS.
|
|
| 32 | - */
|
|
| 33 | - switch (reason) {
|
|
| 34 | - |
|
| 35 | - // shutdownHaskelAndExit() is already being called,
|
|
| 36 | - // so I don't think we need this. BL 2009/11/17
|
|
| 37 | - |
|
| 38 | - //case DLL_PROCESS_DETACH: shutdownHaskell();
|
|
| 39 | - }
|
|
| 40 | - return true;
|
|
| 41 | -}
|
|
| 42 | - |
|
| 43 | -#endif |
| 1 | -#include "Rts.h"
|
|
| 2 | - |
|
| 3 | -#if defined(HAVE_WINDOWS_H)
|
|
| 4 | -#include <windows.h>
|
|
| 5 | -#endif
|
|
| 6 | - |
|
| 7 | -/* I'd be mildly surprised if this wasn't defined, but still. */
|
|
| 8 | -#if defined(COMPILING_WINDOWS_DLL)
|
|
| 9 | -BOOL
|
|
| 10 | -WINAPI
|
|
| 11 | -DllMain ( HINSTANCE hInstance
|
|
| 12 | - , DWORD reason
|
|
| 13 | - , LPVOID reserved
|
|
| 14 | - );
|
|
| 15 | -#endif |
| ... | ... | @@ -435,17 +435,9 @@ extern char **environ; |
| 435 | 435 | |
| 436 | 436 | // On most platforms, the garbage collector rewrites references
|
| 437 | 437 | // to small integer and char objects to a set of common, shared ones.
|
| 438 | -//
|
|
| 439 | -// We don't do this when compiling to Windows DLLs at the moment because
|
|
| 440 | -// it doesn't support cross package data references well.
|
|
| 441 | -//
|
|
| 442 | -#if defined(COMPILING_WINDOWS_DLL)
|
|
| 443 | -#define RTS_INTCHAR_SYMBOLS
|
|
| 444 | -#else
|
|
| 445 | 438 | #define RTS_INTCHAR_SYMBOLS \
|
| 446 | 439 | SymI_HasProto(stg_CHARLIKE_closure) \
|
| 447 | 440 | SymI_HasProto(stg_INTLIKE_closure)
|
| 448 | -#endif
|
|
| 449 | 441 | |
| 450 | 442 | #if defined(PROFILING)
|
| 451 | 443 | #define RTS_PROF_SYMBOLS \
|
| ... | ... | @@ -1027,20 +1019,9 @@ extern char **environ; |
| 1027 | 1019 | /* entirely bogus claims about types of these symbols */
|
| 1028 | 1020 | #define SymI_NeedsProto(vvv) extern void vvv(void);
|
| 1029 | 1021 | #define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
|
| 1030 | -#if defined(COMPILING_WINDOWS_DLL)
|
|
| 1031 | -#define SymE_HasProto(vvv) SymE_HasProto(vvv);
|
|
| 1032 | -# if defined(x86_64_HOST_ARCH)
|
|
| 1033 | -# define SymE_NeedsProto(vvv) extern void __imp_ ## vvv (void);
|
|
| 1034 | -# define SymE_NeedsDataProto(vvv) SymE_NeedsProto(vvv)
|
|
| 1035 | -# else
|
|
| 1036 | -# define SymE_NeedsProto(vvv) extern void _imp__ ## vvv (void);
|
|
| 1037 | -# define SymE_NeedsDataProto(vvv) SymE_NeedsProto(vvv)
|
|
| 1038 | -# endif
|
|
| 1039 | -#else
|
|
| 1040 | 1022 | #define SymE_NeedsProto(vvv) SymI_NeedsProto(vvv);
|
| 1041 | 1023 | #define SymE_NeedsDataProto(vvv) SymI_NeedsDataProto(vvv);
|
| 1042 | 1024 | #define SymE_HasProto(vvv) SymI_HasProto(vvv);
|
| 1043 | -#endif
|
|
| 1044 | 1025 | #define SymI_HasProto(vvv) /**/
|
| 1045 | 1026 | #define SymI_HasDataProto(vvv) /**/
|
| 1046 | 1027 | #define SymI_HasProto_redirect(vvv,xxx,strength,ty) /**/
|
| ... | ... | @@ -1040,28 +1040,12 @@ CLOSURE(stg_ASYNCIO_LIVE0_closure,stg_ASYNCIO_LIVE0); |
| 1040 | 1040 | replace them with references to the static objects.
|
| 1041 | 1041 | ------------------------------------------------------------------------- */
|
| 1042 | 1042 | |
| 1043 | -#if defined(COMPILING_WINDOWS_DLL)
|
|
| 1044 | -/*
|
|
| 1045 | - * When sticking the RTS in a Windows DLL, we delay populating the
|
|
| 1046 | - * Charlike and Intlike tables until load-time, which is only
|
|
| 1047 | - * when we've got the real addresses to the C# and I# closures.
|
|
| 1048 | - *
|
|
| 1049 | - * -- this is currently broken BL 2009/11/14.
|
|
| 1050 | - * we don't rewrite to static closures at all with Windows DLLs.
|
|
| 1051 | - */
|
|
| 1052 | -// #warning Is this correct? _imp is a pointer!
|
|
| 1053 | -#define Char_hash_con_info _imp__ghczminternal_GHCziInternalziTypes_Czh_con_info
|
|
| 1054 | -#define Int_hash_con_info _imp__ghczminternal_GHCziInternalziTypes_Izh_con_info
|
|
| 1055 | -#else
|
|
| 1056 | 1043 | #define Char_hash_con_info ghczminternal_GHCziInternalziTypes_Czh_con_info
|
| 1057 | 1044 | #define Int_hash_con_info ghczminternal_GHCziInternalziTypes_Izh_con_info
|
| 1058 | -#endif
|
|
| 1059 | - |
|
| 1060 | 1045 | |
| 1061 | 1046 | #define CHARLIKE_HDR(n) CLOSURE(Char_hash_con_info, n)
|
| 1062 | 1047 | #define INTLIKE_HDR(n) CLOSURE(Int_hash_con_info, n)
|
| 1063 | 1048 | |
| 1064 | -#if !(defined(COMPILING_WINDOWS_DLL))
|
|
| 1065 | 1049 | section "data" {
|
| 1066 | 1050 | stg_CHARLIKE_closure:
|
| 1067 | 1051 | CHARLIKE_HDR(0)
|
| ... | ... | @@ -1598,5 +1582,3 @@ section "data" { |
| 1598 | 1582 | INTLIKE_HDR(255) /* MAX_INTLIKE == 255
|
| 1599 | 1583 | See #16961 for why 255 */
|
| 1600 | 1584 | } |
| 1601 | - |
|
| 1602 | -#endif |
| ... | ... | @@ -581,19 +581,11 @@ void rts_done (void); |
| 581 | 581 | These are used by foreign export and foreign import "wrapper" stubs.
|
| 582 | 582 | ----------------------------------------------------------------------- */
|
| 583 | 583 | |
| 584 | -// When producing Windows DLLs the we need to know which symbols are in the
|
|
| 585 | -// local package/DLL vs external ones.
|
|
| 586 | -//
|
|
| 587 | 584 | // Note that RtsAPI.h is also included by foreign export stubs in
|
| 588 | 585 | // the base package itself.
|
| 589 | 586 | //
|
| 590 | -#if defined(COMPILING_WINDOWS_DLL) && !defined(COMPILING_GHC_INTERNAL_PACKAGE)
|
|
| 591 | -__declspec(dllimport) extern StgClosure ghczminternal_GHCziInternalziTopHandler_runIO_closure;
|
|
| 592 | -__declspec(dllimport) extern StgClosure ghczminternal_GHCziInternalziTopHandler_runNonIO_closure;
|
|
| 593 | -#else
|
|
| 594 | 587 | extern StgClosure ghczminternal_GHCziInternalziTopHandler_runIO_closure;
|
| 595 | 588 | extern StgClosure ghczminternal_GHCziInternalziTopHandler_runNonIO_closure;
|
| 596 | -#endif
|
|
| 597 | 589 | |
| 598 | 590 | #define runIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runIO_closure)
|
| 599 | 591 | #define runNonIO_closure DLL_IMPORT_DATA_REF(ghczminternal_GHCziInternalziTopHandler_runNonIO_closure)
|
| ... | ... | @@ -13,29 +13,9 @@ |
| 13 | 13 | |
| 14 | 14 | #pragma once
|
| 15 | 15 | |
| 16 | -#if defined(COMPILING_WINDOWS_DLL)
|
|
| 17 | -# if defined(x86_64_HOST_ARCH)
|
|
| 18 | -# define DLL_IMPORT_DATA_REF(x) (__imp_##x)
|
|
| 19 | -# define DLL_IMPORT_DATA_VARNAME(x) *__imp_##x
|
|
| 20 | -# else
|
|
| 21 | -# define DLL_IMPORT_DATA_REF(x) (_imp__##x)
|
|
| 22 | -# define DLL_IMPORT_DATA_VARNAME(x) *_imp__##x
|
|
| 23 | -# endif
|
|
| 24 | -# if __GNUC__ && !defined(__declspec)
|
|
| 25 | -# define DLLIMPORT
|
|
| 26 | -# else
|
|
| 27 | -# define DLLIMPORT __declspec(dllimport)
|
|
| 28 | -# if defined(x86_64_HOST_ARCH)
|
|
| 29 | -# define DLLIMPORT_DATA(x) __imp_##x
|
|
| 30 | -# else
|
|
| 31 | -# define DLLIMPORT_DATA(x) _imp__##x
|
|
| 32 | -# endif
|
|
| 33 | -# endif
|
|
| 34 | -#else
|
|
| 35 | 16 | # define DLL_IMPORT_DATA_REF(x) (&(x))
|
| 36 | 17 | # define DLL_IMPORT_DATA_VARNAME(x) x
|
| 37 | 18 | # define DLLIMPORT
|
| 38 | -#endif
|
|
| 39 | 19 | |
| 40 | 20 | /* The view of the rts/include/ header files differ ever so
|
| 41 | 21 | slightly depending on whether the RTS is being compiled
|
| ... | ... | @@ -47,26 +27,9 @@ |
| 47 | 27 | using Win32 DLLs. ]
|
| 48 | 28 | */
|
| 49 | 29 | #if defined(COMPILING_RTS)
|
| 50 | -#define DLL_IMPORT DLLIMPORT
|
|
| 51 | 30 | #define DLL_IMPORT_RTS
|
| 52 | 31 | #define DLL_IMPORT_DATA_VAR(x) x
|
| 53 | 32 | #else
|
| 54 | -#define DLL_IMPORT
|
|
| 55 | 33 | #define DLL_IMPORT_RTS DLLIMPORT
|
| 56 | -# if defined(COMPILING_WINDOWS_DLL)
|
|
| 57 | -# if defined(x86_64_HOST_ARCH)
|
|
| 58 | -# define DLL_IMPORT_DATA_VAR(x) __imp_##x
|
|
| 59 | -# else
|
|
| 60 | -# define DLL_IMPORT_DATA_VAR(x) _imp__##x
|
|
| 61 | -# endif
|
|
| 62 | -# else
|
|
| 63 | -# define DLL_IMPORT_DATA_VAR(x) x
|
|
| 64 | -# endif
|
|
| 65 | -#endif
|
|
| 66 | - |
|
| 67 | - |
|
| 68 | -#if defined(COMPILING_STDLIB)
|
|
| 69 | -#define DLL_IMPORT_STDLIB
|
|
| 70 | -#else
|
|
| 71 | -#define DLL_IMPORT_STDLIB DLLIMPORT
|
|
| 34 | +#define DLL_IMPORT_DATA_VAR(x) x
|
|
| 72 | 35 | #endif |
| ... | ... | @@ -443,7 +443,6 @@ library |
| 443 | 443 | RetainerProfile.c
|
| 444 | 444 | RetainerSet.c
|
| 445 | 445 | RtsAPI.c
|
| 446 | - RtsDllMain.c
|
|
| 447 | 446 | RtsFlags.c
|
| 448 | 447 | RtsMain.c
|
| 449 | 448 | RtsMessages.c
|
| ... | ... | @@ -857,9 +857,6 @@ loop: |
| 857 | 857 | //
|
| 858 | 858 | case CONSTR_0_1:
|
| 859 | 859 | {
|
| 860 | -#if defined(COMPILING_WINDOWS_DLL)
|
|
| 861 | - copy_tag_nolock(p,info,q,sizeofW(StgHeader)+1,gen_no,tag);
|
|
| 862 | -#else
|
|
| 863 | 860 | StgWord w = (StgWord)q->payload[0];
|
| 864 | 861 | if (info == Czh_con_info &&
|
| 865 | 862 | // unsigned, so always true: (StgChar)w >= MIN_CHARLIKE &&
|
| ... | ... | @@ -879,7 +876,6 @@ loop: |
| 879 | 876 | else {
|
| 880 | 877 | copy_tag_nolock(p,info,q,sizeofW(StgHeader)+1,gen_no,tag);
|
| 881 | 878 | }
|
| 882 | -#endif
|
|
| 883 | 879 | return;
|
| 884 | 880 | }
|
| 885 | 881 |