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

s390x support for celo-bls #24

Open
e-desouza opened this issue Jul 19, 2021 · 10 comments
Open

s390x support for celo-bls #24

e-desouza opened this issue Jul 19, 2021 · 10 comments

Comments

@e-desouza
Copy link

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
Copy link
Collaborator

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
Copy link
Author

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
Copy link
Collaborator

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
Copy link
Author

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

@kobigurk
Copy link
Collaborator

kobigurk commented Jul 19, 2021 via email

@udai05
Copy link

udai05 commented Jul 23, 2021

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

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
Copy link

udai05 commented Jul 23, 2021

"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
Copy link
Collaborator

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

@kobigurk
Copy link
Collaborator

kobigurk commented Aug 4, 2021

If you want to test it out, we have a PR that does the restructuring: #25

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

@Roavill2
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants