cesanta / v7

Embedded JavaScript engine for C/C++
Other
1.43k stars 177 forks source link

Compilation under Arduino ESP8266? #550

Open benjamind opened 8 years ago

benjamind commented 8 years ago

Trying to build this in the Arduino IDE, and with Platform.io, for an ESP8266.

I brought the two v7 files in, set CS_PLATFORM to CS_P_ESP_LWIP and CS_BUILD_PROFILE to minimal. But I get an undefined reference to 'ctype_ptr' error.

Seems we're missing a bunch of stdio functions, fprintf, and setjmp as well. Any ideas how to go about fixing this?

xtensa-lx106-elf-ar rcs .pioenvs\huzzah\libv7.a .pioenvs\huzzah\v7\v7.o
xtensa-lx106-elf-ranlib .pioenvs\huzzah\libv7.a
xtensa-lx106-elf-g++ -o .pioenvs\huzzah\firmware.elf -Os -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static -Wl,--gc-sections -Wl,-wrap,system_restart_local -Wl,-wrap,register_chipv6_phy -Wl,-T"esp8266.flash.4m1m.ld" .pioenvs\huzzah\src\WifiManager.o .pioenvs\huzzah\src\tmp_ino_to.o -LC:\Users\Ben\.platformio\packages\framework-arduinoespressif\tools\sdk\lib -LC:\Users\Ben\.platformio\packages\ldscripts -L.pioenvs\huzzah -Wl,--start-group .pioenvs\huzzah\libFrameworkArduinoVariant.a .pioenvs\huzzah\libFrameworkArduino.a -lmesh -lwpa2 -lsmartconfig -lpp -lmain -lwpa -llwip -lnet80211 -lwps -lcrypto -lphy -lhal -laxtls -lgcc -lm .pioenvs\huzzah\libESP8266WiFi.a .pioenvs\huzzah\libESP8266mDNS.a .pioenvs\huzzah\libArduinoOTA.a .pioenvs\huzzah\libDNSServer.a .pioenvs\huzzah\libFastLED.a .pioenvs\huzzah\libSoftwareSerial.a .pioenvs\huzzah\libESP8266WebServer.a .pioenvs\huzzah\libHash.a .pioenvs\huzzah\libEthernet.a .pioenvs\huzzah\libSPI.a .pioenvs\huzzah\libarduinoWebSockets.a .pioenvs\huzzah\libArduinoJson.a .pioenvs\huzzah\libTicker.a .pioenvs\huzzah\libv7.a -Wl,--end-group
.pioenvs\huzzah\libv7.a(v7.o):(.text.skip_to_next_tok+0x0): undefined reference to `__ctype_ptr__'
.pioenvs\huzzah\libv7.a(v7.o):(.text.gc_check_valid_allocation_seqn+0x0): undefined reference to `_impure_ptr'
.pioenvs\huzzah\libv7.a(v7.o):(.text.gc_check_valid_allocation_seqn+0xc): undefined reference to `fprintf'
.pioenvs\huzzah\libv7.a(v7.o): In function `gc_check_valid_allocation_seqn':
v7.c:(.text.gc_check_valid_allocation_seqn+0x47): undefined reference to `fprintf'
v7.c:(.text.gc_check_valid_allocation_seqn+0x56): undefined reference to `fprintf'
.pioenvs\huzzah\libv7.a(v7.o):(.text.re_rng2set+0x0): undefined reference to `longjmp'
.pioenvs\huzzah\libv7.a(v7.o): In function `re_rng2set':
v7.c:(.text.re_rng2set+0x2e): undefined reference to `longjmp'
.pioenvs\huzzah\libv7.a(v7.o): In function `re_nchset':
v7.c:(.text.re_nchset+0x14): undefined reference to `longjmp'
.pioenvs\huzzah\libv7.a(v7.o): In function `re_nrep':
v7.c:(.text.re_nrep+0x3b): undefined reference to `longjmp'
.pioenvs\huzzah\libv7.a(v7.o): In function `gc_dump_arena_stats':
v7.c:(.text.gc_dump_arena_stats+0x2f): undefined reference to `fprintf'
.pioenvs\huzzah\libv7.a(v7.o): In function `re_lexer':
v7.c:(.text.re_lexer+0x1cb): undefined reference to `longjmp'
.pioenvs\huzzah\libv7.a(v7.o): In function `re_parse_la':
v7.c:(.text.re_parse_la+0x183): undefined reference to `longjmp'
.pioenvs\huzzah\libv7.a(v7.o):(.text.slre_compile+0x4): undefined reference to `setjmp'
.pioenvs\huzzah\libv7.a(v7.o): In function `slre_compile':
v7.c:(.text.slre_compile+0x56): undefined reference to `setjmp'
v7.c:(.text.slre_compile+0x114): undefined reference to `longjmp'
.pioenvs\huzzah\libv7.a(v7.o): In function `b_exec':
v7.c:(.text.b_exec+0x463): undefined reference to `fprintf'
v7.c:(.text.b_exec+0x512): undefined reference to `fprintf'
.pioenvs\huzzah\libv7.a(v7.o): In function `v7_throwf':
v7.c:(.text.v7_throwf+0xaa): undefined reference to `fprintf'
v7.c:(.text.v7_throwf+0x123): undefined reference to `fprintf'
.pioenvs\huzzah\libv7.a(v7.o):(.text.parse$constprop$79+0x30): undefined reference to `fputs'
.pioenvs\huzzah\libv7.a(v7.o): In function `parse$constprop$79':
v7.c:(.text.parse$constprop$79+0x12a): undefined reference to `fputs'
v7.c:(.text.parse$constprop$79+0x13e): undefined reference to `fprintf'
.pioenvs\huzzah\src\tmp_ino_to.o:(.text._ZL15js_fill_rainbowP2v7Py+0x0): undefined reference to `v7_arg(v7*, unsigned long)'
.pioenvs\huzzah\src\tmp_ino_to.o:(.text._ZL15js_fill_rainbowP2v7Py+0x14): undefined reference to `v7_arg(v7*, unsigned long)'
.pioenvs\huzzah\src\tmp_ino_to.o: In function `js_fill_rainbow(v7*, unsigned long long*)':
tmp_ino_to.cpp:(.text._ZL15js_fill_rainbowP2v7Py+0x21): undefined reference to `v7_arg(v7*, unsigned long)'
.pioenvs\huzzah\src\tmp_ino_to.o:(.text._Z15startJavascriptv+0x14): undefined reference to `v7_create()'
.pioenvs\huzzah\src\tmp_ino_to.o:(.text._Z15startJavascriptv+0x18): undefined reference to `v7_get_global(v7*)'
.pioenvs\huzzah\src\tmp_ino_to.o:(.text._Z15startJavascriptv+0x1c): undefined reference to `v7_exec(v7*, char const*, unsigned long long*)'
.pioenvs\huzzah\src\tmp_ino_to.o:(.text._Z15startJavascriptv+0x20): undefined reference to `v7_destroy(v7*)'
.pioenvs\huzzah\src\tmp_ino_to.o:(.text._Z15startJavascriptv+0x2f): undefined reference to `v7_create()'
.pioenvs\huzzah\src\tmp_ino_to.o: In function `startJavascript()':
tmp_ino_to.cpp:(.text._Z15startJavascriptv+0x3c): undefined reference to `v7_get_global(v7*)'
tmp_ino_to.cpp:(.text._Z15startJavascriptv+0x5a): undefined reference to `v7_exec(v7*, char const*, unsigned long long*)'
tmp_ino_to.cpp:(.text._Z15startJavascriptv+0x7a): undefined reference to `v7_destroy(v7*)'
collect2.exe: error: ld returned 1 exit status
scons: *** [.pioenvs\huzzah\firmware.elf] Error 1
cpq commented 8 years ago

@dimonomid could you address it please?

benjamind commented 8 years ago

I've found that I can compile this using the feature/libc branch of Arduino ESP8266, after adding the putc.a symbols back into the libcmin build. Compilation and linking now work with CS_DISABLE_STDIO and V7_BUILD_PROFILE 1, however I get a crash on v7_create().

benjamind commented 8 years ago

So the stack trace gives me this:

0x40100711: calloc at E:\Users\Ben\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1682
0x4020135c: gc_new_block at E:\Temp\build93b5748ed8fde4d231b4b4b5930427cd.tmp\sketch/v7.c line 13957
0x4020f232: gc_arena_init at E:\Temp\build93b5748ed8fde4d231b4b4b5930427cd.tmp\sketch/v7.c line 13957
:  (inlined by) v7_create_opt at E:\Temp\build93b5748ed8fde4d231b4b4b5930427cd.tmp\sketch/v7.c line 14075
0x401006e4: malloc at E:\Users\Ben\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266\umm_malloc/umm_malloc.c line 1662
0x402143f1: Print::write(char const*) at E:\Users\Ben\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/Print.cpp line 188
0x4020fa4c: v7_create at E:\Temp\build93b5748ed8fde4d231b4b4b5930427cd.tmp\sketch/v7.c line 13957
0x40213d41: setup at E:\Workspace\ArduinoV7/ArduinoV7.ino line 38
0x40214894: loop_wrapper at E:\Users\Ben\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/core_esp8266_main.cpp line 43
0x40100964: cont_norm at E:\Users\Ben\Documents\Arduino\hardware\esp8266com\esp8266\cores\esp8266/cont.S line 109

Looks like an issue in calloc, not sure how to proceed from here. Anyone else had any luck compiling under ESP8266 Arduino?

sfranzyshen commented 6 years ago

Manually add the esp8266 arduino board support (follow the instructions here: https://github.com/esp8266/Arduino#using-git-version) instead of using the board manager from the arduino ide ...