<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - WASM backend generates invalid wasm for undeclared imports"
   href="https://bugs.llvm.org/show_bug.cgi?id=35385">35385</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>WASM backend generates invalid wasm for undeclared imports
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>libraries
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Linux
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Backend: WebAssembly
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>ncw@realvnc.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>llvm-bugs@lists.llvm.org
          </td>
        </tr></table>
      <p>
        <div>
        <pre>When the WASM backend generates a call to an incomplete function declaration,
it generates illegal WASM.

Testcase below:


#### test.c ####

// Succeeds, with (void) annotation
// Generates import with "(func)" type
extern void externSym1(void);
void exportSym1() { externSym1(); }

// Fails!
// Generates import with "(func (param i32))" type, but
// calls the imported function with the signature "void()".
extern void externSym2();
void exportSym2() { externSym2(); }


#### Commands ####
# $LLVM/clang --version
clang version 6.0.0 (trunk 318652)
Target: wasm32-unknown-unknown-wasm
Thread model: posix

# $LLVM/clang -Oz -c -o test.o test.c

# $WABT/wasm2wat test.o
0000000: error: type mismatch in call, expected [i32] but got []



The expected result (perhaps) is that the WASM backend refuses to generate
calls to functions with in incomplete declaration? But then how is linking to
varargs functions supposed to work? Hmm, I'm a bit confused really, but it
surely can't be right that the WASM output is invalid.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>