|
| 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 ./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 | +# ./clang+llvm-99.9-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/qemu-hexagon -L ./clang+llvm-99.9-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 target. |
| 44 | + |
| 45 | +Therefore, you can build Rust with support for the target by adding it to the |
| 46 | +target list in config.toml, a sample configuration is shown below. |
| 47 | + |
| 48 | +```toml |
| 49 | +[build] |
| 50 | +target = [ "hexagon-unknown-linux-musl"] |
| 51 | +docs = false |
| 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 = "/usr/local/clang+llvm-18.0.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr" |
| 61 | +llvm-libunwind = 'in-tree' |
| 62 | +qemu-rootfs = "/usr/local/clang+llvm-18.0.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 | +```text |
| 72 | +rustc --target hexagon-unknown-linux-musl your-code.rs |
| 73 | +``` |
| 74 | + |
| 75 | +## Building Rust programs |
| 76 | + |
| 77 | +The following `.cargo/config` is needed inside any project directory to build |
| 78 | +for the Hexagon Linux target: |
| 79 | + |
| 80 | +```toml |
| 81 | +[build] |
| 82 | +target = "hexagon-unknown-linux-musl" |
| 83 | + |
| 84 | +[target.hexagon-unknown-linux-musl] |
| 85 | +linker = "hexagon-unknown-linux-musl-clang" |
| 86 | +ar = "hexagon-unknown-linux-musl-ar" |
| 87 | +runner = "/usr/bin/env QEMU_LD_PREFIX=/usr/local/clang+llvm-18.0.0-rc1-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr qemu-hexagon" |
| 88 | +``` |
| 89 | + |
0 commit comments