This is a side effect caused by asm2wasm - in asm.js we do need to import NaN. But you're right it's unnecessary in wasm.
Once we switch away from asm2wasm to the LLVM wasm backend by default, this problem will go away. It's odd btw that you see an import that is never used not being optimized out - I only see NaN remain when it is actually used. So you might be seeing a bug in the binaryen optimizer - if you can share a testcase I can take a look at that. On Fri, Apr 26, 2019 at 12:29 PM stephen.weber via emscripten-discuss < [email protected]> wrote: > When compiling some code with emcc I get these imports in the result: > > (import "global" "NaN" (global $gimport$16 f64)) > (import "global" "Infinity" (global $gimport$17 f64)) > > Why are these needed? Could the values for these constants not exist > internal to the WASM? > > Also, I searched the disassembly for NaN and it is only here in the import > -- even when I use -O3 -- so maybe unused import removal is missing it for > some reason? > > Thanks. > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
