Add clarification about build-std and using newer instructions.
This commit is contained in:
parent
b787fc0ea6
commit
34e01d5f32
@ -39,20 +39,31 @@ list in `config.toml`:
|
|||||||
```toml
|
```toml
|
||||||
[build]
|
[build]
|
||||||
build-stage = 1
|
build-stage = 1
|
||||||
target = ["sparc-unknown-none-elf"]
|
host = ["<target for your host>"]
|
||||||
|
target = ["<target for your host>", "sparc-unknown-none-elf"]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Replace `<target for your host>` with `x86_64-unknown-linux-gnu` or whatever
|
||||||
|
else is appropriate for your host machine.
|
||||||
|
|
||||||
## Building Rust programs
|
## Building Rust programs
|
||||||
|
|
||||||
```text
|
To build with this target, pass it to the `--target` argument, like:
|
||||||
|
|
||||||
|
```console
|
||||||
cargo build --target sparc-unknown-none-elf
|
cargo build --target sparc-unknown-none-elf
|
||||||
```
|
```
|
||||||
|
|
||||||
This target uses GCC as a linker, and so you will need an appropriate GCC
|
This target uses GCC as a linker, and so you will need an appropriate GCC
|
||||||
compatible `sparc-unknown-none` toolchain.
|
compatible `sparc-unknown-none` toolchain. The default linker binary is
|
||||||
|
`sparc-elf-gcc`, but you can override this in your project configuration, as
|
||||||
|
follows:
|
||||||
|
|
||||||
The default linker name is `sparc-elf-gcc`, but you can override this in your
|
`.cargo/config.toml`:
|
||||||
project configuration.
|
```toml
|
||||||
|
[target.sparc-unknown-none-elf]
|
||||||
|
linker = "sparc-custom-elf-gcc"
|
||||||
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
@ -74,6 +85,26 @@ something like:
|
|||||||
linker = "sparc-gaisler-elf-gcc"
|
linker = "sparc-gaisler-elf-gcc"
|
||||||
runner = "tsim-leon3"
|
runner = "tsim-leon3"
|
||||||
|
|
||||||
|
[build]
|
||||||
|
target = ["sparc-unknown-none-elf"]
|
||||||
|
rustflags = "-Ctarget-cpu=leon3"
|
||||||
|
```
|
||||||
|
|
||||||
|
With this configuration, running `cargo run` will compile your code for the
|
||||||
|
SPARC V8 compatible Gaisler Leon3 processor and then start the `tsim-leon3`
|
||||||
|
simulator. The `libcore` was pre-compiled as part of the `rustc` compilation
|
||||||
|
process using the SPARC V7 baseline, but if you are using a nightly toolchain
|
||||||
|
you can use the
|
||||||
|
[`-Z build-std=core`](https://doc.rust-lang.org/cargo/reference/unstable.html#build-std)
|
||||||
|
option to rebuild `libcore` from source. This may be useful if you want to
|
||||||
|
compile it for SPARC V8 and take advantage of the extra instructions.
|
||||||
|
|
||||||
|
`.cargo/config.toml`:
|
||||||
|
```toml
|
||||||
|
[target.sparc-unknown-none-elf]
|
||||||
|
linker = "sparc-gaisler-elf-gcc"
|
||||||
|
runner = "tsim-leon3"
|
||||||
|
|
||||||
[build]
|
[build]
|
||||||
target = ["sparc-unknown-none-elf"]
|
target = ["sparc-unknown-none-elf"]
|
||||||
rustflags = "-Ctarget-cpu=leon3"
|
rustflags = "-Ctarget-cpu=leon3"
|
||||||
@ -82,16 +113,16 @@ rustflags = "-Ctarget-cpu=leon3"
|
|||||||
build-std = ["core"]
|
build-std = ["core"]
|
||||||
```
|
```
|
||||||
|
|
||||||
With this configuration, running `cargo run` will compile your code for the
|
Either way, once the simulator is running, simply enter the command `run` to
|
||||||
SPARC V8 compatible Gaisler Leon3 processor and then start the `tsim-leon3`
|
start the code executing in the simulator.
|
||||||
simulator. Once the simulator is running, simply enter the command
|
|
||||||
`run` to start the code executing in the simulator.
|
|
||||||
|
|
||||||
The default C toolchain libraries are linked in, so with the Gaisler [BCC2]
|
The default C toolchain libraries are linked in, so with the Gaisler [BCC2]
|
||||||
toolchain, and using its default Leon3 BSP, you can use call the C `putchar`
|
toolchain, and using its default Leon3 BSP, you can use call the C `putchar`
|
||||||
function and friends to output to the simulator console.
|
function and friends to output to the simulator console. The default linker
|
||||||
|
script is also appropriate for the Leon3 simulator, so no linker script is
|
||||||
|
required.
|
||||||
|
|
||||||
Here's a complete example:
|
Here's a complete example using the above config file:
|
||||||
|
|
||||||
```rust,ignore (cannot-test-this-because-it-assumes-special-libc-functions)
|
```rust,ignore (cannot-test-this-because-it-assumes-special-libc-functions)
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user