@@ -39,20 +39,31 @@ list in `config.toml`:
39
39
``` toml
40
40
[build ]
41
41
build-stage = 1
42
- target = [" sparc-unknown-none-elf" ]
42
+ host = [" <target for your host>" ]
43
+ target = [" <target for your host>" , " sparc-unknown-none-elf" ]
43
44
```
44
45
46
+ Replace ` <target for your host> ` with ` x86_64-unknown-linux-gnu ` or whatever
47
+ else is appropriate for your host machine.
48
+
45
49
## Building Rust programs
46
50
47
- ``` text
51
+ To build with this target, pass it to the ` --target ` argument, like:
52
+
53
+ ``` console
48
54
cargo build --target sparc-unknown-none-elf
49
55
```
50
56
51
57
This target uses GCC as a linker, and so you will need an appropriate GCC
52
- compatible ` sparc-unknown-none ` toolchain.
58
+ compatible ` sparc-unknown-none ` toolchain. The default linker binary is
59
+ ` sparc-elf-gcc ` , but you can override this in your project configuration, as
60
+ follows:
53
61
54
- The default linker name is ` sparc-elf-gcc ` , but you can override this in your
55
- project configuration.
62
+ ` .cargo/config.toml ` :
63
+ ``` toml
64
+ [target .sparc-unknown-none-elf ]
65
+ linker = " sparc-custom-elf-gcc"
66
+ ```
56
67
57
68
## Testing
58
69
@@ -74,6 +85,26 @@ something like:
74
85
linker = " sparc-gaisler-elf-gcc"
75
86
runner = " tsim-leon3"
76
87
88
+ [build ]
89
+ target = [" sparc-unknown-none-elf" ]
90
+ rustflags = " -Ctarget-cpu=leon3"
91
+ ```
92
+
93
+ With this configuration, running ` cargo run ` will compile your code for the
94
+ SPARC V8 compatible Gaisler Leon3 processor and then start the ` tsim-leon3 `
95
+ simulator. The ` libcore ` was pre-compiled as part of the ` rustc ` compilation
96
+ process using the SPARC V7 baseline, but if you are using a nightly toolchain
97
+ you can use the
98
+ [ ` -Z build-std=core ` ] ( https://doc.rust-lang.org/cargo/reference/unstable.html#build-std )
99
+ option to rebuild ` libcore ` from source. This may be useful if you want to
100
+ compile it for SPARC V8 and take advantage of the extra instructions.
101
+
102
+ ` .cargo/config.toml ` :
103
+ ``` toml
104
+ [target .sparc-unknown-none-elf ]
105
+ linker = " sparc-gaisler-elf-gcc"
106
+ runner = " tsim-leon3"
107
+
77
108
[build ]
78
109
target = [" sparc-unknown-none-elf" ]
79
110
rustflags = " -Ctarget-cpu=leon3"
@@ -82,16 +113,16 @@ rustflags = "-Ctarget-cpu=leon3"
82
113
build-std = [" core" ]
83
114
```
84
115
85
- With this configuration, running ` cargo run ` will compile your code for the
86
- SPARC V8 compatible Gaisler Leon3 processor and then start the ` tsim-leon3 `
87
- simulator. Once the simulator is running, simply enter the command
88
- ` run ` to start the code executing in the simulator.
116
+ Either way, once the simulator is running, simply enter the command ` run ` to
117
+ start the code executing in the simulator.
89
118
90
119
The default C toolchain libraries are linked in, so with the Gaisler [ BCC2]
91
120
toolchain, and using its default Leon3 BSP, you can use call the C ` putchar `
92
- function and friends to output to the simulator console.
121
+ function and friends to output to the simulator console. The default linker
122
+ script is also appropriate for the Leon3 simulator, so no linker script is
123
+ required.
93
124
94
- Here's a complete example:
125
+ Here's a complete example using the above config file :
95
126
96
127
``` rust,ignore (cannot-test-this-because-it-assumes-special-libc-functions)
97
128
#![no_std]
0 commit comments