From c9d211bdb70cc5b0169f9d1093a5ea4bfada0878 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Mon, 29 Sep 2025 23:39:22 -0500 Subject: [PATCH 1/9] Add support for hexagon-unknown-qurt target --- compiler/rustc_target/src/spec/mod.rs | 1 + .../src/spec/targets/hexagon_unknown_qurt.rs | 50 ++++++ .../platform-support/hexagon-unknown-qurt.md | 165 ++++++++++++++++++ 3 files changed, 216 insertions(+) create mode 100644 compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs create mode 100644 src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index 4a82a8bd888e6..ac9ebac33db52 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1487,6 +1487,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), diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs new file mode 100644 index 0000000000000..472c8fece63c3 --- /dev/null +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs @@ -0,0 +1,50 @@ +use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, TargetOptions, cvs}; + +pub(crate) fn target() -> Target { + let mut pre_link_args = std::collections::BTreeMap::>::new(); + pre_link_args + .entry(LinkerFlavor::Unix(Cc::Yes)) + .or_default() + .extend(["-G0".into()].into_iter()); + + Target { + llvm_target: "hexagon-unknown-elf".into(), + metadata: TargetMetadata { + description: Some("Hexagon QuRT (Qualcomm Real-Time OS)".into()), + tier: Some(3), + host_tools: Some(false), + std: Some(true), + }, + 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 { + os: "qurt".into(), + vendor: "unknown".into(), + cpu: "hexagonv69".into(), + linker: Some("rust-lld".into()), + linker_flavor: LinkerFlavor::Unix(Cc::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), + pre_link_args, + ..Default::default() + }, + } +} diff --git a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md new file mode 100644 index 0000000000000..7e10ff81f28d0 --- /dev/null +++ b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md @@ -0,0 +1,165 @@ +# `hexagon-unknown-qurt` + +**Tier: 3** + +Rust for Hexagon QuRT (Qualcomm Real-Time OS). + +| Target | Description | +| -------------------- | -------------------------------------------- | +| hexagon-unknown-qurt | Hexagon 32-bit QuRT (position independent) | + +## 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. + +## 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 = ["", "hexagon-unknown-qurt"] + +[target.hexagon-unknown-qurt] +cc = "hexagon-clang" +cxx = "hexagon-clang++" +ranlib = "hexagon-ranlib" +ar = "hexagon-ar" +llvm-libunwind = 'in-tree' +``` + +Replace `` 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 build --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 build --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 [Hexagon SDK toolchain for C interoperability](https://softwarecenter.qualcomm.com/api/download/software/sdks/Hexagon_SDK/Linux/Debian/6.3.0.0/Hexagon_SDK.zip): + +- **SDK Path**: `/opt/Hexagon_SDK/6.3.0.0/` +- **Toolchain**: Use `hexagon-clang` from the Hexagon SDK +- **Headers**: QuRT and POSIX headers are automatically included +- **Libraries**: Link against QuRT system libraries as needed + +### C Interoperability Example + +```rust +// lib.rs +#![no_std] +extern crate std; + +#[no_mangle] +pub extern "C" fn rust_function() -> i32 { + // Your Rust code here + 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. From ade9252acabc157a365391b3dbc5dc4002357edf Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 30 Sep 2025 08:28:54 -0500 Subject: [PATCH 2/9] Changes from review --- .../rustc_target/src/spec/targets/hexagon_unknown_qurt.rs | 2 +- src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md | 4 ++-- tests/assembly-llvm/targets/targets-elf.rs | 3 +++ tests/ui/check-cfg/cfg-crate-features.stderr | 2 +- tests/ui/check-cfg/well-known-values.stderr | 4 ++-- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs index 472c8fece63c3..2852acf918bef 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs @@ -5,7 +5,7 @@ pub(crate) fn target() -> Target { pre_link_args .entry(LinkerFlavor::Unix(Cc::Yes)) .or_default() - .extend(["-G0".into()].into_iter()); + .extend(["-G0".into()]); Target { llvm_target: "hexagon-unknown-elf".into(), diff --git a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md index 7e10ff81f28d0..72425461e2a88 100644 --- a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md +++ b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md @@ -130,7 +130,7 @@ either: ## Cross-compilation toolchains and C code -This target requires the [Hexagon SDK toolchain for C interoperability](https://softwarecenter.qualcomm.com/api/download/software/sdks/Hexagon_SDK/Linux/Debian/6.3.0.0/Hexagon_SDK.zip): +This target requires the proprietary [Hexagon SDK toolchain for C interoperability](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK): - **SDK Path**: `/opt/Hexagon_SDK/6.3.0.0/` - **Toolchain**: Use `hexagon-clang` from the Hexagon SDK @@ -144,7 +144,7 @@ This target requires the [Hexagon SDK toolchain for C interoperability](https:// #![no_std] extern crate std; -#[no_mangle] +#[unsafe(no_mangle)] pub extern "C" fn rust_function() -> i32 { // Your Rust code here 42 diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index ebea9fe40f518..19afc1f47c4b3 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -232,6 +232,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 diff --git a/tests/ui/check-cfg/cfg-crate-features.stderr b/tests/ui/check-cfg/cfg-crate-features.stderr index 39fee52a909b6..23ff7224a02fa 100644 --- a/tests/ui/check-cfg/cfg-crate-features.stderr +++ b/tests/ui/check-cfg/cfg-crate-features.stderr @@ -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`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, and `trusty` and 12 more + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `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`, and `trusty` and 12 more = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index e62f741b3020c..fc1c0b2016ce0 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -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`, `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`, `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 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`, `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`, `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 for more information about checking conditional configuration warning: 28 warnings emitted From aac9b5ed09e72b3696044dae47848798deaaef15 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Tue, 30 Sep 2025 10:41:16 -0500 Subject: [PATCH 3/9] format hexagon_unknown_qurt.rs --- .../rustc_target/src/spec/targets/hexagon_unknown_qurt.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs index 2852acf918bef..db372cd2a0da3 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs @@ -2,10 +2,7 @@ use crate::spec::{Cc, LinkerFlavor, Target, TargetMetadata, TargetOptions, cvs}; pub(crate) fn target() -> Target { let mut pre_link_args = std::collections::BTreeMap::>::new(); - pre_link_args - .entry(LinkerFlavor::Unix(Cc::Yes)) - .or_default() - .extend(["-G0".into()]); + pre_link_args.entry(LinkerFlavor::Unix(Cc::Yes)).or_default().extend(["-G0".into()]); Target { llvm_target: "hexagon-unknown-elf".into(), From ff0bdd2a14dd517e6c1e950ea3897112362d922a Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 2 Oct 2025 13:44:07 -0500 Subject: [PATCH 4/9] Rename hexagon-unknown-qurt => hexagon-qurt Discsussion with compiler team converged on "hexagon-qurt" as a target name. Also: describe the available linkers. --- compiler/rustc_target/src/spec/mod.rs | 2 +- ...exagon_unknown_qurt.rs => hexagon_qurt.rs} | 0 .../platform-support/hexagon-unknown-qurt.md | 32 +++++++++++-------- tests/assembly-llvm/targets/targets-elf.rs | 6 ++-- 4 files changed, 23 insertions(+), 17 deletions(-) rename compiler/rustc_target/src/spec/targets/{hexagon_unknown_qurt.rs => hexagon_qurt.rs} (100%) diff --git a/compiler/rustc_target/src/spec/mod.rs b/compiler/rustc_target/src/spec/mod.rs index ac9ebac33db52..e58646d741486 100644 --- a/compiler/rustc_target/src/spec/mod.rs +++ b/compiler/rustc_target/src/spec/mod.rs @@ -1487,7 +1487,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), + ("hexagon-qurt", hexagon_qurt), ("mips-unknown-linux-uclibc", mips_unknown_linux_uclibc), ("mipsel-unknown-linux-uclibc", mipsel_unknown_linux_uclibc), diff --git a/compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs similarity index 100% rename from compiler/rustc_target/src/spec/targets/hexagon_unknown_qurt.rs rename to compiler/rustc_target/src/spec/targets/hexagon_qurt.rs diff --git a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md index 72425461e2a88..72d75870e9404 100644 --- a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md +++ b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md @@ -1,12 +1,12 @@ -# `hexagon-unknown-qurt` +# `hexagon-qurt` **Tier: 3** Rust for Hexagon QuRT (Qualcomm Real-Time OS). -| Target | Description | -| -------------------- | -------------------------------------------- | -| hexagon-unknown-qurt | Hexagon 32-bit QuRT (position independent) | +| Target | Description | +| -------------------- | ------------| +| hexagon-qurt | Hexagon 32-bit QuRT | ## Target maintainers @@ -28,6 +28,13 @@ Functions marked `extern "C"` use the [Hexagon architecture calling convention]( This target generates position-independent ELF binaries by default, making it suitable for both static images and dynamic shared objects. +## 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](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK). + ## Building the target You can build Rust with support for the target by adding it to the `target` @@ -37,9 +44,9 @@ list in `bootstrap.toml`: [build] build-stage = 1 host = [""] -target = ["", "hexagon-unknown-qurt"] +target = ["", "hexagon-qurt"] -[target.hexagon-unknown-qurt] +[target.hexagon-qurt] cc = "hexagon-clang" cxx = "hexagon-clang++" ranlib = "hexagon-ranlib" @@ -64,7 +71,7 @@ configuration with additional linker flags: ```sh # Build a static executable for QuRT -cargo build --target hexagon-unknown-qurt \ +cargo build --target hexagon-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" @@ -82,7 +89,7 @@ For shared libraries that can be dynamically loaded by QuRT applications: ```sh # Build a shared object for QuRT -cargo build --target hexagon-unknown-qurt \ +cargo build --target hexagon-qurt \ --crate-type=cdylib \ -C link-args="-shared -fPIC" \ -C link-args="-L/opt/Hexagon_SDK/6.3.0.0/rtos/qurt/computev69/lib" @@ -101,7 +108,7 @@ The target can be customized for different use cases: ### For Static Images ```toml # In .cargo/config.toml -[target.hexagon-unknown-qurt] +[target.hexagon-qurt] rustflags = [ "-C", "link-args=-static", "-C", "link-args=-nostdlib", @@ -112,7 +119,7 @@ rustflags = [ ### For Shared Objects ```toml # In .cargo/config.toml -[target.hexagon-unknown-qurt] +[target.hexagon-qurt] rustflags = [ "-C", "link-args=-shared", "-C", "link-args=-fPIC", @@ -122,7 +129,7 @@ rustflags = [ ## Testing -Since `hexagon-unknown-qurt` requires the QuRT runtime environment, testing requires +Since `hexagon-qurt` requires the QuRT runtime environment, testing requires either: - Hexagon hardware with QuRT - `hexagon-sim` @@ -132,9 +139,8 @@ either: This target requires the proprietary [Hexagon SDK toolchain for C interoperability](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK): -- **SDK Path**: `/opt/Hexagon_SDK/6.3.0.0/` +- **Sample SDK Path**: `/opt/Hexagon_SDK/6.3.0.0/` - **Toolchain**: Use `hexagon-clang` from the Hexagon SDK -- **Headers**: QuRT and POSIX headers are automatically included - **Libraries**: Link against QuRT system libraries as needed ### C Interoperability Example diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index 19afc1f47c4b3..a4d6e5e61d8a9 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -232,9 +232,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: hexagon_qurt +//@ [hexagon_qurt] compile-flags: --target hexagon-qurt +//@ [hexagon_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 From 6de0adfae8286a280db086b655284e97a9ffc2c9 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 2 Oct 2025 14:27:14 -0500 Subject: [PATCH 5/9] Fix test failure in tests/ui/ --- tests/ui/check-cfg/cfg-crate-features.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/check-cfg/cfg-crate-features.stderr b/tests/ui/check-cfg/cfg-crate-features.stderr index 23ff7224a02fa..c9102cdb2a0e6 100644 --- a/tests/ui/check-cfg/cfg-crate-features.stderr +++ b/tests/ui/check-cfg/cfg-crate-features.stderr @@ -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`, `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`, and `trusty` and 12 more + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `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`, and `trusty` and 13 more = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default From 85fe1067f47959298cfdfb6ba4ec474f5a3fb3c8 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 2 Oct 2025 14:55:02 -0500 Subject: [PATCH 6/9] Update compiler/rustc_target/src/spec/targets/hexagon_qurt.rs Co-authored-by: Trevor Gross --- .../rustc_target/src/spec/targets/hexagon_qurt.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs index db372cd2a0da3..fa2c35b498970 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs @@ -13,12 +13,11 @@ pub(crate) fn target() -> Target { std: Some(true), }, 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" - ) + 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() .into(), arch: "hexagon".into(), options: TargetOptions { From 06b7f5f8bd58139f5c1cdcadede21629adb165f6 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 2 Oct 2025 19:31:16 -0500 Subject: [PATCH 7/9] fixes from review --- .../rustc_target/src/spec/targets/hexagon_qurt.rs | 9 +++++---- src/doc/rustc/src/platform-support.md | 1 + .../src/platform-support/hexagon-unknown-qurt.md | 15 +++++++++------ 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs index fa2c35b498970..8a56a2fe7cce3 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs @@ -7,18 +7,19 @@ pub(crate) fn target() -> Target { Target { llvm_target: "hexagon-unknown-elf".into(), metadata: TargetMetadata { - description: Some("Hexagon QuRT (Qualcomm Real-Time OS)".into()), + description: Some("Hexagon QuRT".into()), tier: Some(3), host_tools: Some(false), - std: Some(true), + 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() - .into(), + :2048:2048" + .into() + .into(), arch: "hexagon".into(), options: TargetOptions { os: "qurt".into(), diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index d0b6ed51bc163..c95229e591930 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -314,6 +314,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.3 [`hexagon-unknown-none-elf`](platform-support/hexagon-unknown-none-elf.md)| * | | Bare Hexagon (v60+, HVX) +[`hexagon-qurt`](platform-support/hexagon-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] diff --git a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md index 72d75870e9404..f2053e685d54d 100644 --- a/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md +++ b/src/doc/rustc/src/platform-support/hexagon-unknown-qurt.md @@ -28,12 +28,15 @@ Functions marked `extern "C"` use the [Hexagon architecture calling convention]( 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](https://softwarecenter.qualcomm.com/catalog/item/Hexagon_SDK). +and the Hexagon SDK. ## Building the target @@ -49,8 +52,8 @@ target = ["", "hexagon-qurt"] [target.hexagon-qurt] cc = "hexagon-clang" cxx = "hexagon-clang++" -ranlib = "hexagon-ranlib" -ar = "hexagon-ar" +ranlib = "llvm-ranlib" +ar = "llvm-ar" llvm-libunwind = 'in-tree' ``` @@ -71,7 +74,7 @@ configuration with additional linker flags: ```sh # Build a static executable for QuRT -cargo build --target hexagon-qurt \ +cargo rustc --target hexagon-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" @@ -89,8 +92,8 @@ For shared libraries that can be dynamically loaded by QuRT applications: ```sh # Build a shared object for QuRT -cargo build --target hexagon-qurt \ - --crate-type=cdylib \ +cargo rustc --target hexagon-qurt \ + --crate-type=cdylib -- \ -C link-args="-shared -fPIC" \ -C link-args="-L/opt/Hexagon_SDK/6.3.0.0/rtos/qurt/computev69/lib" ``` From 597e485339f3a4f3c70b008b715b92b402f313b4 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Thu, 2 Oct 2025 20:06:00 -0500 Subject: [PATCH 8/9] fix CI failures --- compiler/rustc_target/src/spec/targets/hexagon_qurt.rs | 1 - src/bootstrap/src/core/sanity.rs | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs b/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs index 8a56a2fe7cce3..7f153fa683bbe 100644 --- a/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs +++ b/compiler/rustc_target/src/spec/targets/hexagon_qurt.rs @@ -18,7 +18,6 @@ pub(crate) fn target() -> Target { :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() .into(), arch: "hexagon".into(), options: TargetOptions { diff --git a/src/bootstrap/src/core/sanity.rs b/src/bootstrap/src/core/sanity.rs index eaa9e3a6a3e9d..f7a6f937246c7 100644 --- a/src/bootstrap/src/core/sanity.rs +++ b/src/bootstrap/src/core/sanity.rs @@ -35,6 +35,7 @@ pub struct Finder { const STAGE0_MISSING_TARGETS: &[&str] = &[ // just a dummy comment so the list doesn't get onelined "x86_64-unknown-motor", + "hexagon-unknown-qurt", ]; /// Minimum version threshold for libstdc++ required when using prebuilt LLVM From 5be8956b728e58641905f55e34533fb168ba79b6 Mon Sep 17 00:00:00 2001 From: Brian Cain Date: Fri, 17 Oct 2025 12:18:37 -0500 Subject: [PATCH 9/9] fix for omitted "trusty" from test case --- tests/ui/check-cfg/cfg-crate-features.stderr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/ui/check-cfg/cfg-crate-features.stderr b/tests/ui/check-cfg/cfg-crate-features.stderr index c9102cdb2a0e6..612f227b92aff 100644 --- a/tests/ui/check-cfg/cfg-crate-features.stderr +++ b/tests/ui/check-cfg/cfg-crate-features.stderr @@ -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`, `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`, and `trusty` and 13 more + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `motor`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `qurt`, `redox`, `rtems`, `solaris`, `solid_asp3`, and `teeos` and 13 more = note: see for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default