Fix for ghc-lib-parser 9.2 and haskell.nix patched ghc (#1502)

Fixes #1488
This commit is contained in:
Hamish Mackenzie 2022-06-02 15:00:54 +12:00 committed by GitHub
parent a5b85df063
commit 4b61024e55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -58,7 +58,8 @@ in {
packages.mintty.components.library.build-tools = pkgs.lib.mkForce [];
packages.ghc-lib-parser.patches = [
(fromUntil "8.10.0.0" "9.1" ../overlays/patches/ghc-lib-parser-8.10-global-unique-counters-in-rts.patch)
(fromUntil "8.10.0.0" "9.2" ../overlays/patches/ghc-lib-parser-8.10-global-unique-counters-in-rts.patch)
(fromUntil "9.2.0.0" "9.3" ../overlays/patches/ghc-lib-parser-9.2-global-unique-counters-in-rts.patch)
];
# See https://github.com/haskell-nix/hnix/pull/1053

View File

@ -0,0 +1,20 @@
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(9,2,0,0)
HsInt ghc_unique_counter = 0;
HsInt ghc_unique_inc = 1;
+#endif
#define UNIQUE_BITS (sizeof (HsInt) * 8 - UNIQUE_TAG_BITS)
#define UNIQUE_MASK ((1ULL << UNIQUE_BITS) - 1)