-
Notifications
You must be signed in to change notification settings - Fork 101
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
How do you build this for Android ("Tier 2 without Host Tools") #1450
Comments
If I understand correctly what you are doing, you are making cargo compile rustc_driver + dependencies and then rustc_codegen_cranelift for android and then loading it into an existing rustc executable. That won't work. You need to link codegen backends against the exact same librustc_driver.so as rustc itself. Otherwise you either have abi mismatches or duplicated thread local storage. Both of which will lead to the compiler crashing. Or did I misunderstand what you did? If I did misunderstand what you did and it does work, then you could try building the sysroot by changing I did however recommend building rustc itself with the cranelift backend enabled using a config.toml like the following in your local checkout of https://github.com/rust-lang/rust/ profile = "compiler"
[rust]
codegen-backends = ["llvm", "cranelift"]
[target.aarch64-linux-android]
cc = "/path/to/clang"
cxx = "/path/to/clang++"
linker = "/path/to/clang" where you need to point it to the clang included in the android ndk and then doing |
What I am actually doing is compiling this repo, but including the rustc_driver as a dependency, last time I did this I somehow got it working fine but the linker refused to work. The reason why I use cranelift over LLVM is because that is a real pain in the ass to compile and cranelift supports JIT so I can avoid linking. All I want to do is to be able to compile a simple rust program with std on android and run it, but because it is not a host target shit just refuses to work. |
@bjorn3 using the default library does not work with JIT, however not using JIT forces me to link it, and I cant for the love of god get it to link correctly. I also tried compiling both the compiler and cranelift, but got weird errors. eg So I am wondering how I should compile the sysroot to give JIT lib files, because right now |
You probably need to copy rustc_codegen_cranelift/build_system/utils.rs Lines 25 to 34 in 24361a1
self.runner as that only matters for running tests.
The JIT mode requires all dependencies to be available as linked dylibs. I've got a branch somewhere to add a fake LTO mode to cg_clif which would likely help here, but that branch is quite out of date and doesn't actually wire it up to the JIT mode, only the default AOT mode. |
7 mo ago I tried to build this project for android and being successfully able to compile rust project on android, however I was unable to link it (missing libc.so.6 ect) and JIT PTE was not implemented. Now I tested https://github.com/bytecodealliance/cranelift-jit-demo and it worked on an android device, and now I want to port the entirety of the compiler to android using JIT to run the code.
I use https://github.com/cross-rs/cross to "cross build --target aarch64-linux-android --release" this project and add to the toml
and
And this works fine for building the librustc_driver.so and librustc_codegen_cranelift.so, however it cant compile without a sysroot.
How can I compile the sysroot (to target android) to be able to compile it?
The text was updated successfully, but these errors were encountered: