LLVM ERROR: Function addresses with offsets not supported #80318
Labels
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
O-wasm
Target: WASM (WebAssembly), http://webassembly.org/
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
I've ran into an issue with one of my libraries that was preventing it from compiling with
wasm-pack
. It would otherwise compile just fine withrustc
to other targets (no compiler errors) but when I would attempt to compile withwasm-pack
I would get this cryptic error:No line numbers, no error trace, just that.
After spending quite a while to find the offending block of code, I've discovered that the issue was caused by misusing the type system a bit.
Here's the offending code:
I expected to see this happen: I think this is actually a type error.
u16::max
is a function and I'm casting it to ausize
. I would hope the Rust compiler would yell at me for that or at least require me to writeunsafe
before I can cast a function to ausize
.Instead, this happened: The program compiles and runs just fine unless you attempt to compile it to wasm with
wasm-pack build
. If you run the function in a test, it spits out20
.rustc --version --verbose
:wasm-pack -V
:Hoping to save someone else a few days of hair pulling!
Edit: A little bit more testing, it looks like the program compiles just fine if you change the line to this:
So it seems like combining the cast with an operation causes the issue. Interestingly, not all operations cause the error.
The text was updated successfully, but these errors were encountered: