Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion modules/configuration-nix.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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)