Skip to content
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

Fix static linking on Mac #16

Merged
merged 3 commits into from
Oct 20, 2023
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to rm here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I saw the description. Wouldn't it work even if we don't remove?

Copy link
Collaborator Author

@david-zk david-zk Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By default linker prefers dynamic libraries if they are available, now we specify tfhe lib with -ltfhe flag, which doesn't imply if it is static or dynamic, so if we remove dynamic libraries, linker is forced to link statically

Copy link
Collaborator Author

@david-zk david-zk Oct 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would work, but then on macbook it links dynamically, I tried -l:libtfhe.a flag but it doesn't work


.PHONY: clean
clean:
Expand Down
6 changes: 4 additions & 2 deletions fhevm/tfhe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
#cgo darwin LDFLAGS: -framework Security -L../tfhe-rs/target/release -ltfhe -lm

#include <tfhe.h>

Expand Down