Rollup merge of #147173 - androm3da:bcain/hexagon_qurt, r=davidtwco,tgross35
Add support for hexagon-unknown-qurt target MCP: https://github.com/rust-lang/compiler-team/issues/919 Fixes https://github.com/rust-lang/rust/issues/148982.
This commit is contained in:
commit
422b83aeee
9 changed files with 236 additions and 3 deletions
|
|
@ -1490,6 +1490,7 @@ supported_targets! {
|
|||
("mips64el-unknown-linux-muslabi64", mips64el_unknown_linux_muslabi64),
|
||||
("hexagon-unknown-linux-musl", hexagon_unknown_linux_musl),
|
||||
("hexagon-unknown-none-elf", hexagon_unknown_none_elf),
|
||||
("hexagon-unknown-qurt", hexagon_unknown_qurt),
|
||||
|
||||
("mips-unknown-linux-uclibc", mips_unknown_linux_uclibc),
|
||||
("mipsel-unknown-linux-uclibc", mipsel_unknown_linux_uclibc),
|
||||
|
|
@ -1958,6 +1959,7 @@ crate::target_spec_enum! {
|
|||
OpenBsd = "openbsd",
|
||||
Psp = "psp",
|
||||
Psx = "psx",
|
||||
Qurt = "qurt",
|
||||
Redox = "redox",
|
||||
Rtems = "rtems",
|
||||
Solaris = "solaris",
|
||||
|
|
|
|||
|
|
@ -0,0 +1,45 @@
|
|||
use crate::spec::{Arch, Cc, LinkerFlavor, Lld, Os, Target, TargetMetadata, TargetOptions, cvs};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = TargetOptions::default();
|
||||
base.add_pre_link_args(LinkerFlavor::Gnu(Cc::No, Lld::No), &["-G0"]);
|
||||
|
||||
Target {
|
||||
llvm_target: "hexagon-unknown-elf".into(),
|
||||
metadata: TargetMetadata {
|
||||
description: Some("Hexagon QuRT".into()),
|
||||
tier: Some(3),
|
||||
host_tools: Some(false),
|
||||
std: Some(false),
|
||||
},
|
||||
pointer_width: 32,
|
||||
data_layout: "\
|
||||
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: Arch::Hexagon,
|
||||
options: TargetOptions {
|
||||
os: Os::Qurt,
|
||||
vendor: "unknown".into(),
|
||||
cpu: "hexagonv69".into(),
|
||||
linker: Some("rust-lld".into()),
|
||||
linker_flavor: LinkerFlavor::Gnu(Cc::No, Lld::Yes),
|
||||
exe_suffix: ".elf".into(),
|
||||
dynamic_linking: true,
|
||||
executables: true,
|
||||
families: cvs!["unix"],
|
||||
has_thread_local: true,
|
||||
has_rpath: false,
|
||||
crt_static_default: false,
|
||||
crt_static_respected: true,
|
||||
crt_static_allows_dylibs: true,
|
||||
no_default_libraries: false,
|
||||
max_atomic_width: Some(32),
|
||||
features: "-small-data,+hvx-length128b".into(),
|
||||
c_enum_min_bits: Some(8),
|
||||
..base
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -41,6 +41,7 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
|
|||
"sparc64-unknown-helenos",
|
||||
// just a dummy comment so the list doesn't get onelined
|
||||
"riscv64gc-unknown-redox",
|
||||
"hexagon-unknown-qurt",
|
||||
];
|
||||
|
||||
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@
|
|||
- [csky-unknown-linux-gnuabiv2\*](platform-support/csky-unknown-linux-gnuabiv2.md)
|
||||
- [hexagon-unknown-linux-musl](platform-support/hexagon-unknown-linux-musl.md)
|
||||
- [hexagon-unknown-none-elf](platform-support/hexagon-unknown-none-elf.md)
|
||||
- [hexagon-unknown-qurt](platform-support/hexagon-unknown-qurt.md)
|
||||
- [illumos](platform-support/illumos.md)
|
||||
- [loongarch\*-unknown-linux-\*](platform-support/loongarch-linux.md)
|
||||
- [loongarch\*-unknown-none\*](platform-support/loongarch-none.md)
|
||||
|
|
|
|||
|
|
@ -315,6 +315,7 @@ target | std | host | notes
|
|||
`csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian)
|
||||
[`hexagon-unknown-linux-musl`](platform-support/hexagon-unknown-linux-musl.md) | ✓ | | Hexagon Linux with musl 1.2.5
|
||||
[`hexagon-unknown-none-elf`](platform-support/hexagon-unknown-none-elf.md)| * | | Bare Hexagon (v60+, HVX)
|
||||
[`hexagon-unknown-qurt`](platform-support/hexagon-unknown-qurt.md)| * | | Hexagon QuRT
|
||||
[`i386-apple-ios`](platform-support/apple-ios.md) | ✓ | | 32-bit x86 iOS (Penryn) [^x86_32-floats-return-ABI]
|
||||
[`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | | 32-bit x86 (original Pentium) [^x86_32-floats-x87]
|
||||
[`i586-unknown-redox`](platform-support/redox.md) | ✓ | | 32-bit x86 Redox OS (PentiumPro) [^x86_32-floats-x87]
|
||||
|
|
|
|||
180
src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md
Normal file
180
src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md
Normal file
|
|
@ -0,0 +1,180 @@
|
|||
# `hexagon-unknown-qurt`
|
||||
|
||||
**Tier: 3**
|
||||
|
||||
Rust for Hexagon QuRT (Qualcomm Real-Time OS).
|
||||
|
||||
| Target | Description |
|
||||
| -------------------- | ------------|
|
||||
| hexagon-unknown-qurt | Hexagon 32-bit QuRT |
|
||||
|
||||
## Target maintainers
|
||||
|
||||
[@androm3da](https://github.com/androm3da)
|
||||
|
||||
## Requirements
|
||||
|
||||
This target is cross-compiled. There is support for `std`. The target uses
|
||||
QuRT's standard library and runtime.
|
||||
|
||||
By default, code generated with this target should run on Hexagon DSP hardware
|
||||
running the QuRT real-time operating system.
|
||||
|
||||
- `-Ctarget-cpu=hexagonv69` targets Hexagon V69 architecture (default)
|
||||
- `-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 position-independent ELF binaries by default, making it
|
||||
suitable for both static images and dynamic shared objects.
|
||||
|
||||
The [Hexagon SDK](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK) is
|
||||
required for building programs for this target.
|
||||
|
||||
## Linking
|
||||
|
||||
This target selects `rust-lld` by default. Another option to use is
|
||||
[eld](https://github.com/qualcomm/eld), which is also provided with
|
||||
[the opensource hexagon toolchain](https://github.com/quic/toolchain_for_hexagon)
|
||||
and the Hexagon SDK.
|
||||
|
||||
## Building the target
|
||||
|
||||
You can build Rust with support for the target by adding it to the `target`
|
||||
list in `bootstrap.toml`:
|
||||
|
||||
```toml
|
||||
[build]
|
||||
build-stage = 1
|
||||
host = ["<target for your host>"]
|
||||
target = ["<target for your host>", "hexagon-unknown-qurt"]
|
||||
|
||||
[target.hexagon-unknown-qurt]
|
||||
cc = "hexagon-clang"
|
||||
cxx = "hexagon-clang++"
|
||||
ranlib = "llvm-ranlib"
|
||||
ar = "llvm-ar"
|
||||
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.
|
||||
|
||||
## Static Image Targeting
|
||||
|
||||
For static executables that run directly on QuRT, use the default target
|
||||
configuration with additional linker flags:
|
||||
|
||||
```sh
|
||||
# Build a static executable for QuRT
|
||||
cargo rustc --target hexagon-unknown-qurt -- \
|
||||
-C link-args="-static -nostdlib" \
|
||||
-C link-args="-L/opt/Hexagon_SDK/6.3.0.0/rtos/qurt/computev69/lib" \
|
||||
-C link-args="-lqurt -lc"
|
||||
```
|
||||
|
||||
This approach is suitable for:
|
||||
- Standalone QuRT applications
|
||||
- System-level services
|
||||
- Boot-time initialization code
|
||||
- Applications that need deterministic memory layout
|
||||
|
||||
## User-Loadable Shared Object Targeting
|
||||
|
||||
For shared libraries that can be dynamically loaded by QuRT applications:
|
||||
|
||||
```sh
|
||||
# Build a shared object for QuRT
|
||||
cargo rustc --target hexagon-unknown-qurt \
|
||||
--crate-type=cdylib -- \
|
||||
-C link-args="-shared -fPIC" \
|
||||
-C link-args="-L/opt/Hexagon_SDK/6.3.0.0/rtos/qurt/computev69/lib"
|
||||
```
|
||||
|
||||
This approach is suitable for:
|
||||
- Plugin architectures
|
||||
- Runtime-loadable modules
|
||||
- Libraries shared between multiple applications
|
||||
- Code that needs to be updated without system restart
|
||||
|
||||
## Configuration Options
|
||||
|
||||
The target can be customized for different use cases:
|
||||
|
||||
### For Static Images
|
||||
```toml
|
||||
# In .cargo/config.toml
|
||||
[target.hexagon-unknown-qurt]
|
||||
rustflags = [
|
||||
"-C", "link-args=-static",
|
||||
"-C", "link-args=-nostdlib",
|
||||
"-C", "target-feature=-small-data"
|
||||
]
|
||||
```
|
||||
|
||||
### For Shared Objects
|
||||
```toml
|
||||
# In .cargo/config.toml
|
||||
[target.hexagon-unknown-qurt]
|
||||
rustflags = [
|
||||
"-C", "link-args=-shared",
|
||||
"-C", "link-args=-fPIC",
|
||||
"-C", "relocation-model=pic"
|
||||
]
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Since `hexagon-unknown-qurt` requires the QuRT runtime environment, testing requires
|
||||
either:
|
||||
- Hexagon hardware with QuRT
|
||||
- `hexagon-sim`
|
||||
- QEMU (`qemu-system-hexagon`)
|
||||
|
||||
## Cross-compilation toolchains and C code
|
||||
|
||||
This target requires the proprietary [Hexagon SDK toolchain for C interoperability](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK):
|
||||
|
||||
- **Sample SDK Path**: `/opt/Hexagon_SDK/6.3.0.0/`
|
||||
- **Toolchain**: Use `hexagon-clang` from the Hexagon SDK
|
||||
- **Libraries**: Link against QuRT system libraries as needed
|
||||
|
||||
### C Interoperability Example
|
||||
|
||||
```rust
|
||||
// lib.rs
|
||||
#![no_std]
|
||||
extern crate std;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub extern "C" fn rust_function() -> i32 {
|
||||
// Your Rust code here
|
||||
42
|
||||
}
|
||||
|
||||
fn main() {
|
||||
// Example usage
|
||||
let result = rust_function();
|
||||
assert_eq!(result, 42);
|
||||
}
|
||||
```
|
||||
|
||||
```c
|
||||
// wrapper.c
|
||||
extern int rust_function(void);
|
||||
|
||||
int main() {
|
||||
return rust_function();
|
||||
}
|
||||
```
|
||||
|
||||
The target supports both static linking for standalone applications and dynamic
|
||||
linking for modular architectures, making it flexible for various QuRT
|
||||
deployment scenarios.
|
||||
|
|
@ -235,6 +235,9 @@
|
|||
//@ revisions: hexagon_unknown_none_elf
|
||||
//@ [hexagon_unknown_none_elf] compile-flags: --target hexagon-unknown-none-elf
|
||||
//@ [hexagon_unknown_none_elf] needs-llvm-components: hexagon
|
||||
//@ revisions: hexagon_unknown_qurt
|
||||
//@ [hexagon_unknown_qurt] compile-flags: --target hexagon-unknown-qurt
|
||||
//@ [hexagon_unknown_qurt] needs-llvm-components: hexagon
|
||||
//@ revisions: i686_pc_nto_qnx700
|
||||
//@ [i686_pc_nto_qnx700] compile-flags: --target i686-pc-nto-qnx700
|
||||
//@ [i686_pc_nto_qnx700] needs-llvm-components: x86
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ warning: unexpected `cfg` condition value: `does_not_exist`
|
|||
LL | #![cfg(not(target(os = "does_not_exist")))]
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, and `teeos` and 13 more
|
||||
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, and `solid_asp3` and 14 more
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
= note: `#[warn(unexpected_cfgs)]` on by default
|
||||
|
||||
|
|
|
|||
|
|
@ -201,7 +201,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
|
|||
LL | target_os = "_UNEXPECTED_VALUE",
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
|
||||
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
|
||||
warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE`
|
||||
|
|
@ -274,7 +274,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux`
|
|||
| |
|
||||
| help: there is a expected value with a similar name: `"linux"`
|
||||
|
|
||||
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
|
||||
= note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `helenos`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm`
|
||||
= note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration
|
||||
|
||||
warning: 28 warnings emitted
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue