You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+29-2
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,12 @@
1
-
# Android Rust example application
1
+
# Android Rust example application with SIMD instructions
2
2
3
3
This repository is a demonstration of an Android app integrating a native Rust library.
4
+
Additionally, this Rust library demonstrates detecting support for SIMD instructions.
4
5
5
-
You can find more information in the following blog post: [Compiling Rust libraries for Android apps: a deep dive](https://gendignoux.com/blog/2022/10/24/rust-library-android.html).
6
+
You can find more information in the following blog posts:
7
+
8
+
-[Compiling Rust libraries for Android apps: a deep dive](https://gendignoux.com/blog/2022/10/24/rust-library-android.html),
9
+
-[Detecting SIMD support on ARM with Android (and patching the Rust compiler for it)](https://gendignoux.com/blog/2022/11/09/rust-simd-detect-arm-android.md).
6
10
7
11
## Usage
8
12
@@ -29,6 +33,7 @@ You can build various flavors of the Rust library.
29
33
30
34
-`script-rust-nightly.sh`: basic script using the nightly Rust toolchain, with stripping of debug symbols enabled.
31
35
-`script-rust-nightly-nostrip.sh`: same, but without stripping debug symbols.
36
+
-`script-rust-stage1.sh` and `script-rust-stage1-nostrip.sh`: using a locally built `stage1` Rust compiler (see below).
32
37
-`script-rust-default.sh` and `script-rust-default-nostrip.sh`: using the default Rust toolchain (stable).
33
38
34
39
Then, multiple ways are provided to build the Java part of the Android app.
@@ -38,3 +43,25 @@ Then, multiple ways are provided to build the Java part of the Android app.
38
43
-`script-java-incorrect-x86_64.sh`: Android app built with the x86_64 library in the wrong folder.
39
44
40
45
You can then spawn an Android emulator with `emulator.sh`, and use the `launch-app-debug.sh` or `launch-app-release.sh` scripts to install+launch the application via ADB to either the emulator or a real device connected via USB.
46
+
47
+
## Building and using a patched Rust compiler
48
+
49
+
This repository also shows how to patch and build the Rust compiler.
50
+
You can launch the Docker container in various scenarios:
51
+
52
+
-`docker-run-rustc-1cpu.sh`: with 1 CPU, 2 GB of RAM,
53
+
-`docker-run-rustc-2cpu.sh`: with 2 CPUs, 2 GB of RAM,
54
+
-`docker-run-rustc-4cpu.sh`: with 4 CPUs, 3 GB of RAM,
55
+
-`docker-run-rustc-8cpu.sh`: with 8 CPUs, 5 GB of RAM,
56
+
-`docker-run-all-rustc.sh`: to compile `rustc` + build the app.
57
+
58
+
Once launched, you can clone and compile `rustc` for Android with:
59
+
60
+
-`scripts/clone-rustlang-head.sh`: clone the latest commit on the Rust repository,
61
+
-`scripts/stage0.sh`: build a stage 0 compiler,
62
+
-`scripts/stage1.sh`: build a stage 1 compiler.
63
+
64
+
You'll also find the following tool to generate a flame graph of the disk space used by a build of `rustc`:
65
+
66
+
-`tools/flamedisk`: small Rust tool to generate an input suitable for `flamegraph.pl`,
67
+
-`scripts/flamedisk.sh`: driver script to generate the flame graph.
0 commit comments