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 Android build #81

Closed
oskarth opened this issue Feb 24, 2024 · 5 comments
Closed

Fix Android build #81

oskarth opened this issue Feb 24, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@oskarth
Copy link
Collaborator

oskarth commented Feb 24, 2024

Problem

Currently Android CI build doesn't work. Some users have reported similar problems locally.

Details

User report

 ./scripts/build_android.sh config-example.toml 
= note: ld: unknown options: --version-script=/var/folders/hj/cgm2qndd02b6qbvv2rc46k080000gn/T/rustcNXwgFX/list --no-undefined-version --as-needed -Bstatic -Bdynamic --eh-frame-hdr -z --gc-sections -z -z
          clang: error: linker command failed with exit code 1 (use -v to see invocation)


error: could not compile `ark-circom` (lib) due to 1 previous error 

Failing CI

ELF (EM: 183)
          /usr/bin/ld: /home/runner/work/mopro/mopro/mopro-ffi/target/aarch64-linux-android/debug/deps/ark_circom-0a9603226fc50811.ark_circom.d89761b3e14fbdfb-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/runner/work/mopro/mopro/mopro-ffi/target/aarch64-linux-android/debug/deps/ark_circom-0a9603226fc50811.ark_circom.d89761b3e14fbdfb-cgu.0.rcgu.o: Relocations in generic ELF (EM: 183)
          /usr/bin/ld: /home/runner/work/mopro/mopro/mopro-ffi/target/aarch64-linux-android/debug/deps/ark_circom-0a9603226fc50811.ark_circom.d89761b3e14fbdfb-cgu.0.rcgu.o: error adding symbols: file in wrong format
          collect2: error: ld returned 1 exit status
          

error: could not compile `ark-circom` (lib) due to 1 previous error

Latest working

I try to revert to the latest commit (7b2413f) that passes CI
and it can still successfully build for android
so I think we made some changes that cause the CI to fail

Other notes

One difference between build_ios and build_android is:

# Update bindings
cd "${PROJECT_DIR}"
./scripts/update_bindings.sh $CONFIG_FILE

in build_ios, perhaps this leads to different behavior when building for android in some circumstances? With the new toml config format.

Acceptance criteria

Android build works locally and on CI.

@oskarth oskarth added the bug Something isn't working label Feb 24, 2024
@oskarth
Copy link
Collaborator Author

oskarth commented Feb 24, 2024

Also need to adjust target dir to root

@vivianjeng
Copy link
Collaborator

I try to revert to the latest commit (7b2413f) that passes CI
and it can still successfully build for android
so I think we made some changes that cause the CI to fail

I didn't notice that the previous CI also don't pass but the error is not caught (so it passed)
I think it is because of the architecture
but when I tried x86_64 it shows

note: /usr/bin/ld: cannot find -llog: No such file or directory
          collect2: error: ld returned 1 exit status

I am still figuring this out

@ethzanity
Copy link

Thanks @oskarth and @vivianjeng -- I managed to resolve the issue by adding a .cargo/config.toml file specifying the exact clang linker to be used, as follows

[target.x86_64-linux-android] linker = "{NDK_PATH}/toolchains/llvm/prebuilt/darwin-x86_64/bin/x86_64-linux-android21-clang"
I noticed that there was a mac popup window (either unpacking or authenticating the binaries) that appeared the first time I compiled successfully.

Separately, in line 97 of config-example-android.toml I had to add ${PROJECT_DIR} in front of
cp ${PROJECT_DIR}/target/${ARCHITECTURE}/${LIB_DIR}/libmopro_ffi.so jniLibs/${FOLDER}/libuniffi_mopro.so

@vivianjeng
Copy link
Collaborator

Thank you @ethzanity
I also solved CI with this: rust-lang/rustup#2872 (comment)
See: #82

@oskarth
Copy link
Collaborator Author

oskarth commented Feb 27, 2024

I guess we can close this issue now

@oskarth oskarth closed this as completed Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants