[PATCH] D57909: [WebAssembly] Don't generate invalid modules when function signatures mismatch

Sam Clegg via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 7 15:06:05 PST 2019


sbc100 marked an inline comment as done.
sbc100 added inline comments.


================
Comment at: docs/WebAssembly.rst:98
 
+Function Signatrues
+~~~~~~~~~~~~~~~~~~~
----------------
ruiu wrote:
> Is this a new default behavior? I wonder what is the motivation of the change. I mean, finding an error at static-link-time is almost always better than finding it at run-time, no?
It complicated.

Before this change, we generate a warning and an invalid module.

I've tried in the past to make this a hard error because generating an invalid module seems like always the wrong thing to do.

When I do this lots of things break.  The most common failure is CMake checks for whether a function exists.  Cmake create a tiny C program with the named symbol and checks that it links.  But it doesn't know the signature so I always uses "char <func>()".   This is almost always wrong but the expectation is that linking should work.

In you actually tried to execute that at runtime you'd get undefined behaviour, but its not trying to run it.

So, the conclusion was to make this the default behaviour and allow the link to succeed, and have an option for a more strict mode.

We could invert the option... but that wouldn't save us any complexity and I quite the like the default to match the native linker behaviour.


Repository:
  rLLD LLVM Linker

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57909/new/

https://reviews.llvm.org/D57909





More information about the llvm-commits mailing list