-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Sony PlayStation 1 tier 3 target
- Loading branch information
Showing
5 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use crate::spec::{cvs, Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "mipsel-sony-psx".into(), | ||
pointer_width: 32, | ||
data_layout: "e-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64".into(), | ||
arch: "mips".into(), | ||
|
||
options: TargetOptions { | ||
os: "none".into(), | ||
env: "psx".into(), | ||
vendor: "sony".into(), | ||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes), | ||
cpu: "mips1".into(), | ||
executables: true, | ||
linker: Some("rust-lld".into()), | ||
relocation_model: RelocModel::Static, | ||
exe_suffix: ".exe".into(), | ||
|
||
// PSX doesn't natively support floats. | ||
features: "+soft-float".into(), | ||
|
||
// This should be 16 bits, but LLVM incorrectly tries emitting MIPS-II SYNC instructions | ||
// for atomic loads and stores. This crashes rustc so we have to disable the Atomic* API | ||
// until this is fixed upstream. See https://reviews.llvm.org/D122427#3420144 for more | ||
// info. | ||
max_atomic_width: Some(0), | ||
|
||
// PSX does not support trap-on-condition instructions. | ||
llvm_args: cvs!["-mno-check-zero-division"], | ||
llvm_abiname: "o32".into(), | ||
panic_strategy: PanicStrategy::Abort, | ||
..Default::default() | ||
}, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# mipsel-sony-psx | ||
|
||
**Tier: 3** | ||
|
||
Sony PlayStation 1 (psx) | ||
|
||
## Designated Developer | ||
|
||
* [@ayrtonm](https://github.com/ayrtonm) | ||
|
||
## Requirements | ||
|
||
This target is cross-compiled. | ||
It has no special requirements for the host. | ||
|
||
## Building | ||
|
||
The target can be built by enabling it for a `rustc` build: | ||
|
||
```toml | ||
[build] | ||
build-stage = 1 | ||
target = ["mipsel-sony-psx"] | ||
``` | ||
|
||
## Cross-compilation | ||
|
||
This target can be cross-compiled from any host. | ||
|
||
## Testing | ||
|
||
Currently there is no support to run the rustc test suite for this target. | ||
|
||
## Building Rust programs | ||
|
||
Since it is Tier 3, rust doesn't ship pre-compiled artifacts for this target. | ||
|
||
Just use the `build-std` nightly cargo feature to build the `core` and `alloc` libraries: | ||
```shell | ||
cargo build -Zbuild-std=core,alloc --target mipsel-sony-psx | ||
``` | ||
|
||
The command above generates an ELF. To generate binaries in the PSEXE format that emulators run, you can use [cargo-psx](https://github.com/ayrtonm/psx-sdk-rs#readme): | ||
|
||
```shell | ||
cargo psx build | ||
``` | ||
|
||
or use `-Clink-arg=--oformat=binary` to produce a flat binary. |