@@ -96,9 +96,34 @@ exec /path/to/ohos-sdk/linux/native/llvm/bin/clang++ \
9696
9797Future versions of the OpenHarmony SDK will avoid the need for this process.
9898
99- ## Building the target
99+ ## Building Rust programs
100+
101+ Rustup ships pre-compiled artifacts for this target, which you can install with:
102+ ``` sh
103+ rustup target add aarch64-unknown-linux-ohos
104+ rustup target add armv7-unknown-linux-ohos
105+ rustup target add x86_64-unknown-linux-ohos
106+ ```
107+
108+ You will need to configure the linker to use in ` ~/.cargo/config.toml ` :
109+ ``` toml
110+ [target .aarch64-unknown-linux-ohos ]
111+ ar = " /path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar"
112+ linker = " /path/to/aarch64-unknown-linux-ohos-clang.sh"
113+
114+ [target .armv7-unknown-linux-ohos ]
115+ ar = " /path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar"
116+ linker = " /path/to/armv7-unknown-linux-ohos-clang.sh"
117+
118+ [target .x86_64-unknown-linux-ohos ]
119+ ar = " /path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar"
120+ linker = " /path/to/x86_64-unknown-linux-ohos-clang.sh"
121+ ```
100122
101- To build a rust toolchain, create a ` config.toml ` with the following contents:
123+ ## Building the target from source
124+
125+ Instead of using ` rustup ` , you can instead build a rust toolchain from source.
126+ Create a ` config.toml ` with the following contents:
102127
103128``` toml
104129profile = " compiler"
@@ -130,28 +155,6 @@ ranlib = "/path/to/ohos-sdk/linux/native/llvm/bin/llvm-ranlib"
130155linker = " /path/to/x86_64-unknown-linux-ohos-clang.sh"
131156```
132157
133- ## Building Rust programs
134-
135- Rust does not yet ship pre-compiled artifacts for this target. To compile for
136- this target, you will either need to build Rust with the target enabled (see
137- "Building the target" above), or build your own copy of ` core ` by using
138- ` build-std ` or similar.
139-
140- You will need to configure the linker to use in ` ~/.cargo/config ` :
141- ``` toml
142- [target .aarch64-unknown-linux-ohos ]
143- ar = " /path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar"
144- linker = " /path/to/aarch64-unknown-linux-ohos-clang.sh"
145-
146- [target .armv7-unknown-linux-ohos ]
147- ar = " /path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar"
148- linker = " /path/to/armv7-unknown-linux-ohos-clang.sh"
149-
150- [target .x86_64-unknown-linux-ohos ]
151- ar = " /path/to/ohos-sdk/linux/native/llvm/bin/llvm-ar"
152- linker = " /path/to/x86_64-unknown-linux-ohos-clang.sh"
153- ```
154-
155158## Testing
156159
157160Running the Rust testsuite is possible, but currently difficult due to the way
0 commit comments