Does JSDB run on ARM architecture (RasberryPi board)? Compilation from source fails :(

82 views
Skip to first unread message

remi...@gmail.com

unread,
Jan 4, 2013, 9:53:09 AM1/4/13
to js...@googlegroups.com, Baltix Linux
Hi JSDB developers,

I'm trying to compile JSDB on ARM architecture (RasberryPi board), but it seems JSDB 1.8.0.7 still depends on i386 architecture - js/src/nanojit/Nativei386.cpp (and Nativei386.h) is included several times in makejsdb.csh, while NativeARM.cpp exists too in js/src/nanojit/ folder:

dell@Ubuntu-Baltix-2012:~/Atsiuntimai/jsdb-deb/jsdb_source_1.8.0.7$ grep 386 *
jsdb.project:        <file platform=win32,linux,osx>nanojit/Nativei386.cpp</file>
makejsdb.csh:g++  -c -fexceptions -I . -idirafter js/src/  -idirafter js/  -D FEATURE_NANOJIT  -D JS_TRACER  -D JS_HAVE_STDINT_H  -D NO_NOTES_MAIL  -D NO_CMC_MAIL  -D NO_DBF_ENCRYPTION  -D XP_UNIX  -D HAVE_TERMIO  -D AVMPLUS_IA32=1  -D AVMPLUS_LINUX=1  -Wno-invalid-offsetof -oobj/nanojit_Nativei386.o js/src/nanojit/Nativei386.cpp; echo js/src/nanojit/Nativei386.cpp;
makejsdb.csh:g++   -s  -o jsdb obj/jsdb.o obj/wrap_sqlite.o obj/wrap_process.o obj/wrap_com.o obj/wrap_debug.o obj/wrap_env.o obj/wrap_nums.o obj/wrap_image.o obj/wrap_index.o obj/wrap_mail.o obj/wrap_odbc.o obj/wrap_record.o obj/wrap_server.o obj/wrap_shell.o obj/wrap_system.o obj/wrap_stream.o obj/wrap_table.o obj/wrap_zip.o obj/dbf_cache.o obj/dbf_dat.o obj/dbf_file.o obj/dbf_head.o obj/dbf_io.o obj/dbf_open.o obj/dbf_rec.o obj/gif_font.o obj/gif_main.o obj/io_b64.o obj/io_comm.o obj/io_compress.o obj/io_expand.o obj/io_file.o obj/io_inet.o obj/io_list.o obj/io_memory.o obj/io_fifo.o obj/io_open.o obj/io_pipe.o obj/io_print.o obj/io_stream.o obj/io_xml.o obj/io_zip.o obj/ml_list.o obj/ml_mapi.o obj/ml_mapi2.o obj/ml_mime.o obj/ml_notes.o obj/ml_open.o obj/ml_pop.o obj/ml_vim.o obj/sy_alloc.o obj/sy_char.o obj/sy_crc.o obj/sy_except.o obj/sy_file.o obj/sy_form.o obj/sy_int32.o obj/sy_list.o obj/sy_mswin.o obj/sy_param.o obj/sy_sort.o obj/sy_sql.o obj/sy_string.o obj/sy_strlist.o obj/sy_time.o obj/sy_url.o obj/sy_worm.o obj/tbl_asci.o obj/tbl_cache.o obj/tbl_data.o obj/tbl_dbf.o obj/tbl_index.o obj/tbl_main.o obj/tbl_sql.o obj/adler32.o obj/trees.o obj/zutil.o obj/deflate.o obj/infblock.o obj/infcodes.o obj/inffast.o obj/inflate.o obj/inftrees.o obj/infutil.o obj/jsapi.o obj/jsarena.o obj/jsbuiltins.o obj/jsarray.o obj/jsatom.o obj/jsbool.o obj/jscntxt.o obj/jsdate.o obj/jsdbgapi.o obj/jsdhash.o obj/jsdtoa.o obj/jsemit.o obj/jsexn.o obj/jsfun.o obj/jstracer.o obj/jsgc.o obj/jshash.o obj/jsinterp.o obj/jsinvoke.o obj/jsiter.o obj/jslock.o obj/jslog2.o obj/jsmath.o obj/jsnum.o obj/jsobj.o obj/json.o obj/jsopcode.o obj/jsparse.o obj/jsprf.o obj/jsregexp.o obj/jsscan.o obj/jsscope.o obj/jsscript.o obj/jsstr.o obj/jsutil.o obj/jsxdrapi.o obj/jsxml.o obj/prmjtime.o obj/nanojit_Assembler.o obj/nanojit_avmplus.o obj/nanojit_Fragmento.o obj/nanojit_LIR.o obj/nanojit_CodeAlloc.o obj/nanojit_Containers.o obj/nanojit_Allocator.o obj/nanojit_Nativei386.o obj/nanojit_RegAlloc.o obj/editline.o obj/sysunix.o obj/sqlite3.o  -lm  -lodbc  -lpthread  
makejsdbnosql.csh:g++  -c -fexceptions -I . -idirafter js/src/  -idirafter js/  -D FEATURE_NANOJIT  -D JS_TRACER  -D JS_HAVE_STDINT_H  -D NO_NOTES_MAIL  -D NO_CMC_MAIL  -D NO_DBF_ENCRYPTION  -D XP_UNIX  -D HAVE_TERMIO  -D TBL_NO_SQL  -D AVMPLUS_IA32=1  -D AVMPLUS_LINUX=1  -Wno-invalid-offsetof -oobj/nanojit_Nativei386.o js/src/nanojit/Nativei386.cpp; echo js/src/nanojit/Nativei386.cpp;
makejsdbnosql.csh:g++   -s  -o jsdb obj/jsdb.o obj/wrap_sqlite.o obj/wrap_process.o obj/wrap_com.o obj/wrap_debug.o obj/wrap_env.o obj/wrap_nums.o obj/wrap_image.o obj/wrap_index.o obj/wrap_mail.o obj/wrap_odbc.o obj/wrap_record.o obj/wrap_server.o obj/wrap_shell.o obj/wrap_system.o obj/wrap_stream.o obj/wrap_table.o obj/wrap_zip.o obj/dbf_cache.o obj/dbf_dat.o obj/dbf_file.o obj/dbf_head.o obj/dbf_io.o obj/dbf_open.o obj/dbf_rec.o obj/gif_font.o obj/gif_main.o obj/io_b64.o obj/io_comm.o obj/io_compress.o obj/io_expand.o obj/io_file.o obj/io_inet.o obj/io_list.o obj/io_memory.o obj/io_fifo.o obj/io_open.o obj/io_pipe.o obj/io_print.o obj/io_stream.o obj/io_xml.o obj/io_zip.o obj/ml_list.o obj/ml_mapi.o obj/ml_mapi2.o obj/ml_mime.o obj/ml_notes.o obj/ml_open.o obj/ml_pop.o obj/ml_vim.o obj/sy_alloc.o obj/sy_char.o obj/sy_crc.o obj/sy_except.o obj/sy_file.o obj/sy_form.o obj/sy_int32.o obj/sy_list.o obj/sy_mswin.o obj/sy_param.o obj/sy_sort.o obj/sy_sql.o obj/sy_string.o obj/sy_strlist.o obj/sy_time.o obj/sy_url.o obj/sy_worm.o obj/tbl_asci.o obj/tbl_cache.o obj/tbl_data.o obj/tbl_dbf.o obj/tbl_index.o obj/tbl_main.o obj/tbl_sql.o obj/adler32.o obj/trees.o obj/zutil.o obj/deflate.o obj/infblock.o obj/infcodes.o obj/inffast.o obj/inflate.o obj/inftrees.o obj/infutil.o obj/jsapi.o obj/jsarena.o obj/jsbuiltins.o obj/jsarray.o obj/jsatom.o obj/jsbool.o obj/jscntxt.o obj/jsdate.o obj/jsdbgapi.o obj/jsdhash.o obj/jsdtoa.o obj/jsemit.o obj/jsexn.o obj/jsfun.o obj/jstracer.o obj/jsgc.o obj/jshash.o obj/jsinterp.o obj/jsinvoke.o obj/jsiter.o obj/jslock.o obj/jslog2.o obj/jsmath.o obj/jsnum.o obj/jsobj.o obj/json.o obj/jsopcode.o obj/jsparse.o obj/jsprf.o obj/jsregexp.o obj/jsscan.o obj/jsscope.o obj/jsscript.o obj/jsstr.o obj/jsutil.o obj/jsxdrapi.o obj/jsxml.o obj/prmjtime.o obj/nanojit_Assembler.o obj/nanojit_avmplus.o obj/nanojit_Fragmento.o obj/nanojit_LIR.o obj/nanojit_CodeAlloc.o obj/nanojit_Containers.o obj/nanojit_Allocator.o obj/nanojit_Nativei386.o obj/nanojit_RegAlloc.o obj/editline.o obj/sysunix.o obj/sqlite3.o  -lm  -lpthread  
dell@Ubuntu-Baltix-2012:~/Atsiuntimai/jsdb-deb/jsdb_source_1.8.0.7$

I tried simply replace "Nativei386" with "NativeARM" in makejsdb.csh file but this doesn't help - compilation still fails.
Maybe JSDB developers could help me compile latest JSDB sources on ARM architecture (RasberryPi board) - it seems this task is on TODO list since 2011 ;) ?

2011-09-13 Shanti Rao wrote:
> A new version of JSDB is available.
> [..]
> To do (if you want to contribute)
> [..]
> * Recompile against JS engine from Firefox 5
> *ARM edition

Shanti Rao

unread,
Jan 4, 2013, 11:34:18 AM1/4/13
to js...@googlegroups.com, Baltix Linux
Howdy,

You're on the right track. The first thing to do is try compiling it without the JIT. Remove definitions for
-D FEATURE_NANOJIT  -D JS_TRACER -D AVMPLUS_IA32=1  -D AVMPLUS_LINUX=1

If you can get jsdb.cpp to compile under those conditions, then you can edit jsdb.project and add a new platform ("raspberry").  Copy the linux <platform> definition and modify the compiler flags as appropriate for your cross-compiler.

In the "release" and "debug" modes, update these lines so they will be used in every platform except raspberry.

<define platform=win32,winbcc.osx,sun>FEATURE_NANOJIT</define>
<define platform=win32,winbcc.osx,sun>JS_TRACER</define>       

JSDB builds itself. The compile scripts (makejsdb.*) are generated with ...

./jsdb make.js jsdb.project raspberry /preview > makeraspberry.csh; chmod +x makeraspberry.csh

If you get that working, you can save time in compiling by letting JSDB manage the compilation process

./jsdb make.js jsdb.project raspberry

Be sure your binary output file doesn't overwrite jsdb on your host!

Shanti

dave mobley

unread,
Aug 5, 2019, 1:29:14 AM8/5/19
to JSDB
Necro-threadding:

Did anyone ever make a successful ARM version of this?  I'd really like to try it on a Lego Mindstorms EV3 (running debian/ubuntu).  The Lego is an ARMv5 (so I can't get node.js to run).  I've looked at other languages, and most are very sluggish for startup (Python, Java).  Only C/C++/Perl/Bash start fast.  I need a very lightweight interpreter to teach the kids how to program and still be competitive in matches.

Thanks,

dave mobley

unread,
Aug 5, 2019, 1:29:14 AM8/5/19
to JSDB
Sorry for necro-ing this thread, but I'm trying to get a JS intepreter running on lego mindstorms.

I've recently tried to compile JSDB based on the limited instructions above.  Was not able to get it to built.  I'm currently using Debian Stretch on an ARMv5 processor.  

I've gotten it to build until the first set of warnings here:

zlib/inffast.c
zlib/inflate.c
zlib/inftrees.c
zlib/infutil.c
In file included from js/src/jsinterp.h:48:0,
                 from js/src/jscntxt.h:53,
                 from js/src/jsapi.cpp:60:
js/src/jsfun.h: In function ‘js_ArgsPrivateNative* js_GetArgsPrivateNative(JSObject*)’:
js/src/jsfun.h:233:55: warning: converting to non-pointer type ‘unsigned int’ from NULL [-Wconversion-null]
     return (js_ArgsPrivateNative *) (p & 2 ? p & ~2 : NULL);
                                                       ^~~~



It doesn't hit a real error though until:


In file included from js/src/jsbit.h:43:0,
                 from js/src/jstracer.cpp:43:
js/src/jstracer.cpp: At global scope:
js/src/jstracer.cpp:105:25: error: ‘JSTraceType’ was not declared in this scope
 JS_STATIC_ASSERT(sizeof(JSTraceType) == 1);
                         ^
js/src/jsutil.h:96:75: note: in definition of macro ‘JS_STATIC_ASSERT’
   typedef int JS_STATIC_ASSERT_GLUE(js_static_assert, __COUNTER__)[(cond) ? 1 : -1]
                                                                     ^~~~
js/src/jstracer.cpp:279:10: error: ‘nanojit::Allocator’ has not been declared
 nanojit::Allocator::allocChunk(size_t nbytes)
          ^~~~~~~~~



Any ideas on how to get around these?


On Friday, January 4, 2013 at 11:34:18 AM UTC-5, Shanti Rao wrote:

S Rao

unread,
Aug 5, 2019, 1:37:18 AM8/5/19
to js...@googlegroups.com
Hi Dave,

Well, congratulations for getting this far!

What happens if you don’t compile jstracer.cpp? The build script is a pretty straightforward shell script so you could just comment that line out and then exclude it from the linker at the end. At least then we will find out how to remove the JIT. 

Shanti
--
You received this message because you are subscribed to the Google Groups "JSDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jsdb+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsdb/d6a56bc5-b866-485d-ae9b-4abe370eca17%40googlegroups.com.

scprotz

unread,
Aug 5, 2019, 12:25:55 PM8/5/19
to js...@googlegroups.com
Will I need all the nanojit components or should I comment those out as well?  I rewrote the .csh file as a makefile (so it wouldn't perform recompile on the super low-power ARmv5)
-Dave

Anderson Wiese

unread,
Aug 5, 2019, 12:32:20 PM8/5/19
to js...@googlegroups.com
Hi Dave (and Shanti),
Sorry I don’t have anything helpful to add but encouragement. I used JSDB years ago as the embedded scripting engine for a home automation system, for all the same reasons you name. it worked great. Both JSDB and SpiderMonkey have such straightforward code, it was easy to extend JSDB with my own native functionality. Now I’m using nodejs on IoT, and I miss those days. 

Hi Shanti, Thanks for continuing to be engaged with your cool creation. 

S Rao

unread,
Aug 5, 2019, 3:08:02 PM8/5/19
to js...@googlegroups.com
I think removing all the JIT stuff is the way to go. 

Shanti

dave mobley

unread,
Aug 5, 2019, 3:24:39 PM8/5/19
to JSDB
So I gave that a shot.  I removed the jit stuff.  Also had to remove jstracer, jsstr, and jsxml as they each had errors.  All other files compiled fine.

I could not get the linker to build jsdb though and had pages of errors of undefined references.  

Any ideas?  I think that jsstr and jsxml probably only have minor errors at this point, but my G++-fu is not that great and haven't figured out how to fix them.  here are the errors:

In file included from js/src/jsinterp.h:48:0,
                 from js/src/jscntxt.h:53,
                 from js/src/jsxml.cpp:56:
js/src/jsfun.h: In function ‘js_ArgsPrivateNative* js_GetArgsPrivateNative(JSObject*)’:
js/src/jsfun.h:233:55: warning: converting to non-pointer type ‘unsigned int’ from NULL [-Wconversion-null]
     return (js_ArgsPrivateNative *) (p & 2 ? p & ~2 : NULL);
                                                       ^~~~
In file included from js/src/jsxml.cpp:47:0:
js/src/jsxml.cpp: In function ‘JSObject* NewXMLNamespace(JSContext*, JSString*, JSString*, JSBool)’:
js/src/jstypes.h:362:18: error: invalid conversion from ‘JSIntn {aka int}’ to ‘JSObject*’ [-fpermissive]
 #define JS_FALSE (JSIntn)0
                  ^~~~~~~~~
js/src/jsxml.cpp:306:16: note: in expansion of macro ‘JS_FALSE’
         return JS_FALSE;
                ^~~~~~~~

In file included from js/src/jsstr.cpp:55:0:
js/src/jsstr.cpp: In function ‘JSObject* js_InitStringClass(JSContext*, JSObject*)’:
js/src/jstypes.h:362:18: error: invalid conversion from ‘JSIntn {aka int}’ to ‘JSObject*’ [-fpermissive]
 #define JS_FALSE (JSIntn)0
                  ^~~~~~~~~
js/src/jsstr.cpp:3043:16: note: in expansion of macro ‘JS_FALSE’
         return JS_FALSE;
                ^~~~~~~~
js/src/jsstr.cpp
Hi Dave,

To unsubscribe from this group and stop receiving emails from it, send an email to js...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "JSDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to js...@googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "JSDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to js...@googlegroups.com.
build.txt

dave mobley

unread,
Aug 5, 2019, 3:54:43 PM8/5/19
to JSDB
Ok, so explicitly casting JS_FALSE (which is just an (int)0), allowed jsstr to compile (and I suspect jsxml.  I'll fix those and then see what is broken with the linker, because at this point the only things that are not compiling are jstracer and the nanojit.
Message has been deleted

S Rao

unread,
Aug 5, 2019, 4:17:13 PM8/5/19
to js...@googlegroups.com
The linker needs jsstr and jsxml (but didn’t that end up being deprecated in later versions of Js? So maybe the explicit cast trick and put them back in the linker to fix the references. 

BTW, if you use jsdb for robotics, you’ll want to regularly call system.gc(). Garbage collection has nondeterministic timing, and by doing it often, you can keep it brief. 

JSDB has been pretty stable for 10 years, which is coincidentally the same age as my oldest child. Meanwhile, V8 and webassembly have become incredibly advanced. So advanced, in fact, that I can’t figure out how to download and install them. As far as I can tell, nobody else but the developers can, either. So maybe it’s time for a “bare-bones” JavaScript reboot, throwing out that fancy stuff like JIT so it can run reliably on resource-limited devices like LEGO. Hmm. 

Shanti
To unsubscribe from this group and stop receiving emails from it, send an email to jsdb+uns...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jsdb/7873353c-6ff1-4950-8c8d-c5c6a05b6659%40googlegroups.com.

scprotz

unread,
Aug 5, 2019, 4:27:47 PM8/5/19
to js...@googlegroups.com
So jsstr and jsxml compiled, and were added back to the linking step.  I had to add -lsupc++ for the linker too (an ARM-ism for g++?..not sure).  But it cleared up most of the reference problems.  At this point, I think it is really close, but still have a few outstanding reference issues, mostly from sqlite3 and io_fifo.  

obj/io_fifo.o: In function `std::_Deque_base<char, std::allocator<char> >::_Deque_impl::~_Deque_impl()':
io_fifo.cpp:(.text._ZNSt11_Deque_baseIcSaIcEE11_Deque_implD2Ev[_ZNSt11_Deque_baseIcSaIcEE11_Deque_implD5Ev]+0x14): undefined reference to `std::allocator<char>::~allocator()'
obj/io_fifo.o: In function `std::_Deque_base<char, std::allocator<char> >::_Deque_impl::_Deque_impl()':
io_fifo.cpp:(.text._ZNSt11_Deque_baseIcSaIcEE11_Deque_implC2Ev[_ZNSt11_Deque_baseIcSaIcEE11_Deque_implC5Ev]+0x14): undefined reference to `std::allocator<char>::allocator()'
obj/io_fifo.o: In function `__gnu_cxx::new_allocator<char>::allocate(unsigned int, void const*)':
io_fifo.cpp:(.text._ZN9__gnu_cxx13new_allocatorIcE8allocateEjPKv[_ZN9__gnu_cxx13new_allocatorIcE8allocateEjPKv]+0x40): undefined reference to `std::__throw_bad_alloc()'
obj/io_fifo.o: In function `__gnu_cxx::new_allocator<char*>::allocate(unsigned int, void const*)':
io_fifo.cpp:(.text._ZN9__gnu_cxx13new_allocatorIPcE8allocateEjPKv[_ZN9__gnu_cxx13new_allocatorIPcE8allocateEjPKv]+0x40): undefined reference to `std::__throw_bad_alloc()'
obj/sqlite3.o: In function `unixDlOpen':
sqlite3.c:(.text+0x1203c): undefined reference to `dlopen'
obj/sqlite3.o: In function `unixDlError':
sqlite3.c:(.text+0x12074): undefined reference to `dlerror'
obj/sqlite3.o: In function `unixDlSym':
sqlite3.c:(.text+0x12110): undefined reference to `dlsym'
obj/sqlite3.o: In function `unixDlClose':
sqlite3.c:(.text+0x1212c): undefined reference to `dlclose'
collect2: error: ld returned 1 exit status
Makefile:25: recipe for target 'jsdb' failed
make: *** [jsdb] Error 1

I think these may be because of missing allocator (from jstracer or jit?)  As for the sqlite3 issues, no ideas there.  I google some and see what I can come up with on those, but looks like a missing library or something.


As for running this on LEGO, the current languages available are either slow (python or java), or fast but unsuitable for teaching middle schoolers (C, Perl, Bash).  Google pulled V8 support for ARMv5, so no good JS engine available.  Hoping JSDB can 'start fast', and still have a solid programming experience so the students can build competitive robots in a non-block programming format.

S Rao

unread,
Aug 5, 2019, 4:41:58 PM8/5/19
to js...@googlegroups.com
Ah, template instantiation. Try compiling with -frepo. At least that’s what this says: http://www.rowleydownload.co.uk/arm/documentation/gnu/gcc/Template-Instantiation.html

I hate that fifo code anyhow. I was trying to learn how to use the c++ standard template libraries, and this just goes to show why you shouldn’t do that. Too clever by half. 

SQLite, you don’t need. You could strip that out or maybe I was thinking ahead and there’s a NO_SQLITE define. Look in rs/tbl_sqlite.cpp. 

Shanti

scprotz

unread,
Aug 5, 2019, 4:44:03 PM8/5/19
to js...@googlegroups.com
Woohoo!  So I got it working on the ARMv5 right now.  I just need to run some tests and make sure I can pipe some text to some devices (or at least execute some shell script stuff doing the same thing).  It seems like it runs pretty fast, which is exactly what I wanted.  Ultimately, I found that I had to change 3 files (#undef a few defines, and do the casting in the 2 other files at mentioned above), and use my makefile on the Mindstorms for ev3dev.

I've included my Makefile if someone else wants to try and build their own JS for Mindstorms (on ev3dev stretch).
Makefile

scprotz

unread,
Aug 5, 2019, 4:46:00 PM8/5/19
to js...@googlegroups.com
Turns out, most of the complaints were an errant call to gcc instead of g++ (gcc wasn't linking all the goodies).  I switched it to g++ and got nearly all things linked.  Only had to add a -ldl to the linker for sqlite to be happy.  So all is good now and it works on the system.  Now to see if I can port the old node.js javascript codebase over (since node.js no longer runs on these things).

S Rao

unread,
Aug 5, 2019, 5:26:24 PM8/5/19
to js...@googlegroups.com
Awesome! If you’ll privately send me whatever changed files you have, I’ll merge them and rev it. If you have some mindstorms samples to share, that would be great, too! 

Shanti

Michiel Crefcoeur

unread,
Aug 8, 2019, 3:36:48 PM8/8/19
to js...@googlegroups.com
You might also want to take a look at  https://www.moddable.com/.
I haven't used it myself but it seems like it's made for the thing you're trying to do.
Good luck!

Op ma 5 aug. 2019 om 23:26 schreef S Rao <shant...@gmail.com>:
Reply all
Reply to author
Forward
0 new messages