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

Add iOS build with bls #528

Merged
merged 30 commits into from
Oct 18, 2019
Merged

Add iOS build with bls #528

merged 30 commits into from
Oct 18, 2019

Conversation

jeanregisser
Copy link
Contributor

@jeanregisser jeanregisser commented Oct 14, 2019

Description

This PR adds iOS build support with bls.

make ios generates the static framework and bls lib that can be used on iOS (device and simulator).
The CeloBlockchain podspec is to be used by final iOS clients. It's directly compatible with Podfile using use_frameworks!. In that case it creates a dynamic framework linking against both geth and bls.

I had to disable bitcode for now since the rust generated lib isn't yet compatible with apple's bitcode. See rust-lang/rust#35968 (I tried the latest rust nigthly but I couldn't make it work).

It also exposes the IPCPath config for the node so that iOS can use a relative path to workaround the 104 chars path limit for unix domain sockets.

Big thank to @cmcewen who did the initial working prototype!

Tested

Tested that it builds and runs correctly on both iOS and Android.

Other changes

  • Ignore ndk_bundle dir used by the Makefile

Related issues

Backwards compatibility

Yes.

Copy link
Contributor

@kobigurk kobigurk left a comment

Choose a reason for hiding this comment

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

Looks awesome! Only small comments.

else
rustup target add aarch64-apple-ios armv7-apple-ios x86_64-apple-ios i386-apple-ios
cd vendor/github.com/celo-org/bls-zexe/bls && cargo lipo --release --targets=aarch64-apple-ios,armv7-apple-ios,x86_64-apple-ios,i386-apple-ios
endif
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't there an endif missing here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question 👍 this syntax works but someone mentions it's failing with GNU Make 3.80:
https://stackoverflow.com/a/12297193/158525

My machine has GNU Make 3.81 which was first released in 2006.
I think we're safe, but let me know if you still wanna change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah I just changed the structure anyway so no questions about this anymore :D

@@ -942,6 +942,8 @@ func doXCodeFramework(cmdline []string) {

// Build the iOS XCode framework
build.MustRun(goTool("get", "golang.org/x/mobile/cmd/gomobile", "golang.org/x/mobile/cmd/gobind"))
// Patch gomobile to disable bitcode for now (rust generated bls lib output is not compatible)
build.MustRunCommand("sed", "-i", "", `/^[[:space:]]*cflags += \" -fembed-bitcode\"$/s/^/\/\//`, filepath.Join(build.GOPATH(), "src/golang.org/x/mobile/cmd/gomobile/env.go"))
Copy link
Contributor

Choose a reason for hiding this comment

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

Too bad it doesn't work :(
Can you try with Rust 1.37? I'm upgrading the build toolchain to that anyway. Seems like people succeeded with recent nightlies, so it might work there: rust-lang/rust#35968 (comment)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried with Rust 1.38 stable and 1.40.0-nightly (2748a9fd9 2019-10-08).
Both failed to link with gomobile when bitcode was enabled (Xcode 10.3). Though the generated rust lib do contain bitcode markers.

Makefile Outdated
ifeq ("$(RUSTUP_exists)","")
$(error "No rustup in PATH, consult https://github.com/celo-org/celo-monorepo/blob/master/SETUP.md")
else ifeq ("$(CARGO_LIPO_exists)","")
$(error "No cargo lipo in PATH, run cargo install cargo-lipo")
Copy link
Contributor

Choose a reason for hiding this comment

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

How about installing cargo-lipo for the user here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea! I'll do that.

@jeanregisser jeanregisser requested a review from kobigurk October 16, 2019 10:21
@asaj
Copy link
Contributor

asaj commented Oct 16, 2019

Do you need reviews from all five of us?

@asaj asaj removed their assignment Oct 16, 2019
This is to fix problems when yarn/npm is run after pod install and
clears what has been done by the podspec prepare command.
@jeanregisser jeanregisser merged commit 9fa5a7e into master Oct 18, 2019
@jeanregisser jeanregisser deleted the cmcewen/ios branch October 18, 2019 15:57
tkporter pushed a commit that referenced this pull request Oct 24, 2019
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

Successfully merging this pull request may close these issues.

6 participants