[llvm-bugs] [Bug 40470] New: CMake config checks lead to invalid output wasm

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 25 14:29:26 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=40470

            Bug ID: 40470
           Summary: CMake config checks lead to invalid output wasm
           Product: lld
           Version: unspecified
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedbugs at nondot.org
          Reporter: alonzakai at gmail.com
                CC: llvm-bugs at lists.llvm.org, peter.smith at linaro.org

Testcase:
===
#ifdef CHECK_FUNCTION_EXISTS

#ifdef __cplusplus
extern "C"
#endif
  char
  CHECK_FUNCTION_EXISTS(void);
#ifdef __CLASSIC_C__
int main()
{
  int ac;
  char* av[];
#else
int main(int ac, char* av[])
{
#endif
  CHECK_FUNCTION_EXISTS();
  if (ac > 1000) {
    return *av[0];
  }
  return 0;
}

#else /* CHECK_FUNCTION_EXISTS */

#error "CHECK_FUNCTION_EXISTS has to specify the function"

#endif /* CHECK_FUNCTION_EXISTS */
===

Build with

emcc a.c -DCHECK_FUNCTION_EXISTS=strtod

Output is
===
redeclaration of library function 'strtod'
[-Wincompatible-library-redeclaration]
  CHECK_FUNCTION_EXISTS(void);
  ^
<command line>:9:31: note: expanded from here
#define CHECK_FUNCTION_EXISTS strtod
                              ^
a.c:7:3: note: 'strtod' is a builtin with type 'double (const char *, char **)'
<command line>:9:31: note: expanded from here
#define CHECK_FUNCTION_EXISTS strtod
                              ^
1 warning generated.
Ddef __stack_pointer
wasm-ld: warning: function signature mismatch: strtod
>>> defined as () -> i32 in /tmp/emscripten_temp_OvrAvc/a_0.o
>>> defined as (i32, i32) -> f64 in /home/azakai/.emscripten_cache/wasm_o/libc.a(strtod_94cb6386.c.o)
===

It complains correctly about the invalid signature. However, the wasm-ld stage
emitted a wasm, which is invalid. wabt errors with

/tmp/emscripten_temp/a.out.wasm:00001f9: error: type mismatch in call, expected
[i32, i32] but got []

and as emcc continues on to run wasm-emscripten-finalize that fails with

[parse exception: attempted pop from empty stack / beyond block start boundary
at 505 (at 0:505)]

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20190125/6e35078b/attachment.html>


More information about the llvm-bugs mailing list