Problems compiling lv_micropython javascript simulator

I am trying to compile lvgl_javascript branch of lv_micropython and I have compilation problems. Maybe you can help me to get it working.

The problems I encountered during building process are the following:

1. Compiler complains about redefinition of macros in clang_predefs.h (alredy defined in built-in).

// many many more...
build/clang_predefs.h:315:9: error: '__VERSION__' macro redefined
      [-Werror,-Wmacro-redefined]
#define __VERSION__ "4.2.1 Compatible Clang 6.0.1 (/b/s/w/ir/cache/git/c...
        ^
<built-in>:23:9: note: previous definition is here
#define __VERSION__ "4.2.1 Compatible Apple LLVM 10.0.1 (clang-1001.0.46.4)"

I removed -Wall -Werror flags to go through.

2. main.c doesn’t compiler because of missing setjmp and related stuff.

main.c:228:5: error: use of undeclared identifier 'jmp_buf'
    jmp_buf dummy;
    ^
main.c:229:9: warning: implicit declaration of function 'setjmp' is invalid in
      C99 [-Wimplicit-function-declaration]
    if (setjmp(dummy) == 0) {
        ^
main.c:229:9: warning: declaration of built-in function 'setjmp' requires
      inclusion of the header <setjmp.h> [-Wbuiltin-requires-header]

Adding #include <setjmp.h> to the main.c file helps.

3. wasm_file_api.c uses EM_ASM_INT and other emscripten-specific things

wasm_file_api.c:16:20: warning: implicit declaration of function 'EM_ASM_INT' is
      invalid in C99 [-Wimplicit-function-declaration]
        int fidx = EM_ASM_INT({return wasm_file_open(UTF8ToString($0)); ...
                   ^

I don’t quite understand emscripten ecosystem, so I decided to remove this file from the Makefile and try to build without filesystem support for now.

4. finally everything got compiled but linking failed

I got a huge list of warnings like

# warnings for all object files
emcc:WARNING: build/lib/timeutils/timeutils.o is not a valid input file

And finaly a linker error:

shared:ERROR: no input files
note that input files without a known suffix are ignored, make sure 
your input files end with one of: ('.c', '.C', '.i', '.cpp', '.cxx', '.cc', '.c++', 
'.CPP', '.CXX', '.CC', '.C++', '.ii', '.m', '.mi', '.mm', '.mii', '/dev/null', '.bc',
 '.o', '.obj', '.lo', '.dylib', '.so', '.a', '.ll', '.h', '.hxx', '.hpp', '.hh', '.H',
 '.HXX', '.HPP', '.HH')`

At this point I am stuck and have no idea how to proceed. Maybe I need some specific version of emsdk? If so which one?

Original micropython builds succesfully:

I was able to get micropython master branch fully working with ./emsdk activate latest-fastcomp.

./emsdk activate latest didn’t work so I switched to legacy emsdk.

Guys, I need help :frowning:

@embeddedt - can you help?
@pmp-p might have some idea too.

recently that command ./emsdk activate latest switched default clang 8 customized “fastcomp” compiler to “clang 10 upstream”, i’m not sure the - official - micropython javascript port can handle upstream yet. ./emsdk activate latest-fastcomp is indeed the best move you could do.
fastcomp produces slower wasm code (roughly 2X slower) but does it matter ?

I am fine with using latest-fastcomp, but the problem is that I can’t build lv_micropython with it.

I am stuck at the linking stage (p. 4 in the post above).
Also compiling wasm_file_api.c doesn’t work for some reason (p.3) so I had to remove it.

You should compile it with an older version of Emscripten (if memory serves me correctly 1.38.30 or something similar should work fine).

They’ve made a lot of updates to the toolchain since then and I don’t think upstream MicroPython has been changed to reflect that.

1 Like

my port readme says last ok was 1.38.31-fastcomp ( official and lv_micropython ).
later could work but i switched to no_nlr + upstream clang and away from javascript port at that point so i don’t know.

2 Likes

Thanks, on 1.38.31 it worked! I was able to compile the simulator. Finally!!!