Skip to content

Commit 6ed1358

Browse files
committed
Add a platform doc for hexagon-unknown-linux-musl
1 parent 62e144c commit 6ed1358

File tree

3 files changed

+100
-1
lines changed

3 files changed

+100
-1
lines changed

src/doc/rustc/src/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
- [\*-unknown-fuchsia](platform-support/fuchsia.md)
4040
- [\*-kmc-solid_\*](platform-support/kmc-solid.md)
4141
- [csky-unknown-linux-gnuabiv2\*](platform-support/csky-unknown-linux-gnuabiv2.md)
42+
- [hexagon-unknown-linux-musl](platform-support/hexagon-unknown-linux-musl.md)
4243
- [hexagon-unknown-none-elf](platform-support/hexagon-unknown-none-elf.md)
4344
- [loongarch\*-unknown-linux-\*](platform-support/loongarch-linux.md)
4445
- [loongarch\*-unknown-none\*](platform-support/loongarch-none.md)

src/doc/rustc/src/platform-support.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ target | std | host | notes
287287
`csky-unknown-linux-gnuabiv2` | ✓ | | C-SKY abiv2 Linux (little endian)
288288
`csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian)
289289
[`hexagon-unknown-none-elf`](platform-support/hexagon-unknown-none-elf.md)| * | | Bare Hexagon (v60+, HVX)
290-
`hexagon-unknown-linux-musl` | ? | |
290+
[`hexagon-unknown-linux-musl`](platform-support/hexagon-unknown-linux-musl.md) | | | Hexagon Linux
291291
`i386-apple-ios` | ✓ | | 32-bit x86 iOS [^x86_32-floats-return-ABI]
292292
[`i586-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS [^x86_32-floats-return-ABI]
293293
[`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | | 32-bit x86, restricted to Pentium
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
# `hexagon-unknown-linux-musl`
2+
3+
**Tier: 3**
4+
5+
Target for cross-compiling Linux user-mode applications targeting the Hexagon
6+
DSP architecture.
7+
8+
| Target | Descriptions |
9+
| ------------------------ | ----------------------------------------- |
10+
| hexagon-unknown-linux-musl | Hexagon 32-bit Linux |
11+
12+
## Target maintainers
13+
14+
- [Brian Cain](https://github.com/androm3da), `bcain@quicinc.com`
15+
16+
## Requirements
17+
The target is cross-compiled. This target supports `std`. By default, code
18+
generated with this target should run on Hexagon DSP hardware.
19+
20+
- `-Ctarget-cpu=hexagonv73` adds support for instructions defined up to Hexagon V73.
21+
22+
Binaries can be run using QEMU user emulation. On Debian-based systems, it should be
23+
sufficient to install the package `qemu-user-static` to be able to run simple static
24+
binaries:
25+
26+
```text
27+
# apt install qemu-user-static
28+
# qemu-hexagon-static ./hello
29+
```
30+
31+
In order to build linux programs with Rust, you will require a linker capable
32+
of targeting hexagon. You can use `clang`/`lld` from the [hexagon toolchain
33+
using exclusively public open source repos](https://github.com/quic/toolchain_for_hexagon/releases).
34+
35+
Also included in that toolchain is the C library that can be used when creating
36+
dynamically linked executables.
37+
38+
```text
39+
# /opt/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/qemu-hexagon -L /opt/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr/ ./hello
40+
```
41+
42+
## Building the target
43+
Because it is Tier 3, rust does not yet ship pre-compiled artifacts for this
44+
target.
45+
46+
Therefore, you can build Rust with support for the target by adding it to the
47+
target list in `config.toml`, a sample configuration is shown below.
48+
49+
```toml
50+
[build]
51+
target = [ "hexagon-unknown-linux-musl"]
52+
53+
[target.hexagon-unknown-linux-musl]
54+
55+
cc = "hexagon-unknown-linux-musl-clang"
56+
cxx = "hexagon-unknown-linux-musl-clang++"
57+
linker = "hexagon-unknown-linux-musl-clang"
58+
ar = "hexagon-unknown-linux-musl-ar"
59+
ranlib = "hexagon-unknown-linux-musl-ranlib"
60+
musl-root = "/opt/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr"
61+
llvm-libunwind = 'in-tree'
62+
qemu-rootfs = "/opt/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr"
63+
```
64+
65+
66+
## Testing
67+
68+
Currently there is no support to run the rustc test suite for this target.
69+
70+
71+
## Building Rust programs
72+
73+
Download and install the hexagon open source toolchain from https://github.com/quic/toolchain_for_hexagon/releases
74+
75+
The following `.cargo/config` is needed inside any project directory to build
76+
for the Hexagon Linux target:
77+
78+
```toml
79+
[build]
80+
target = "hexagon-unknown-linux-musl"
81+
82+
[target.hexagon-unknown-linux-musl]
83+
linker = "hexagon-unknown-linux-musl-clang"
84+
ar = "hexagon-unknown-linux-musl-ar"
85+
runner = "qemu-hexagon -L /opt/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr"
86+
```
87+
88+
Edit the "runner" in `.cargo/config` to point to the path to your toolchain's
89+
C library.
90+
91+
...
92+
runner = "qemu-hexagon -L /path/to/my/inst/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr"
93+
...
94+
95+
Build/run your rust program with `qemu-hexagon` in your `PATH`:
96+
97+
export PATH=/path/to/my/inst/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/:$PATH
98+
cargo run -Zbuild-std -Zbuild-std-features=llvm-libunwind

0 commit comments

Comments
 (0)