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

iOS build failing #285

Closed
Schr3da opened this issue Jan 26, 2020 · 10 comments · Fixed by #286
Closed

iOS build failing #285

Schr3da opened this issue Jan 26, 2020 · 10 comments · Fixed by #286

Comments

@Schr3da
Copy link

Schr3da commented Jan 26, 2020

Hey,
Just tried out to build the spinning cube example form ios. Unfortunately it is not building using cargo-lipo and the required toolchain.

Any advise?
Kind regards,
Schreda

@ghost ghost added the question label Jan 26, 2020
@ghost
Copy link

ghost commented Jan 26, 2020

Could you please give more details on how it's "not building"? It would really help us diagnose the problem if you could:

  1. Clarify whether you are building "for" or "from" iOS. I'm afraid the latter is not a use case we can support.
  2. Confirm that you have installed the libraries required by bindgen: https://rust-lang.github.io/rust-bindgen/requirements.html.
  3. Specify the version of godot-rust you were using -- 0.7.0 or the master branch?
  4. Provide the full output produced by cargo.

Thanks!

@Schr3da
Copy link
Author

Schr3da commented Jan 26, 2020

Thanks for the quick reply!

  1. Want to build for iOS.
  2. I can confirm that all requirements are properly installed for bindgen - Besides that Im able to build for OSX, Linux and Windows - However building for iOS using my Mac fails even proper tooling installed incl. cargo lip.
  3. Tried godot-rust v0.7 and master

Did you try to build one of the examples of rust-godot for iOS before?

Kind regards

@ghost
Copy link

ghost commented Jan 27, 2020

I must admit that I haven't tried building for iOS yet, so a log can be really helpful in determining how serious the problem is, and what its cause might be. If the cargo output is too long, just post the first few errors: something is better than nothing!

@Schr3da
Copy link
Author

Schr3da commented Jan 30, 2020

Hey,

sorry took bit longer than expected. Enclosed please find the output log

bash-3.2$ cargo lipo --release
[INFO  cargo_lipo::meta] Will build universal library for ["spinning_cube"]
[INFO  cargo_lipo::lipo] Building "spinning_cube" for "aarch64-apple-ios"
Downloaded aho-corasick v0.7.7
Compiling...
Building [====================================================] 94/94: bindgen, syn, clang-sys

error: failed to run custom build command for `gdnative-sys v0.7.0 (/Users/SAMPLE_USER/Downloads/godot-rust-master/gdnative-sys)`

Caused by:
  process didn't exit successfully: `/Users/SAMPLE_USER/Downloads/godot-rust-master/target/release/build/gdnative-sys-34a47cc58729244c/build-sc
--- stdout
cargo:warning=couldn't execute `llvm-config --prefix` (error: No such file or directory (os error 2))
cargo:warning=set the LLVM_CONFIG_PATH environment variable to a valid `llvm-config` executable

--- stderr
thread 'main' panicked at 'libclang error; possible causes include:
- Invalid flag syntax
- Unrecognized flags
- Invalid flag arguments
- File I/O errors
If you encounter an error missing from this list, please file an issue or a PR!', src/libcore/option.rs:1185:5
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.

warning: build failed, waiting for other jobs to finish...
error: build failed
[ERROR cargo_lipo] Failed to build "spinning_cube" for "aarch64-apple-ios"

So probably it is required to install the toolchain of llvm besides Xcode using brew install --with-toolchain llvm.

Kind regards,
Schreda

@ghost
Copy link

ghost commented Jan 31, 2020

So probably it is required to install the toolchain of llvm besides Xcode using brew install --with-toolchain llvm.

LLVM is one of the dependencies of bindgen. Does this mean your problem is resolved, or is there anything that still needs to be handled?

@ghost ghost added the bug label Feb 1, 2020
@ghost
Copy link

ghost commented Feb 1, 2020

Tried on macOS Catalina 10.15.2 with XCode 11.3.1, can confirm that this is happening with the current master branch. This seems to be a bindgen issue: rust-lang/rust-bindgen#1211

Stacktrace from `cargo lipo`

stack backtrace:
   0: std::sys_common::at_exit_imp::push
   1: core::fmt::ArgumentV1::show_usize
   2: std::io::Write::write_fmt
   3: std::panicking::default_hook::{{closure}}
   4: std::panicking::default_hook
   5: <std::panicking::begin_panic::PanicPayload<A> as core::panic::BoxMeUp>::get
   6: std::panicking::continue_panic_fmt
   7: std::panicking::try::do_call
   8: std::panicking::begin_panic
   9: std::panicking::begin_panic
  10: core::hash::sip::SipHasher13::new_with_keys
  11: bindgen::ir::context::BindgenContext::new
  12: bindgen::Bindings::generate
  13: bindgen::args_are_cpp::{{closure}}
  14: build_script_build::header_binding::generate
             at gdnative-sys/build.rs:69
  15: build_script_build::main
             at gdnative-sys/build.rs:7
  16: std::rt::lang_start::{{closure}}
             at /rustc/_/src/libstd/rt.rs:61
  17: std::panicking::try::do_call
  18: panic_unwind::dwarf::eh::read_encoded_pointer
  19: std::panicking::update_count_then_panic
  20: std::rt::lang_start
             at /rustc/_/src/libstd/rt.rs:61
  21: build_script_build::main
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Standalone invocation of the bindgen CLI yielded an clang error consistent with the linked bindgen issue:error: unknown target triple 'unknown-apple-ios5.0.0', please use -triple or -arch.

ghost pushed a commit that referenced this issue Feb 1, 2020
There is an issue in bindgen that prevents building for the aarch64-apple-ios target. This
works arounds the issue by replacing aarch64 with arm64 which clang can understand.

Also fixes conditional includes for macOS, which was using the target of the *build script*
instead of the target we're building for.

Close #285
@ghost ghost mentioned this issue Feb 1, 2020
@ghost
Copy link

ghost commented Feb 1, 2020

@Schr3da I have created a patch in #286 that should allow building for iOS with cargo-lipo. Could you try and see if it works on your machine?

@Schr3da
Copy link
Author

Schr3da commented Feb 1, 2020

Hm unfortunately Im unable to install llvm-config using brew install --with-toolchain llvm. Brew does not resolve the option :(

@ghost
Copy link

ghost commented Feb 2, 2020

llvm-config is normally installed by brew without requiring any additional options, just not put in PATH. You can find it in $(brew --prefix)/opt/llvm/bin. The warning shouldn't normally affect building, and I have managed to build the example without setting LLVM_CONFIG_PATH with the PR I linked. Could you please try building the example with the PR applied?

@Schr3da
Copy link
Author

Schr3da commented Feb 2, 2020

Great job - works !!!
We can close the item.

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

Successfully merging a pull request may close this issue.

1 participant