konsoletyper / teavm

Compiles Java bytecode to JavaScript, WebAssembly and C
https://teavm.org
Apache License 2.0
2.55k stars 261 forks source link

unused import function #857

Closed wangshuli0315 closed 7 months ago

wangshuli0315 commented 7 months ago
  (import "teavm" "currentTimeMillis" (func $teavm.currentTimeMillis (type $t9)))
  (import "teavm" "logString" (func $teavm.logString (type $t1)))
  (import "teavm" "logInt" (func $teavm.logInt (type $t1)))
  (import "teavm" "logOutOfMemory" (func $teavm.logOutOfMemory (type $t4)))

As shown above, these import methods are not used in java applications and should be generated by Teavm by default. How can I configure not to generate these import methods?

konsoletyper commented 7 months ago

Are you sure these functions aren't used by application?

wangshuli0315 commented 7 months ago

Yes, the application I tested was written with an empty main method.

konsoletyper commented 7 months ago

This does not mean anything. TeaVM runtime uses it internally. Anyway, I don't see a reason why it's a problem

wangshuli0315 commented 7 months ago

The generated wasm module I compile needs to run on resource-constrained devices, so I need to make sure the generated wasm file is as small as possible. Is there any way to do this?

konsoletyper commented 7 months ago

The generates Wasm file is as small as possible in this context. You can't remove anything else.