From 12086c65408dfd3079015554f61bca4cd75aac11 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 20 Oct 2023 13:44:18 +0800 Subject: [PATCH 1/3] Fix static linking on mac --- Makefile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b988d25..ecc50ac 100644 --- a/Makefile +++ b/Makefile @@ -1,14 +1,19 @@ +ifeq ($(shell uname), Darwin) + CGO_LDFLAGS := -framework Security +endif + .PHONY: build build: build-tfhe-rs-capi - cd fhevm && go build . + cd fhevm && CGO_LDFLAGS='$(CGO_LDFLAGS)' go build . .PHONY: test test: build-tfhe-rs-capi - cd fhevm && go test -v . + cd fhevm && CGO_LDFLAGS='$(CGO_LDFLAGS)' go test -v . .PHONY: build-tfhe-rs-capi build-tfhe-rs-capi: - cd tfhe-rs && make build_c_api_experimental_deterministic_fft + cd tfhe-rs && make build_c_api_experimental_deterministic_fft \ + && cd target/release && rm -f *.dylib *.dll *.so .PHONY: clean clean: From 60412d653b6fce674eb507206cd8ce5d92ac25f4 Mon Sep 17 00:00:00 2001 From: youben11 Date: Fri, 20 Oct 2023 10:12:22 +0100 Subject: [PATCH 2/3] fix(build): use different flags per platform --- Makefile | 11 +++-------- fhevm/tfhe.go | 6 ++++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index ecc50ac..b988d25 100644 --- a/Makefile +++ b/Makefile @@ -1,19 +1,14 @@ -ifeq ($(shell uname), Darwin) - CGO_LDFLAGS := -framework Security -endif - .PHONY: build build: build-tfhe-rs-capi - cd fhevm && CGO_LDFLAGS='$(CGO_LDFLAGS)' go build . + cd fhevm && go build . .PHONY: test test: build-tfhe-rs-capi - cd fhevm && CGO_LDFLAGS='$(CGO_LDFLAGS)' go test -v . + cd fhevm && go test -v . .PHONY: build-tfhe-rs-capi build-tfhe-rs-capi: - cd tfhe-rs && make build_c_api_experimental_deterministic_fft \ - && cd target/release && rm -f *.dylib *.dll *.so + cd tfhe-rs && make build_c_api_experimental_deterministic_fft .PHONY: clean clean: diff --git a/fhevm/tfhe.go b/fhevm/tfhe.go index 3eb6616..3b13160 100644 --- a/fhevm/tfhe.go +++ b/fhevm/tfhe.go @@ -17,8 +17,10 @@ package fhevm /* -#cgo CFLAGS: -O3 -I../tfhe-rs/target/release -#cgo LDFLAGS: -L../tfhe-rs/target/release -ltfhe -lm +#cgo linux CFLAGS: -O3 -I../tfhe-rs/target/release +#cgo linux LDFLAGS: -L../tfhe-rs/target/release -l:libtfhe.a -lm +#cgo darwin CFLAGS: -O3 -I../tfhe-rs/target/release ../tfhe-rs/target/release/libtfhe.a +#cgo darwin LDFLAGS: -framework Security -lm #include From a76ba474a32a34b91e01fa55185f243572604277 Mon Sep 17 00:00:00 2001 From: David Date: Fri, 20 Oct 2023 17:27:30 +0800 Subject: [PATCH 3/3] Another fix for mac --- Makefile | 3 ++- fhevm/tfhe.go | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b988d25..b8859d8 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,8 @@ test: build-tfhe-rs-capi .PHONY: build-tfhe-rs-capi build-tfhe-rs-capi: - cd tfhe-rs && make build_c_api_experimental_deterministic_fft + cd tfhe-rs && make build_c_api_experimental_deterministic_fft \ + && cd target/release && rm -f *.dylib *.dll *.so .PHONY: clean clean: diff --git a/fhevm/tfhe.go b/fhevm/tfhe.go index 3b13160..54c3107 100644 --- a/fhevm/tfhe.go +++ b/fhevm/tfhe.go @@ -19,8 +19,8 @@ package fhevm /* #cgo linux CFLAGS: -O3 -I../tfhe-rs/target/release #cgo linux LDFLAGS: -L../tfhe-rs/target/release -l:libtfhe.a -lm -#cgo darwin CFLAGS: -O3 -I../tfhe-rs/target/release ../tfhe-rs/target/release/libtfhe.a -#cgo darwin LDFLAGS: -framework Security -lm +#cgo darwin CFLAGS: -O3 -I../tfhe-rs/target/release +#cgo darwin LDFLAGS: -framework Security -L../tfhe-rs/target/release -ltfhe -lm #include