-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
draft: Add support for hexagon-unknown-none-elf as target
Still TODO: document usage details for new target
- Loading branch information
Showing
5 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
compiler/rustc_target/src/spec/hexagon_unknown_none_elf.rs
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,29 @@ | ||
use crate::spec::{Cc, LinkerFlavor, Lld, PanicStrategy, RelocModel, Target, TargetOptions}; | ||
|
||
pub fn target() -> Target { | ||
Target { | ||
llvm_target: "hexagon-unknown-none-elf".into(), | ||
pointer_width: 32, | ||
data_layout: concat!( | ||
"e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32", | ||
":32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32", | ||
":32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048", | ||
":2048:2048" | ||
) | ||
.into(), | ||
arch: "hexagon".into(), | ||
|
||
options: TargetOptions { | ||
cpu: "hexagonv60".into(), | ||
linker: Some("clang".into()), | ||
position_independent_executables: true, | ||
panic_strategy: PanicStrategy::Abort, | ||
features: "-small-data,+hvx-length128b".into(), | ||
has_thread_local: true, | ||
max_atomic_width: Some(32), | ||
emit_debug_gdb_scripts: false, | ||
c_enum_min_bits: Some(8), | ||
..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
83 changes: 83 additions & 0 deletions
83
src/doc/rustc/src/platform-support/hexagon-unknown-none-elf.md
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,83 @@ | ||
# `hexagon-unknown-none-elf` | ||
|
||
**Tier: 3** | ||
|
||
Rust for baremetal Hexagon DSPs. | ||
|
||
| Target | Descriptions | | ||
| ------------------------ | ----------------------------------------- | | ||
| hexagon-unknown-none-elf | Hexagon v60 or later, HVX | | ||
|
||
## Target maintainers | ||
|
||
- Brian Cain, `bcain@quicinc.com`, https://github.com/androm3da | ||
|
||
## Requirements | ||
|
||
This target is cross-compiled. There is no support for `std`. There is no | ||
default allocator, but it's possible to use `alloc` by supplying an allocator. | ||
|
||
By default, code generated with this target should run on Hexagon DSP | ||
hardware, v60 or later. | ||
|
||
- `-Ctarget-cpu=hexagonv73` adds support for instructions defined up to Hexagon V73. | ||
|
||
Functions marked `extern "C"` use the | ||
[Hexagon architecture calling convention](https://lists.llvm.org/pipermail/llvm-dev/attachments/20190916/21516a52/attachment-0001.pdf). | ||
|
||
This target generates PIC ELF binaries. | ||
|
||
## Building the target | ||
|
||
You can build Rust with support for the target by adding it to the `target` | ||
list in `config.toml`: | ||
|
||
```toml | ||
[build] | ||
build-stage = 1 | ||
host = ["<target for your host>"] | ||
target = ["<target for your host>", "hexagon-unknown-none-elf"] | ||
|
||
[target.hexagon-unknown-none-elf] | ||
|
||
cc = "hexagon-unknown-none-elf-clang" | ||
cxx = "hexagon-unknown-none-elf-clang++" | ||
linker = "hexagon-unknown-none-elf-clang" | ||
llvm-libunwind = 'in-tree' | ||
``` | ||
|
||
Replace `<target for your host>` with `x86_64-unknown-linux-gnu` or whatever | ||
else is appropriate for your host machine. | ||
|
||
## Building Rust programs | ||
|
||
Rust does not yet ship pre-compiled artifacts for this target. To compile for | ||
this target, you will either need to build Rust with the target enabled (see | ||
"Building the target" above), or build your own copy of `core` by using | ||
`build-std` or similar. | ||
|
||
## Testing | ||
|
||
Since `hexagon-unknown-none-elf` supports a variety of different environments | ||
and does not support `std`, this target does not support running the Rust | ||
test suite. | ||
|
||
## Cross-compilation toolchains and C code | ||
|
||
This target has been tested using `hexagon-sim` from the Hexagon SDK. | ||
|
||
`.cargo/config.toml`: | ||
```toml | ||
[target.hexagon-unknown-none-elf] | ||
|
||
cc = "hexagon-unknown-none-elf-clang" | ||
cxx = "hexagon-unknown-none-elf-clang++" | ||
linker = "hexagon-unknown-none-elf-clang" | ||
runner = "hexagon-sim FIXME TBD details" | ||
|
||
[build] | ||
target = ["hexagon-unknown-none-elf"] | ||
rustflags = "-Ctarget-cpu=hexagonv73" | ||
``` | ||
|
||
FIXME TBD details |