Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #113782

Merged
merged 11 commits into from
Jul 17, 2023
Merged

Rollup of 4 pull requests #113782

merged 11 commits into from
Jul 17, 2023

Commits on Jun 17, 2023

  1. Configuration menu
    Copy the full SHA
    d456d11 View commit details
    Browse the repository at this point in the history

Commits on Jul 11, 2023

  1. Add a sparc-unknown-none-elf target.

    Tested with the Gaisler bcc2 toolchain (both gcc and clang) and the Leon3 simulator.
    jonathanpallant committed Jul 11, 2023
    Configuration menu
    Copy the full SHA
    d30294e View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    4bccf83 View commit details
    Browse the repository at this point in the history

Commits on Jul 16, 2023

  1. self type param infer, avoid ICE

    lcnr committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    19d46b6 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    e449daa View commit details
    Browse the repository at this point in the history
  3. Generate safe stable code for derives on empty enums

    Generate `match *self {}` instead of `unsafe { core::intrinsics::unreachable() }`.
    
    This is:
    
        1. safe
        2. stable
    
    for the benefit of everyone looking at these derived impls through `cargo expand`.
    
    Both expansions compile to the same code at all optimization levels (including `0`).
    dtolnay committed Jul 16, 2023
    Configuration menu
    Copy the full SHA
    f441adc View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    56633b3 View commit details
    Browse the repository at this point in the history

Commits on Jul 17, 2023

  1. Rollup merge of rust-lang#112741 - geometryolife:fix, r=workingjubilee

    fix typo in `rustdoc/src/what-is-rustdoc.md`
    matthiaskrgr authored Jul 17, 2023
    Configuration menu
    Copy the full SHA
    cfeeab5 View commit details
    Browse the repository at this point in the history
  2. Rollup merge of rust-lang#113535 - jonathanpallant:sparc-bare-metal, …

    …r=jackh726
    
    Add a sparc-unknown-none-elf target.
    
    # `sparc-unknown-none-elf`
    
    **Tier: 3**
    
    Rust for bare-metal 32-bit SPARC V7 and V8 systems, e.g. the Gaisler LEON3.
    
    ## Target maintainers
    
    - Jonathan Pallant, `[email protected]`, https://ferrous-systems.com
    
    ## Requirements
    
    > Does the target support host tools, or only cross-compilation?
    
    Only cross-compilation.
    
    > Does the target support std, or alloc (either with a default allocator, or if the user supplies an allocator)?
    
    Only tested with `libcore` but I see no reason why you couldn't also support `liballoc`.
    
    > Document the expectations of binaries built for the target. Do they assume
    specific minimum features beyond the baseline of the CPU/environment/etc? What
    version of the OS or environment do they expect?
    
    Tested by linking with a standard SPARC bare-metal toolchain - specifically I used the [BCC2] toolchain from Gaisler (both GCC and clang variants, both pre-compiled for x64 Linux and compiling my own SPARC GCC from source to run on `aarch64-apple-darwin`).
    
    The target is set to use the lowest-common-denominator `SPARC V7` architecture (yes, they started at V7 - see [Wikipedia](https://en.wikipedia.org/wiki/SPARC#History)).
    
    [BCC2]: https://www.gaisler.com/index.php/downloads/compilers
    
    > Are there notable `#[target_feature(...)]` or `-C target-feature=` values that
    programs may wish to use?
    
    `-Ctarget-cpu=v8` adds the instructions added in V8.
    
    `-Ctarget-cpu=leon3` adds the V8 instructions and sets up scheduling to suit the Gaisler LEON3.
    
    > What calling convention does `extern "C"` use on the target?
    
    I believe this is defined by the SPARC architecture reference manuals and V7, V8 and V9 are all compatible.
    
    > What format do binaries use by default? ELF, PE, something else?
    
    ELF
    
    ## Building the target
    
    > If Rust doesn't build the target by default, how can users build it? Can users
    just add it to the `target` list in `config.toml`?
    
    Yes. I did:
    
    ```toml
    target = ["aarch64-apple-darwin", "sparc-unknown-none-elf"]
    ```
    
    ## 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.
    
    Correct.
    
    ## Testing
    
    > Does the target support running binaries, or do binaries have varying
    expectations that prevent having a standard way to run them?
    
    No - it's a bare metal platform.
    
    > If users can run binaries, can they do so in some common emulator, or do they need native
    hardware?
    
    But if you use [BCC2] as the linker, you get default memory map suitable for the LEON3, and a default BSP for the LEON3, and so you can run the binaries in the `tsim-leon3` simulator from Gaisler.
    
    ```console
    $ cat .cargo/config.toml | grep runner
    runner = "tsim-leon3 -c sim-commands.txt"
    $ cat sim-commands.txt
    run
    quit
    $ cargo +sparcrust run --targe=sparc-unknown-none-elf
       Compiling sparc-demo-rust v0.1.0 (/work/sparc-demo-rust)
        Finished dev [unoptimized + debuginfo] target(s) in 3.44s
         Running `tsim-leon3 -c sim-commands.txt target/sparc-unknown-none-elf/debug/sparc-demo-rust`
    
     TSIM3 LEON3 SPARC simulator, version 3.1.9 (evaluation version)
    
     Copyright (C) 2023, Frontgrade Gaisler - all rights reserved.
     This software may only be used with a valid license.
     For latest updates, go to https://www.gaisler.com/
     Comments or bug-reports to [email protected]
    
     This TSIM evaluation version will expire 2023-11-28
    
    Number of CPUs: 2
    system frequency: 50.000 MHz
    icache: 1 * 4 KiB, 16 bytes/line (4 KiB total)
    dcache: 1 * 4 KiB, 16 bytes/line (4 KiB total)
    Allocated 8192 KiB SRAM memory, in 1 bank at 0x40000000
    Allocated 32 MiB SDRAM memory, in 1 bank at 0x60000000
    Allocated 8192 KiB ROM memory at 0x00000000
    section: .text, addr: 0x40000000, size: 104400 bytes
    section: .rodata, addr: 0x400197d0, size: 15616 bytes
    section: .data, addr: 0x4001d4d0, size: 1176 bytes
    read 1006 symbols
    
      Initializing and starting from 0x40000000
    Hello, this is Rust!
    PANIC: PanicInfo { payload: Any { .. }, message: Some(I am a panic), location: Location { file: "src/main.rs", line: 33, col: 5 }, can_unwind: true }
    
      Program exited normally on CPU 0.
    ```
    
    > Does the target support running the Rust testsuite?
    
    I don't think so, the testsuite requires `libstd` IIRC.
    
    ## Cross-compilation toolchains and C code
    
    > Does the target support C code?
    
    Yes.
    
    > If so, what toolchain target should users use to build compatible C code? (This may match the target triple, or it may be a toolchain for a different target triple, potentially with specific options or caveats.)
    
    I suggest [BCC2] from Gaisler. It comes in both GCC and Clang variants.
    matthiaskrgr authored Jul 17, 2023
    Configuration menu
    Copy the full SHA
    e31ebae View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    eca9c01 View commit details
    Browse the repository at this point in the history
  4. Rollup merge of rust-lang#113770 - dtolnay:derivevoid, r=compiler-err…

    …ors,nnethercote
    
    Generate safe stable code for derives on empty enums
    
    Generate `match *self {}` instead of `unsafe { core::intrinsics::unreachable() }`.
    
    This is:
    
    1. safe
    2. stable
    
    for the benefit of everyone looking at these derived impls through `cargo expand`.
    
    [Both expansions compile to the same code at all optimization levels (including `0`).](https://rust.godbolt.org/z/P79joGMh3)
    matthiaskrgr authored Jul 17, 2023
    Configuration menu
    Copy the full SHA
    93b9812 View commit details
    Browse the repository at this point in the history