From 5b973ce7e105d9d68d08024fbf9b9025479ec9a8 Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Wed, 26 Nov 2025 12:04:23 -0700 Subject: [PATCH 1/2] Patch libblst to overcome duplicate symbol definition problem --- overlays/crypto/libblst.nix | 2 ++ overlays/crypto/libblst.patch | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 overlays/crypto/libblst.patch diff --git a/overlays/crypto/libblst.nix b/overlays/crypto/libblst.nix index 3ba1d3d3..ab6ccec9 100644 --- a/overlays/crypto/libblst.nix +++ b/overlays/crypto/libblst.nix @@ -6,6 +6,8 @@ stdenv.mkDerivation rec { inherit src; + patches = [ ./libblst.patch ]; + # note on -D__BLST_PORTABLE__, this should allow us to have MULX, and similar # stuff run-time detected, and as such blst built on newer hardware should still # work on older. Notably Intel before Broadwell, and AMD before Ryzen, do not diff --git a/overlays/crypto/libblst.patch b/overlays/crypto/libblst.patch new file mode 100644 index 00000000..127f1e26 --- /dev/null +++ b/overlays/crypto/libblst.patch @@ -0,0 +1,42 @@ +From 6b86fb03c7d1396db7972a09acbb94319e7e5824 Mon Sep 17 00:00:00 2001 +From: Neil Mayhew +Date: Wed, 26 Nov 2025 12:33:37 -0700 +Subject: [PATCH] Fix inconsistency in how __blst_platform_cap is defined +Content-Type: text/plain; charset=utf-8 + +In C it's a BSS symbol, and in assembly it's a common symbol: + +$ nm -og libblst.a | grep __blst_platform_cap +libblst.a:assembly.o:0000000000000004 C __blst_platform_cap +libblst.a:server.o:0000000000000000 B __blst_platform_cap + +This causes problems for some toolchains. + +With this change, it becomes: + +$ nm -og libblst.a | grep __blst_platform_cap +libblst.a:assembly.o:0000000000000004 C __blst_platform_cap +libblst.a:server.o:0000000000000004 C __blst_platform_cap +--- + src/cpuid.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/cpuid.c b/src/cpuid.c +index a1a01d4..bbba87e 100644 +--- a/src/cpuid.c ++++ b/src/cpuid.c +@@ -5,9 +5,9 @@ + */ + + #if (defined(__GNUC__) || defined(__clang__) || defined(__SUNPRO_C)) && !defined(_WIN32) +-__attribute__((visibility("hidden"))) ++__attribute__((visibility("hidden"), common)) + #endif +-int __blst_platform_cap = 0; ++int __blst_platform_cap; + + #if defined(__x86_64__) || defined(__x86_64) || (defined(_M_X64) && !defined(_M_ARM64EC)) + +-- +2.51.0 + From 93dba981e866a6bf000f620f70d85db7da9dcfcf Mon Sep 17 00:00:00 2001 From: Neil Mayhew Date: Wed, 26 Nov 2025 15:01:47 -0700 Subject: [PATCH 2/2] Take the libblst patch from the upstream PR --- overlays/crypto/libblst.nix | 9 ++++++-- overlays/crypto/libblst.patch | 42 ----------------------------------- 2 files changed, 7 insertions(+), 44 deletions(-) delete mode 100644 overlays/crypto/libblst.patch diff --git a/overlays/crypto/libblst.nix b/overlays/crypto/libblst.nix index ab6ccec9..9f35924d 100644 --- a/overlays/crypto/libblst.nix +++ b/overlays/crypto/libblst.nix @@ -1,4 +1,4 @@ -{ stdenv, lib, autoreconfHook, enableShared ? !stdenv.hostPlatform.isStatic && !stdenv.hostPlatform.isWindows, src }: +{ stdenv, lib, autoreconfHook, enableShared ? !stdenv.hostPlatform.isStatic && !stdenv.hostPlatform.isWindows, fetchpatch, src }: stdenv.mkDerivation rec { pname = "blst"; @@ -6,7 +6,12 @@ stdenv.mkDerivation rec { inherit src; - patches = [ ./libblst.patch ]; + patches = [ + (fetchpatch { + url = https://github.com/supranational/blst/pull/276.diff; + hash = "sha256-ccGbrtGXfwDxBXY1ahPSjsODRW1tSmCMYWqDy6mNnLg="; + }) + ]; # note on -D__BLST_PORTABLE__, this should allow us to have MULX, and similar # stuff run-time detected, and as such blst built on newer hardware should still diff --git a/overlays/crypto/libblst.patch b/overlays/crypto/libblst.patch deleted file mode 100644 index 127f1e26..00000000 --- a/overlays/crypto/libblst.patch +++ /dev/null @@ -1,42 +0,0 @@ -From 6b86fb03c7d1396db7972a09acbb94319e7e5824 Mon Sep 17 00:00:00 2001 -From: Neil Mayhew -Date: Wed, 26 Nov 2025 12:33:37 -0700 -Subject: [PATCH] Fix inconsistency in how __blst_platform_cap is defined -Content-Type: text/plain; charset=utf-8 - -In C it's a BSS symbol, and in assembly it's a common symbol: - -$ nm -og libblst.a | grep __blst_platform_cap -libblst.a:assembly.o:0000000000000004 C __blst_platform_cap -libblst.a:server.o:0000000000000000 B __blst_platform_cap - -This causes problems for some toolchains. - -With this change, it becomes: - -$ nm -og libblst.a | grep __blst_platform_cap -libblst.a:assembly.o:0000000000000004 C __blst_platform_cap -libblst.a:server.o:0000000000000004 C __blst_platform_cap ---- - src/cpuid.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/src/cpuid.c b/src/cpuid.c -index a1a01d4..bbba87e 100644 ---- a/src/cpuid.c -+++ b/src/cpuid.c -@@ -5,9 +5,9 @@ - */ - - #if (defined(__GNUC__) || defined(__clang__) || defined(__SUNPRO_C)) && !defined(_WIN32) --__attribute__((visibility("hidden"))) -+__attribute__((visibility("hidden"), common)) - #endif --int __blst_platform_cap = 0; -+int __blst_platform_cap; - - #if defined(__x86_64__) || defined(__x86_64) || (defined(_M_X64) && !defined(_M_ARM64EC)) - --- -2.51.0 -