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

Failed to build for iOS #36

Closed
SpriteOvO opened this issue Sep 6, 2023 Discussed in #35 · 7 comments
Closed

Failed to build for iOS #36

SpriteOvO opened this issue Sep 6, 2023 Discussed in #35 · 7 comments
Labels
bug Something isn't working

Comments

@SpriteOvO
Copy link
Owner

Discussed in #35

Originally posted by newbeeAirfeeen September 6, 2023
I have written an ios sdk now. This sdk uses spdlog-rs. But when I build the sdk of the ios general library. The following command was used:
cargo lipo
The compiler told me that there is no corresponding function on IOS。

spdlog-rs-0.3.10/src/record.rs:291:57
    |
291 |     TID.with(|tid| *tid.borrow_mut().get_or_insert_with(get_current_tid_inner))
    |                                                         ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

I downloaded the source code and checked the relevant calls in libc, and found that there seems to be no corresponding function. If I want to build on ios, is it not supported by the current version yet.
Is it possible to change the way of thinking and use other methods to obtain the thread id when building on ios

@SpriteOvO SpriteOvO added the bug Something isn't working label Sep 6, 2023
@SpriteOvO
Copy link
Owner Author

@newbeeAirfeeen Sorry I'm completely unfamiliar with iOS development. Could you give me the steps to reproduce the error? It's best to only use cli as I'd like to add testing for iOS to CI so we can support it long term.

@newbeeAirfeeen
Copy link

I have now developed an SDK library for my own use on iOS. Of course, this requires compiling rust into the corresponding ios version. I believe this article explains it more clearly than I did.
https://mozilla.github.io/firefox-browser-architecture/experiments/2017-09-06-rust-on-ios.html
To put it simply, compiling into ios is equivalent to compiling rust into a static library, and then using rust FFI to let the outside world interact with the rust library through C language.
Here are the steps I took to execute the command
curl https://sh.rustup.rs -sSf | sh
rustup target add aarch64-apple-ios armv7-apple-ios armv7s-apple-ios x86_64-apple-ios i386-apple-ios
cargo install cargo-lipo
cargo lipo --release
Finally, the compiler reported:

spdlog-rs-0.3.10/src/record.rs:291:57
|
291 | TID.with(|tid| *tid.borrow_mut().get_or_insert_with(get_current_tid_inner))
| ^^^^^^^^^^^^^^^^^^^^^ not found in this scope

This is the record.rs code in spdlog. This error is equivalent to telling us that on the iOS platform, libc does not provide a method for obtaining the corresponding thread ID(I'm not sure if libc provides the corresponding method, but at least in spdlog, there is no adaptation similar to #[cfg(target_os="ios")
image
Because on ios, regardless of using the c++11 standard. Or use c with posix threads. You can get the current thread id. Other ways can be considered here.
If your current compilation environment is limited, I can provide some help.

@SpriteOvO
Copy link
Owner Author

SpriteOvO commented Sep 6, 2023

@newbeeAirfeeen Much helped! Seems like we can just run cargo test with --target x86_64-apple-ios, it reproduces the error well, but tests cannot be executed with error dyld[2975]: DYLD_ROOT_PATH not set for simulator program. Launching a simulator (https://github.com/futureware-tech/simulator-action) doesn't solve it, I'm trying to figure out it.

UPDATE: BTW, I'm trying to setup the CI on GitHub Actions macos-latest runner.

@SpriteOvO SpriteOvO changed the title Failed to build on iOS Failed to build for iOS Sep 6, 2023
@newbeeAirfeeen
Copy link

I didn't see your submission just now, so I submitted a PR. I just confirmed and verified that pthread_threadid_np can indeed be called on ios. This has been compiled on my example

@SpriteOvO
Copy link
Owner Author

Fixed in #37. Thanks for your report and help!

@SpriteOvO
Copy link
Owner Author

New version will be released in a few hours because I'm outside now.

@SpriteOvO
Copy link
Owner Author

Released in v0.3.11.

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

2 participants