Skip to content

core::mem::swap used to work, then broke (and later accidentally got unbroken again). #804

Open
@hatoo

Description

@hatoo

Expected Behaviour

Codes that uses core::mem::swap

#![cfg_attr(
    target_arch = "spirv",
    no_std,
    feature(register_attr),
    register_attr(spirv)
)]

#[cfg(not(target_arch = "spirv"))]
use spirv_std::macros::spirv;

use spirv_std as _;

#[spirv(vertex)]
pub fn test_vs() {
    let mut x1 = 0.0f32;
    let mut x2 = 1.0f32;

    core::mem::swap(&mut x1, &mut x2);
}

will compile. it's OK in previous version at least b9867d0.

Example & Steps To Reproduce

  1. Clone https://github.com/hatoo/rust-gpu-issue/tree/swap-fail (note: swap-fail branch)
  2. cargo build and error
> cargo build
   Compiling builder v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\builder)
error: failed to run custom build command for `builder v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\builder)`

Caused by:
  process didn't exit successfully: `C:\Users\hato2\Desktop\rust-gpu-issue\target\debug\build\builder-caf084bc583adeed\build-script-build` (exit code: 1)
  --- stderr
     Compiling shader v0.1.0 (C:\Users\hato2\Desktop\rust-gpu-issue\shader)
  error: Cannot memcpy dynamically sized data
      --> C:\Users\hato2\.rustup\toolchains\nightly-2021-10-26-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\core\src\intrinsics.rs:2057:14
       |
  2057 |     unsafe { copy_nonoverlapping(src, dst, count) }
       |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  error: could not compile `shader` due to previous error
  Error: BuildFailed

It's OK in the previous version. Please see https://github.com/hatoo/rust-gpu-issue/tree/swap-succ.

System Info

  • Rust: rustc 1.58.0-nightly (29b124802 2021-10-25)
  • OS: Windows 11
  • GPU: RTX2080ti
  • SPIR-V: SPIRV-Tools v2021.3 v2021.3

Backtrace

Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: rust-langIssues specific to rust-lang/rust.s: qptr may fixThis might be fixed by the "qptr" experiment (https://github.com/EmbarkStudios/spirt/pull/24)t: bugSomething isn't workingt: externalIssues not about rust-gpu itself, but related enough to be tracked.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions