diff options
author | wolfgang <unknown> | 2005-04-07 05:27:17 +0000 |
---|---|---|
committer | wolfgang <unknown> | 2005-04-07 05:27:17 +0000 |
commit | d79c1cb2dc7c1ec5cd1ac4cb19d80c056ac2dd5d (patch) | |
tree | f638973e8f20fda46e162d980ff218c67eb95871 /ghc | |
parent | ba69efdd1d74ce728e790ea8bb682a5b41aa51fb (diff) | |
download | haskell-d79c1cb2dc7c1ec5cd1ac4cb19d80c056ac2dd5d.tar.gz |
[project @ 2005-04-07 05:27:16 by wolfgang]
Set the keepCAFs flag (required for GHCi with dynamic libraries) from an
__attribute__((constructor)) function linked to stage 2 ghc if GhcBuildDylibs
is set in mk/build.mk.
The previous hack (setting it from addDLL) didn't work, because a few CAFs
from libHSbase_dyn were evaluated before the Linker was first invoked by
GHCi.
MERGE TO STABLE
Diffstat (limited to 'ghc')
-rw-r--r-- | ghc/compiler/Makefile | 10 | ||||
-rw-r--r-- | ghc/compiler/ghci/keepCAFsForGHCi.c | 15 | ||||
-rw-r--r-- | ghc/rts/Linker.c | 18 |
3 files changed, 25 insertions, 18 deletions
diff --git a/ghc/compiler/Makefile b/ghc/compiler/Makefile index f9fbb55f9e..49601a4fb7 100644 --- a/ghc/compiler/Makefile +++ b/ghc/compiler/Makefile @@ -409,6 +409,16 @@ PKG_DEPENDS += template-haskell ALL_DIRS += ghci +# If we are going to use dynamic libraries instead of .o files for ghci, +# we will need to always retain CAFs in the compiler. +# ghci/keepCAFsForGHCi contains a GNU C __attribute__((constructor)) +# function which sets the keepCAFs flag for the RTS before any Haskell +# code is run. +ifeq "$(GhcBuildDylibs)" "YES" +else +EXCLUDED_SRCS += ghci/keepCAFsForGHCi.c +endif + # Enable readline if either: # - we're building stage 1 and $(GhcHasReadline)="YES" # - we're building stage 2/3, and we have built the readline package diff --git a/ghc/compiler/ghci/keepCAFsForGHCi.c b/ghc/compiler/ghci/keepCAFsForGHCi.c new file mode 100644 index 0000000000..0aabbedea0 --- /dev/null +++ b/ghc/compiler/ghci/keepCAFsForGHCi.c @@ -0,0 +1,15 @@ +#include "Rts.h" +#include "Storage.h" + +// This file is only included when GhcBuildDylibs is set in mk/build.mk. +// It contains an __attribute__((constructor)) function (run prior to main()) +// which sets the keepCAFs flag in the RTS, before any Haskell code is run. +// This is required so that GHCi can use dynamic libraries instead of HSxyz.o +// files. + +static void keepCAFsForGHCi() __attribute__((constructor)); + +static void keepCAFsForGHCi() +{ + keepCAFs = 1; +} diff --git a/ghc/rts/Linker.c b/ghc/rts/Linker.c index 3633e54f33..f57bb5a1f6 100644 --- a/ghc/rts/Linker.c +++ b/ghc/rts/Linker.c @@ -803,24 +803,6 @@ addDLL( char *dll_name ) void *hdl; char *errmsg; - // *** HACK - // If we load libHSbase_cbits_dyn.[so|dylib], - // then we know that we need to activate another newCAF - // related hack in Storage.c because we can't redirect - // newCAF to newDynCAF with the system dynamic linker. -#ifdef OBJFORMAT_MACHO - const char *hsbase = "/libHSbase_cbits_dyn.dylib"; -#else - const char *hsbase = "/libHSbase_cbits_dyn.so"; -#endif - int namelen = strlen(dll_name); - int baselen = strlen(hsbase); - if(namelen > baselen && !strcmp(dll_name + namelen - baselen, hsbase)) - { - keepCAFs = rtsTrue; - } - // *** END HACK. - initLinker(); hdl= dlopen(dll_name, RTLD_NOW | RTLD_GLOBAL); |