Skip to content

Commit

Permalink
Updated patches
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtiomTr committed Oct 12, 2024
1 parent 71d59c8 commit e1919d4
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 27 deletions.
2 changes: 1 addition & 1 deletion blst/csharp.patch
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ index df1730c..6b5bc2f 100644

INCLUDE_DIRS = ../../src ../../blst/bindings
-TARGETS = ckzg_wrap.c ../../src/ckzg.c ../../blst/$(BLST_OBJ)
+TARGETS = ckzg_wrap.c ../../../../target/release/rust_kzg_blst.a
+TARGETS = ckzg_wrap.c ../../lib/librust_kzg_blst.a

CFLAGS += -O2 -Wall -Wextra -shared
CFLAGS += ${addprefix -I,${INCLUDE_DIRS}}
Expand Down
2 changes: 1 addition & 1 deletion blst/go.patch
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ index c912d09..edcc96f 100644
+// #endif
+// #include <stdlib.h>
+// #include "c_kzg_4844.h"
+// #cgo LDFLAGS: -L${SRCDIR}/../../../../target/release -l:rust_kzg_blst.a -lm
+// #cgo LDFLAGS: -L${SRCDIR}/../../target/release -lrust_kzg_blst -lm
import "C"

import (
Expand Down
2 changes: 1 addition & 1 deletion blst/java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ index 3f646ef..4be49ba 100644
INCLUDE_DIRS = ../../src ../../blst/bindings

-TARGETS=ckzg_jni.c ../../src/ckzg.c ../../lib/libblst.a
+TARGETS=ckzg_jni.c ../../../../target/release/rust_kzg_blst.a
+TARGETS=ckzg_jni.c ../../lib/librust_kzg_blst.a

CC_FLAGS=
OPTIMIZATION_LEVEL=-O2
Expand Down
12 changes: 2 additions & 10 deletions blst/nim.patch
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,13 @@ diff --git a/bindings/nim/kzg_abi.nim b/bindings/nim/kzg_abi.nim
index 0570efd..59e678e 100644
--- a/bindings/nim/kzg_abi.nim
+++ b/bindings/nim/kzg_abi.nim
@@ -10,6 +10,7 @@ from os import DirSep, AltSep
const
# kzgPath: c-kzg-4844 project path, removing 3 last elem
kzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 3)[0] & "/"
+ rustKzgPath = currentSourcePath.rsplit({DirSep, AltSep}, 5)[0] & "/"
blstPath = kzgPath & "blst/"
srcPath = kzgPath & "src/"
bindingsPath = blstPath & "bindings"
@@ -20,7 +21,9 @@ when not defined(kzgExternalBlst):
{.compile: blstPath & "src/server.c"}
{.passc: "-D__BLST_PORTABLE__"}

-{.compile: srcPath & "ckzg.c"}
++{.passl: "-L" & rustKzgPath & "target/release" .}
++{.passl: "-l:rust_kzg_blst.a" .}
++{.passl: "-L" & kzgPath & "lib" .}
++{.passl: "-lrust_kzg_blst" .}
++{.passl: "-lm" .}

{.passc: "-I" & escape(bindingsPath) .}
Expand Down
2 changes: 1 addition & 1 deletion blst/nodejs.patch
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ index d01e38b..1591b8e 100644
"<!@(node -p \"require('node-addon-api').include\")"
],
+ "libraries": [
+ "<(module_root_dir)/../../../../target/release/rust_kzg_blst.a"
+ "<(module_root_dir)/../../lib/librust_kzg_blst.a"
+ ],
"defines": [
"__BLST_PORTABLE__",
Expand Down
15 changes: 7 additions & 8 deletions blst/python.patch
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
From 8bc31450ffa85ef911550cf35115e89e6ca7b630 Mon Sep 17 00:00:00 2001
From 3c414d6a692f258023f6f4630f447244a7185021 Mon Sep 17 00:00:00 2001
From: sirse <artiom.tretjakovas2@gmail.com>
Date: Wed, 2 Oct 2024 06:58:36 +0000
Date: Sat, 12 Oct 2024 16:57:40 +0000
Subject: [PATCH] Patch python bindings

---
setup.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
setup.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/setup.py b/setup.py
index d16c833..e504d12 100644
index d16c833..b604f1d 100644
--- a/setup.py
+++ b/setup.py
@@ -35,10 +35,10 @@ def main():
Expand All @@ -18,10 +18,9 @@ index d16c833..e504d12 100644
- sources=["bindings/python/ckzg_wrap.c", "src/ckzg.c"],
+ sources=["bindings/python/ckzg_wrap.c"],
include_dirs=["inc", "src"],
- library_dirs=["lib"],
library_dirs=["lib"],
- libraries=["blst"]
+ library_dirs=["lib", "../../target/release"],
+ libraries=[":rust_kzg_blst.a"]
+ libraries=["rust_kzg_blst"]
)
],
cmdclass={
Expand Down
4 changes: 2 additions & 2 deletions blst/rust.patch
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ index 45eb72d..994c83f 100644
- // Obtain the header files of blst
- let blst_base_dir = root_dir.join("blst");
- let blst_headers_dir = blst_base_dir.join("bindings");
+ let rust_kzg_target_dir = root_dir.join("../../target/release/");
+ let rust_kzg_target_dir = root_dir.join("lib");

- let c_src_dir = root_dir.join("src");
-
Expand Down Expand Up @@ -69,7 +69,7 @@ index 45eb72d..994c83f 100644
- // Finally, tell cargo this provides ckzg/ckzg_min
- println!("cargo:rustc-link-lib=ckzg");
+ println!("cargo:rustc-link-search={}", rust_kzg_target_dir.display());
+ println!("cargo:rustc-link-arg=-l:rust_kzg_blst.a");
+ println!("cargo:rustc-link-arg=-lrust_kzg_blst");
}

#[cfg(feature = "generate-bindings")]
Expand Down
5 changes: 2 additions & 3 deletions run-c-kzg-4844-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ else
cargo rustc --release --crate-type=staticlib
fi

rm -f ../target/release/rust_kzg_$backend.a
mv ../target/release/librust_kzg_$backend.a ../target/release/rust_kzg_$backend.a

###################### cloning c-kzg-4844 ######################

print_msg "Removing existing c-kzg-4844"
Expand All @@ -57,6 +54,8 @@ cd c-kzg-4844 || exit
git -c advice.detachedHead=false checkout "$C_KZG_4844_GIT_HASH"
git submodule update --init

mv ../../target/release/librust_kzg_$backend.a ./lib

print_msg "Applying patches and building blst"
cd src
# export CFLAGS="-Ofast -fno-builtin-memcpy -fPIC -Wall -Wextra -Werror"
Expand Down

0 comments on commit e1919d4

Please sign in to comment.