-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
LLVM ERROR: Function addresses with offsets not supported #80318
Copy link
Copy link
Open
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-bugCategory: This is a bug.Category: This is a bug.O-wasmTarget: WASM (WebAssembly), http://webassembly.org/Target: WASM (WebAssembly), http://webassembly.org/T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 withrustcto other targets (no compiler errors) but when I would attempt to compile withwasm-packI 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::maxis 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 writeunsafebefore 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.