Skip to content

LLVM miscompilation/assert in ui/issues/issue-23036.rs on wasm32-unknown-unknown target #93923

Closed
@the8472

Description

@the8472

Context: #93697 - the test had to be disabled there to get a fix in

With patched library/std/src/path.rs running the UI tests targeting wasm32 causes this failure with LLVM asserts enabled:

error: test compilation failed although it shouldn't!
status: signal: 6 (core dumped)
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/issues/issue-23036.rs" "-Zthreads=1" "--target=wasm32-unknown-unknown" "--error-format" "json" "--json" "future-incompat" "-Ccodegen-units=1" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-23036/a.wasm" "-Crpath" "-O" "-Cdebuginfo=0" "-Lnative=/checkout/obj/build/wasm32-unknown-unknown/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/issues/issue-23036/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
rustc: /checkout/src/llvm-project/llvm/lib/MC/WasmObjectWriter.cpp:149: void {anonymous}::writePatchableLEB(llvm::raw_pwrite_stream&, uint64_t, uint64_t) [with int W = 5; uint64_t = long unsigned int]: Assertion `SizeLen == W' failed.
------------------------------------------

With LLVM asserts disabled it produces invalid wasm bytecode:

/home/the8472/workspace/rust/src/etc/wasm32-shim.js:17
let m = new WebAssembly.Module(buffer);
        ^

CompileError: WebAssembly.Module(): Compiling function #3:"_ZN11issue_230364main17hf6fa4aae1344ccadE" failed: Invalid opcode 0xff @+874
    at Object.<anonymous> (/home/the8472/workspace/rust/src/etc/wasm32-shim.js:17:9)
    at Module._compile (node:internal/modules/cjs/loader:1097:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47

Manually executing the rustc command printed by the UI test and adding --emit=llvm-ir generates the following IR repro.ir.txt. Running that through llc (built by bootstrap) also produces invalid bytecode (checked with wasm-dis).

Tested on base commit 686663a + PR #93697 (currently 45082b0)

@rustbot ping llvm

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.I-crashIssue: The compiler crashes (SIGSEGV, SIGABRT, etc). Use I-ICE instead when the compiler panics.ICEBreaker-LLVMBugs identified for the LLVM ICE-breaker groupO-wasmTarget: WASM (WebAssembly), http://webassembly.org/

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions