celo-org / celo-bls-go

Go module for https://github.com/celo-org/bls-zexe/
Apache License 2.0
14 stars 8 forks source link

s390x support for celo-bls #24

Open e-desouza opened 3 years ago

e-desouza commented 3 years ago

We're looking to port celo-bls to s390x architecture so opening this issue to track the work.

Currently the build fails with:

# github.com/celo-org/celo-bls-go/bls
/usr/bin/ld: $WORK/b079/_x002.o: in function `_cgo_81e5edcac56b_Cfunc_aggregate_public_keys':
/tmp/go-build/cgo-gcc-prolog:56: undefined reference to `aggregate_public_keys'
/usr/bin/ld: $WORK/b079/_x002.o: in function `_cgo_81e5edcac56b_Cfunc_aggregate_public_keys_subtract':
/tmp/go-build/cgo-gcc-prolog:79: undefined reference to `aggregate_public_keys_subtract'

Environment:

GOARCH="s390x"
GOHOSTARCH="s390x"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_s390x"
CC="s390x-linux-gnu-gcc"
kobigurk commented 3 years ago

Hi @e-desouza,

We currently don't bundle the libs for s390x, and we haven't tried cross compiling to it. I'll give it a shot while working on re-structuring the repo to allow bundling more libs.

e-desouza commented 3 years ago

Thanks @kobigurk . Let me know if access to a Linux (ubuntu/rhel/sles) on s390x will help this effort and I can provide a VM.

kobigurk commented 3 years ago

Sounds good. If you want to test meanwhile, I can provide instructions on how to work around, if you want to compile rust. Let me know!

e-desouza commented 3 years ago

Absolutely ! We have Rust support on the platform so please let me know the work around..

kobigurk commented 3 years ago

Nice! So what you can do is:

  1. Add the platform to https://github.com/celo-org/celo-bls-go/blob/master/scripts/release.sh. Specifically, the rustup target add and the cargo build and strip parts. The lib should then be copied automatically to the the right directory.

  2. Add a file similar to https://github.com/celo-org/celo-bls-go/blob/master/bls/bls_linux64.go, but with the correct CPU in the build directive and the right directory in LDFLAGS.

Let me know if that makes sense :)

On Mon, Jul 19, 2021 at 7:31 PM Elton de Souza @.***> wrote:

Absolutely ! We have Rust support on the platform so please let me know the work around..

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/celo-org/celo-bls-go/issues/24#issuecomment-882689334, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA23MGCXTXGR24TI2MZAVDTTYRHPRANCNFSM5ATYPJUA .

udai05 commented 3 years ago

Thanks @kobigurk.

Did the below changes and generated the libs.

  1. user@test:/opensrc/user/celo/celo-bls-go/libs$ rustc --print target-list | grep s390 s390x-unknown-linux-gnu s390x-unknown-linux-musl

@@ -25,6 +25,7 @@ rustup target add i686-linux-android rustup target add x86_64-linux-android rustup target add x86_64-unknown-linux-musl rustup target add aarch64-apple-ios x86_64-apple-ios +rustup target add s390x-unknown-linux-gnu

cargo build --release --target=aarch64-linux-android --lib -p bls-snark-sys cargo strip --target aarch64-linux-android @@ -46,6 +47,8 @@ cargo build --target=x86_64-pc-windows-gnu --release -p bls-snark-sys cargo strip --target x86_64-pc-windows-gnu cargo build --target=x86_64-unknown-linux-musl --release -p bls-snark-sys cargo strip --target x86_64-unknown-linux-musl +cargo build --target=s390x-unknown-linux-gnu --release -p bls-snark-sys +cargo strip --target s390x-unknown-linux-gnu cargo lipo --release --targets=aarch64-apple-ios,x86_64-apple-ios -p bls-snark-sys

popd @@ -69,4 +72,4 @@ do

  1. user@test:/opensrc/user/celo/celo-bls-go/bls$ cat bls_s390x.go // +build s390x

package bls

/*

cgo LDFLAGS: -L${SRCDIR}/../libs/s390x-unknown-linux-gnu -lbls_snark_sys -ldl -lm -lpthread

*/ import "C" user@test:/opensrc/user/celo/celo-bls-go/bls$ cd ../libs/ user@test:/opensrc/user/celo/celo-bls-go/libs$ ls s390x-unknown-linux-gnu/ libbls_crypto.a libbls_snark_sys.a libepoch_snark.a user@test:/opensrc/user/celo/celo-bls-go/libs$


"Point go.mod in celo-blockchain to the local celo-bls-go directory with a replace statement" go mod edit -replace github.com/celo-org/celo-bls-go=/opensrc/user/celo/celo-bls-go

I still see the original errors that were reported. Am I missing something?

udai05 commented 3 years ago

"go mod tidy" helped me. I am now able to generate geth now.

.... github.com/celo-org/celo-blockchain/cmd/geth Done building. Run "./build/bin/geth" to launch geth.

Thanks.

kobigurk commented 3 years ago

Amazing, glad the workaround works for you meanwhile. We're working on a new version and will include this platform there as well.

kobigurk commented 2 years ago

If you want to test it out, we have a PR that does the restructuring: https://github.com/celo-org/celo-bls-go/pull/25

You can test it out (which would help us!) using version v0.3.0-alpha3

Roavill2 commented 2 years ago

Hi @kobigurk,

I work with @US-05 and was recently trying out his workaround for getting this to work on s390x as I was hitting the same error as him on the make geth stage of installation.

I notice that you changed the structure of the project, so this workaround doesn't work anymore. Would you potentially be able to let me know the method that should be used now?

Tried making my own bls_s390x.go file but noticed that the libs directory is now gone so I think I'll struggle adding them there! I'm sure there's something I'm missing so any help you can give would be much appreciated. Thanks!