Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
hamishmack committed Dec 2, 2021
1 parent aabf926 commit d9e73e3
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
1 change: 1 addition & 0 deletions overlays/bootstrap.nix
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ in {
++ fromUntil "8.10" "9.2.2" ./patches/ghc/MR6654-nonmoving-maxmem.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6654
++ fromUntil "8.10" "8.10.8" ./patches/ghc/MR6617-nonmoving-mvar.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6617
++ fromUntil "8.10" "8.10.8" ./patches/ghc/MR6595-nonmoving-mutvar.patch # https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6595
++ fromUntil "8.10" "8.11" ./patches/ghc/ghc-8.10-global-unique-counters-in-rts.patch # backport of https://gitlab.haskell.org/ghc/ghc/-/commit/9a28680d2e23e7b25dd7254a439aea31dfae32d5
;
in ({
ghc844 = final.callPackage ../compiler/ghc {
Expand Down
53 changes: 53 additions & 0 deletions overlays/patches/ghc/ghc-8.10-global-unique-counters-in-rts.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
diff --git a/compiler/cbits/genSym.c b/compiler/cbits/genSym.c
index ecb318d5a8..8e70db33fc 100644
--- a/compiler/cbits/genSym.c
+++ b/compiler/cbits/genSym.c
@@ -1,9 +1,15 @@
#include <Rts.h>
#include <assert.h>
#include "Unique.h"
+#include "ghcversion.h"

+// These global variables have been moved into the RTS. It allows them to be
+// shared with plugins even if two different instances of the GHC library are
+// loaded at the same time (#19940)
+#if !MIN_VERSION_GLASGOW_HASKELL(8,10,0,0)
static HsInt GenSymCounter = 0;
static HsInt GenSymInc = 1;
+#endif

#define UNIQUE_BITS (sizeof (HsInt) * 8 - UNIQUE_TAG_BITS)
#define UNIQUE_MASK ((1ULL << UNIQUE_BITS) - 1)
diff --git a/includes/rts/Globals.h b/includes/rts/Globals.h
index ff36572c56..12db025423 100644
--- a/includes/rts/Globals.h
+++ b/includes/rts/Globals.h
@@ -34,3 +34,5 @@ mkStoreAccessorPrototype(LibHSghcInitLinkerDone)
mkStoreAccessorPrototype(LibHSghcGlobalDynFlags)
mkStoreAccessorPrototype(LibHSghcStaticOptions)
mkStoreAccessorPrototype(LibHSghcStaticOptionsReady)
+extern HsInt GenSymCounter;
+extern HsInt GenSymInc;
diff --git a/rts/Globals.c b/rts/Globals.c
index c9980d9a3a..56522937ef 100644
--- a/rts/Globals.c
+++ b/rts/Globals.c
@@ -111,3 +111,5 @@ mkStoreAccessor(LibHSghcInitLinkerDone)
mkStoreAccessor(LibHSghcGlobalDynFlags)
mkStoreAccessor(LibHSghcStaticOptions)
mkStoreAccessor(LibHSghcStaticOptionsReady)
+HsInt GenSymCounter = 0;
+HsInt GenSymInc = 1;
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
index d5b8cc5fec..7ed561ff3f 100644
--- a/rts/RtsSymbols.c
+++ b/rts/RtsSymbols.c
@@ -646,6 +646,8 @@
SymI_HasProto(getOrSetLibHSghcPersistentLinkerState) \
SymI_HasProto(getOrSetLibHSghcInitLinkerDone) \
SymI_HasProto(getOrSetLibHSghcGlobalDynFlags) \
+ SymI_HasProto(GenSymCounter) \
+ SymI_HasProto(GenSymInc) \
SymI_HasProto(genericRaise) \
SymI_HasProto(getProgArgv) \
SymI_HasProto(getFullProgArgv) \

0 comments on commit d9e73e3

Please sign in to comment.