Skip to content

Commit 5b973ce

Browse files
committed
Patch libblst to overcome duplicate symbol definition problem
1 parent a704b93 commit 5b973ce

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

overlays/crypto/libblst.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ stdenv.mkDerivation rec {
66

77
inherit src;
88

9+
patches = [ ./libblst.patch ];
10+
911
# note on -D__BLST_PORTABLE__, this should allow us to have MULX, and similar
1012
# stuff run-time detected, and as such blst built on newer hardware should still
1113
# work on older. Notably Intel before Broadwell, and AMD before Ryzen, do not

overlays/crypto/libblst.patch

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
From 6b86fb03c7d1396db7972a09acbb94319e7e5824 Mon Sep 17 00:00:00 2001
2+
From: Neil Mayhew <neil@mayhew.name>
3+
Date: Wed, 26 Nov 2025 12:33:37 -0700
4+
Subject: [PATCH] Fix inconsistency in how __blst_platform_cap is defined
5+
Content-Type: text/plain; charset=utf-8
6+
7+
In C it's a BSS symbol, and in assembly it's a common symbol:
8+
9+
$ nm -og libblst.a | grep __blst_platform_cap
10+
libblst.a:assembly.o:0000000000000004 C __blst_platform_cap
11+
libblst.a:server.o:0000000000000000 B __blst_platform_cap
12+
13+
This causes problems for some toolchains.
14+
15+
With this change, it becomes:
16+
17+
$ nm -og libblst.a | grep __blst_platform_cap
18+
libblst.a:assembly.o:0000000000000004 C __blst_platform_cap
19+
libblst.a:server.o:0000000000000004 C __blst_platform_cap
20+
---
21+
src/cpuid.c | 4 ++--
22+
1 file changed, 2 insertions(+), 2 deletions(-)
23+
24+
diff --git a/src/cpuid.c b/src/cpuid.c
25+
index a1a01d4..bbba87e 100644
26+
--- a/src/cpuid.c
27+
+++ b/src/cpuid.c
28+
@@ -5,9 +5,9 @@
29+
*/
30+
31+
#if (defined(__GNUC__) || defined(__clang__) || defined(__SUNPRO_C)) && !defined(_WIN32)
32+
-__attribute__((visibility("hidden")))
33+
+__attribute__((visibility("hidden"), common))
34+
#endif
35+
-int __blst_platform_cap = 0;
36+
+int __blst_platform_cap;
37+
38+
#if defined(__x86_64__) || defined(__x86_64) || (defined(_M_X64) && !defined(_M_ARM64EC))
39+
40+
--
41+
2.51.0
42+

0 commit comments

Comments
 (0)