diff options
| author | bors <bors@rust-lang.org> | 2024-02-29 13:35:16 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-29 13:35:16 +0000 |
| commit | 384d26fc7e3bdd7687cc17b2662b091f6017ec2a (patch) | |
| tree | 92c1723144aab5f058f229272d70dbfe751444a1 /src | |
| parent | 71a7b66f20c551f640f2f382bc7e7923ba0a5dab (diff) | |
| parent | bc23b843865fbfd1d585b133ac3006239021f5c4 (diff) | |
| download | rust-384d26fc7e3bdd7687cc17b2662b091f6017ec2a.tar.gz rust-384d26fc7e3bdd7687cc17b2662b091f6017ec2a.zip | |
Auto merge of #121800 - GuillaumeGomez:rollup-wob2qcz, r=GuillaumeGomez
Rollup of 10 pull requests Successful merges: - #118217 (Document which methods on `f64` are precise) - #119748 (Increase visibility of `join_path` and `split_paths`) - #121412 (platform docs: clarify hexagon-unknown-none-elf example, add hexagon-unknown-linux-musl) - #121654 (Fix `async Fn` confirmation for `FnDef`/`FnPtr`/`Closure` types) - #121700 (CFI: Don't compress user-defined builtin types) - #121765 (add platform-specific function to get the error number for HermitOS) - #121781 (bootstrap/format: send larger batches to rustfmt) - #121788 (bootstrap: fix clap deprecated warnings) - #121792 (Improve renaming suggestion when item starts with underscore) - #121793 (Document which methods on `f32` are precise) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'src')
| -rw-r--r-- | src/bootstrap/src/core/build_steps/format.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/src/core/builder.rs | 10 | ||||
| -rw-r--r-- | src/bootstrap/src/core/config/flags.rs | 28 | ||||
| -rw-r--r-- | src/doc/rustc/src/SUMMARY.md | 1 | ||||
| -rw-r--r-- | src/doc/rustc/src/platform-support.md | 4 | ||||
| -rw-r--r-- | src/doc/rustc/src/platform-support/hexagon-unknown-linux-musl.md | 102 | ||||
| -rw-r--r-- | src/doc/rustc/src/platform-support/hexagon-unknown-none-elf.md | 19 |
7 files changed, 142 insertions, 26 deletions
diff --git a/src/bootstrap/src/core/build_steps/format.rs b/src/bootstrap/src/core/build_steps/format.rs index 69c8792b031..700c3ee4fda 100644 --- a/src/bootstrap/src/core/build_steps/format.rs +++ b/src/bootstrap/src/core/build_steps/format.rs @@ -279,8 +279,8 @@ pub fn format(build: &Builder<'_>, check: bool, paths: &[PathBuf]) { let thread = std::thread::spawn(move || { let mut children = VecDeque::new(); while let Ok(path) = rx.recv() { - // try getting a few more paths from the channel to amortize the overhead of spawning processes - let paths: Vec<_> = rx.try_iter().take(7).chain(std::iter::once(path)).collect(); + // try getting more paths from the channel to amortize the overhead of spawning processes + let paths: Vec<_> = rx.try_iter().take(63).chain(std::iter::once(path)).collect(); let child = rustfmt(&src, &rustfmt_path, paths.as_slice(), check); children.push_back(child); diff --git a/src/bootstrap/src/core/builder.rs b/src/bootstrap/src/core/builder.rs index e169cba3c13..8223a80c931 100644 --- a/src/bootstrap/src/core/builder.rs +++ b/src/bootstrap/src/core/builder.rs @@ -642,22 +642,22 @@ impl<'a> ShouldRun<'a> { #[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, ValueEnum)] pub enum Kind { - #[clap(alias = "b")] + #[value(alias = "b")] Build, - #[clap(alias = "c")] + #[value(alias = "c")] Check, Clippy, Fix, Format, - #[clap(alias = "t")] + #[value(alias = "t")] Test, Bench, - #[clap(alias = "d")] + #[value(alias = "d")] Doc, Clean, Dist, Install, - #[clap(alias = "r")] + #[value(alias = "r")] Run, Setup, Suggest, diff --git a/src/bootstrap/src/core/config/flags.rs b/src/bootstrap/src/core/config/flags.rs index 8af454001a6..7262b785ee0 100644 --- a/src/bootstrap/src/core/config/flags.rs +++ b/src/bootstrap/src/core/config/flags.rs @@ -31,7 +31,7 @@ pub enum Warnings { /// Deserialized version of all flags for this compile. #[derive(Debug, Parser)] -#[clap( +#[command( override_usage = "x.py <subcommand> [options] [<paths>...]", disable_help_subcommand(true), about = "", @@ -118,7 +118,7 @@ pub struct Flags { // This overrides the deny-warnings configuration option, // which passes -Dwarnings to the compiler invocations. #[arg(global(true), long)] - #[clap(value_enum, default_value_t=Warnings::Default, value_name = "deny|warn")] + #[arg(value_enum, default_value_t=Warnings::Default, value_name = "deny|warn")] /// if value is deny, will deny warnings /// if value is warn, will emit warnings /// otherwise, use the default configured behaviour @@ -132,7 +132,7 @@ pub struct Flags { pub json_output: bool, #[arg(global(true), long, value_name = "STYLE")] - #[clap(value_enum, default_value_t = Color::Auto)] + #[arg(value_enum, default_value_t = Color::Auto)] /// whether to use color in cargo and rustc output pub color: Color, @@ -188,7 +188,7 @@ impl Flags { let it = std::iter::once(&first).chain(args.iter()); // We need to check for `<cmd> -h -v`, in which case we list the paths #[derive(Parser)] - #[clap(disable_help_flag(true))] + #[command(disable_help_flag(true))] struct HelpVerboseOnly { #[arg(short, long)] help: bool, @@ -218,7 +218,7 @@ impl Flags { #[derive(Debug, Clone, Default, clap::Subcommand)] pub enum Subcommand { - #[clap(aliases = ["b"], long_about = "\n + #[command(aliases = ["b"], long_about = "\n Arguments: This subcommand accepts a number of paths to directories to the crates and/or artifacts to compile. For example, for a quick build of a usable @@ -233,7 +233,7 @@ pub enum Subcommand { /// Compile either the compiler or libraries #[default] Build, - #[clap(aliases = ["c"], long_about = "\n + #[command(aliases = ["c"], long_about = "\n Arguments: This subcommand accepts a number of paths to directories to the crates and/or artifacts to compile. For example: @@ -246,7 +246,7 @@ pub enum Subcommand { all_targets: bool, }, /// Run Clippy (uses rustup/cargo-installed clippy binary) - #[clap(long_about = "\n + #[command(long_about = "\n Arguments: This subcommand accepts a number of paths to directories to the crates and/or artifacts to run clippy against. For example: @@ -273,14 +273,14 @@ pub enum Subcommand { forbid: Vec<String>, }, /// Run cargo fix - #[clap(long_about = "\n + #[command(long_about = "\n Arguments: This subcommand accepts a number of paths to directories to the crates and/or artifacts to run `cargo fix` against. For example: ./x.py fix library/core ./x.py fix library/core library/proc_macro")] Fix, - #[clap( + #[command( name = "fmt", long_about = "\n Arguments: @@ -295,7 +295,7 @@ pub enum Subcommand { #[arg(long)] check: bool, }, - #[clap(aliases = ["d"], long_about = "\n + #[command(aliases = ["d"], long_about = "\n Arguments: This subcommand accepts a number of paths to directories of documentation to build. For example: @@ -316,7 +316,7 @@ pub enum Subcommand { /// render the documentation in JSON format in addition to the usual HTML format json: bool, }, - #[clap(aliases = ["t"], long_about = "\n + #[command(aliases = ["t"], long_about = "\n Arguments: This subcommand accepts a number of paths to test directories that should be compiled and run. For example: @@ -400,7 +400,7 @@ pub enum Subcommand { Dist, /// Install distribution artifacts Install, - #[clap(aliases = ["r"], long_about = "\n + #[command(aliases = ["r"], long_about = "\n Arguments: This subcommand accepts a number of paths to tools to build and run. For example: @@ -413,7 +413,7 @@ pub enum Subcommand { args: Vec<String>, }, /// Set up the environment for development - #[clap(long_about = format!( + #[command(long_about = format!( "\n x.py setup creates a `config.toml` which changes the defaults for x.py itself, as well as setting up a git pre-push hook, VS Code config and toolchain link. @@ -434,7 +434,7 @@ Arguments: profile: Option<PathBuf>, }, /// Suggest a subset of tests to run, based on modified files - #[clap(long_about = "\n")] + #[command(long_about = "\n")] Suggest { /// run suggested tests #[arg(long)] diff --git a/src/doc/rustc/src/SUMMARY.md b/src/doc/rustc/src/SUMMARY.md index d4ca91977a6..90ac97f35f6 100644 --- a/src/doc/rustc/src/SUMMARY.md +++ b/src/doc/rustc/src/SUMMARY.md @@ -39,6 +39,7 @@ - [\*-unknown-fuchsia](platform-support/fuchsia.md) - [\*-kmc-solid_\*](platform-support/kmc-solid.md) - [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) - [loongarch\*-unknown-linux-\*](platform-support/loongarch-linux.md) - [loongarch\*-unknown-none\*](platform-support/loongarch-none.md) diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md index 984cb13f790..f1e3ad81b85 100644 --- a/src/doc/rustc/src/platform-support.md +++ b/src/doc/rustc/src/platform-support.md @@ -286,8 +286,8 @@ target | std | host | notes `bpfel-unknown-none` | * | | BPF (little endian) `csky-unknown-linux-gnuabiv2` | ✓ | | C-SKY abiv2 Linux (little endian) `csky-unknown-linux-gnuabiv2hf` | ✓ | | C-SKY abiv2 Linux, hardfloat (little endian) -[`hexagon-unknown-none-elf`](platform-support/hexagon-unknown-none-elf.md)| * | Bare Hexagon (v60+, HVX) -`hexagon-unknown-linux-musl` | ? | | +[`hexagon-unknown-none-elf`](platform-support/hexagon-unknown-none-elf.md)| * | | Bare Hexagon (v60+, HVX) +[`hexagon-unknown-linux-musl`](platform-support/hexagon-unknown-linux-musl.md) | ✓ | | Hexagon Linux `i386-apple-ios` | ✓ | | 32-bit x86 iOS [^x86_32-floats-return-ABI] [`i586-pc-nto-qnx700`](platform-support/nto-qnx.md) | * | | 32-bit x86 QNX Neutrino 7.0 RTOS [^x86_32-floats-return-ABI] [`i586-unknown-netbsd`](platform-support/netbsd.md) | ✓ | | 32-bit x86, restricted to Pentium diff --git a/src/doc/rustc/src/platform-support/hexagon-unknown-linux-musl.md b/src/doc/rustc/src/platform-support/hexagon-unknown-linux-musl.md new file mode 100644 index 00000000000..c1372726a35 --- /dev/null +++ b/src/doc/rustc/src/platform-support/hexagon-unknown-linux-musl.md @@ -0,0 +1,102 @@ +# `hexagon-unknown-linux-musl` + +**Tier: 3** + +Target for cross-compiling Linux user-mode applications targeting the Hexagon +DSP architecture. + +| Target | Descriptions | +| ------------------------ | ----------------------------------------- | +| hexagon-unknown-linux-musl | Hexagon 32-bit Linux | + +## Target maintainers + +- [Brian Cain](https://github.com/androm3da), `bcain@quicinc.com` + +## Requirements +The target is cross-compiled. This target supports `std`. By default, code +generated with this target should run on Hexagon DSP hardware. + +- `-Ctarget-cpu=hexagonv73` adds support for instructions defined up to Hexagon V73. + +Binaries can be run using QEMU user emulation. On Debian-based systems, it should be +sufficient to install the package `qemu-user-static` to be able to run simple static +binaries: + +```text +# apt install qemu-user-static +# qemu-hexagon-static ./hello +``` + +In order to build linux programs with Rust, you will require a linker capable +of targeting hexagon. You can use `clang`/`lld` from the [hexagon toolchain +using exclusively public open source repos](https://github.com/quic/toolchain_for_hexagon/releases). + +Also included in that toolchain is the C library that can be used when creating +dynamically linked executables. + +```text +# /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 +``` + +## Building the target +Because it is Tier 3, rust does not yet ship pre-compiled artifacts for this +target. + +Therefore, you can build Rust with support for the target by adding it to the +target list in `config.toml`, a sample configuration is shown below. + +```toml +[build] +target = [ "hexagon-unknown-linux-musl"] + +[target.hexagon-unknown-linux-musl] + +cc = "hexagon-unknown-linux-musl-clang" +cxx = "hexagon-unknown-linux-musl-clang++" +linker = "hexagon-unknown-linux-musl-clang" +ar = "hexagon-unknown-linux-musl-ar" +ranlib = "hexagon-unknown-linux-musl-ranlib" +musl-root = "/opt/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr" +llvm-libunwind = 'in-tree' +qemu-rootfs = "/opt/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/target/hexagon-unknown-linux-musl/usr" +``` + + +## Testing + +Currently there is no support to run the rustc test suite for this target. + + +## Building Rust programs + +Download and install the hexagon open source toolchain from https://github.com/quic/toolchain_for_hexagon/releases + +The following `.cargo/config` is needed inside any project directory to build +for the Hexagon Linux target: + +```toml +[build] +target = "hexagon-unknown-linux-musl" + +[target.hexagon-unknown-linux-musl] +linker = "hexagon-unknown-linux-musl-clang" +ar = "hexagon-unknown-linux-musl-ar" +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" +``` + +Edit the "runner" in `.cargo/config` to point to the path to your toolchain's +C library. + +```text +... +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" +... +``` + +Build/run your rust program with `qemu-hexagon` in your `PATH`: + +```text +export PATH=/path/to/my/inst/clang+llvm-18.1.0-cross-hexagon-unknown-linux-musl/x86_64-linux-gnu/bin/:$PATH +cargo run -Zbuild-std -Zbuild-std-features=llvm-libunwind +``` diff --git a/src/doc/rustc/src/platform-support/hexagon-unknown-none-elf.md b/src/doc/rustc/src/platform-support/hexagon-unknown-none-elf.md index 3ac1d2c2460..a0e26b798ac 100644 --- a/src/doc/rustc/src/platform-support/hexagon-unknown-none-elf.md +++ b/src/doc/rustc/src/platform-support/hexagon-unknown-none-elf.md @@ -41,6 +41,8 @@ target = ["<target for your host>", "hexagon-unknown-none-elf"] cc = "hexagon-unknown-none-elf-clang" cxx = "hexagon-unknown-none-elf-clang++" linker = "hexagon-unknown-none-elf-clang" +ranlib = "hexagon-unknown-none-elf-ranlib" +ar = "hexagon-unknown-none-elf-ar" llvm-libunwind = 'in-tree' ``` @@ -142,7 +144,7 @@ ${cc} --target=hexagon-unknown-none-elf -o testit \ ${g0_lib_path}/init.o \ -L${sdk_libs}/${q6_arch}/ \ -L${sdk_libs}/ \ - testit.c \ + wrap.c \ target/hexagon-unknown-none-elf/${build_cfg}/libdemo1_hexagon.rlib \ target/hexagon-unknown-none-elf/${build_cfg}/deps/libcore-*.rlib \ target/hexagon-unknown-none-elf/${build_cfg}/deps/libcompiler_builtins-*.rlib \ @@ -217,7 +219,18 @@ fn rust_eh_personality() {} ``` -Next, save the script below as `build.sh` and edit it to suit your +Next, create a C program as an entry point, save the content below as +`wrap.c`: + +```C +int hello(); + +int main() { + hello(); +} +``` + +Then, save the script below as `build.sh` and edit it to suit your environment. The script below will build a shared object against the QuRT RTOS which is suitable for emulation or on-device testing when loaded via the fastrpc-shell. @@ -248,7 +261,7 @@ ${cc} --target=hexagon-unknown-none-elf -o testit.so \ -Wl,--wrap=realloc \ -Wl,--wrap=memalign \ -m${q6_arch} \ - testit.c \ + wrap.c \ target/hexagon-unknown-none-elf/${build_cfg}/libdemo2_hexagon.rlib \ target/hexagon-unknown-none-elf/${build_cfg}/deps/libcore-*.rlib \ target/hexagon-unknown-none-elf/${build_cfg}/deps/libcompiler_builtins-*.rlib \ |
