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

Create a aarch64-apple-ios-sim target for rustc #81632

Closed
deg4uss3r opened this issue Feb 1, 2021 · 11 comments · Fixed by #81966
Closed

Create a aarch64-apple-ios-sim target for rustc #81632

deg4uss3r opened this issue Feb 1, 2021 · 11 comments · Fixed by #81966
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.

Comments

@deg4uss3r
Copy link
Contributor

deg4uss3r commented Feb 1, 2021

Currently in our application we cannot run the iOS simulator on M1 machines because it is expecting x86_64 architecture. Forcing arm64 using the rustc target aarch64-apple-ios can build the project and ship the application but this targets the iOS Device SDK, and will not build in the simulator for testing with this error:

ld: <path/to/lib> building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

rustc should provide an aarch-apple-ios-sim target that uses the iOS Simulator SDK.

@deg4uss3r deg4uss3r added the C-bug Category: This is a bug. label Feb 1, 2021
@jonas-schievink jonas-schievink added C-feature-request Category: A feature request, i.e: not implemented / a PR. and removed C-bug Category: This is a bug. labels Feb 1, 2021
@shepmaster
Copy link
Member

Is #77484 relevant at all? Can the same path be followed?

@deg4uss3r
Copy link
Contributor Author

Awesome find @shepmaster I'll try doing this! If successful I'll open a similar PR :)

@badboy
Copy link
Member

badboy commented Feb 4, 2021

Ran into this now too. Happy to help here as well.
@deg4uss3r Did you already get started?

@deg4uss3r
Copy link
Contributor Author

@badboy I did but having trouble I've pushed my changes here: https://github.com/deg4uss3r/rust/tree/degausser/aarch64_apple_ios_sim

More than happy to work with you on this Jan!

@badboy
Copy link
Member

badboy commented Feb 4, 2021

I'll try to get a dev environment set up and then I'll take a look.

@deg4uss3r
Copy link
Contributor Author

deg4uss3r commented Feb 4, 2021

I built the toolchain successfully, but when I try to compile my project (with either aarch64-apple-darwin or aarch64-apple-ios-sim) I'm getting:

error[E0277]: cannot subtract `usize` from `u32`
    --> $CARGO_REGISTRY_PATH/lexical-core-0.7.4/src/atof/algorithm/math.rs:2065:25
     |
2065 |     let rs = Limb::BITS - s;
     |                         ^ no implementation for `u32 - usize`
     |
     = help: the trait `Sub<usize>` is not implemented for `u32`

I think I've missed a setting in the build config I'm using, because the normal nightly compiles fine :(

config.toml: https://gist.github.com/deg4uss3r/183ef399590f74353691b21badc382cc

Edit looks like I will try off beta: #81654

@badboy
Copy link
Member

badboy commented Feb 4, 2021

Yeah, that looks like upstream breakage in lexical-core because of recent changes.
I can try taking your code tomorrow and throw this against my project to see if that fixes my simulator issues.

@deg4uss3r
Copy link
Contributor Author

Yeah I added the patch mentioned in that issue and am getting further but:

ld: warning: ignoring file /Users/rth/work/core/target/aarch64-apple-ios-sim/debug/core.a, building for iOS Simulator-x86_64 but attempting to link with file built for unknown-arm64

which Xcode still seems to be getting x86_64 somewhere:

 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-ios14.0-simulator 

I tried replacing all the x86_64 with arm64 and got closer:

/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target arm64-apple-ios14.0-simulator

but got:

ld: in /Users/rth/work/core/target/aarch64-apple-ios-sim/debug/core.a(sqlite3.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

@deg4uss3r
Copy link
Contributor Author

I believe my current version is working but there's something off in my Xcode project that I need to figure out:

❯ cargo build --target=aarch64-apple-ios-sim
   Compiling testing v0.1.0 (/Users/rth/code/experiments/testing)
    Finished dev [unoptimized + debuginfo] target(s) in 1.88s

❯ file testing
testing: Mach-O 64-bit executable arm64

target/aarch64-apple-ios-sim/debug on  master [?]
❯ ./testing
dyld: attempt to run simulator program outside simulator (DYLD_ROOT_PATH not set)
zsh: abort      ./testing

@badboy
Copy link
Member

badboy commented Feb 6, 2021

Ah, you're building a binary? Yeah, that seems to sort-of work now?
I managed to build your branch, my static library is still unchanged. I think we actually need LLVM 12 first to fully enable this (#81451).

@deg4uss3r
Copy link
Contributor Author

It was just a test to see if the simulator is working at all XD.

Yeah my .a file is still saying it's arm64:

ld: in /Users/rth/work/core/target/aarch64-apple-ios-sim/debug/core.a(sqlite3.o), building for iOS Simulator, but linking in object file built for iOS, for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants