VCVRack / VCV-Prototype

Other
130 stars 23 forks source link

Add QuickJS as default Javascript engine #12

Closed JerrySievert closed 4 years ago

JerrySievert commented 4 years ago

uses modified version of QuickJS that lives at https://github.com/JerrySievert/QuickJS

added git clone to Makefile, you will likely want to change this to a submodule to lock down the commit id.

I've tested builds on Mac, linux, and windows, tested running on Mac and windows.

There is a horrible hack that executes Javascript to convert ArrayBuffer to Float32Array, my change to quickjs.c for this was not successful - I will make another attempt later to hopefully remove the hack. https://github.com/JerrySievert/VCV-Prototype/blob/master/src/QuickJSEngine.cpp#L191-L201

otherwise, this is a pretty faithful port.

QuickJS changes:

JerrySievert commented 4 years ago

oh, and I added myself as a contributor, and fixed the spelling of contributor to be correct.

AndrewBelt commented 4 years ago

Merged. A few things you should fix in your QuickJS fork.

AndrewBelt commented 4 years ago

Patch which implements the above.

patch.txt

Apply with git apply patch.txt

JerrySievert commented 4 years ago

why did you remove -fPIC in your patch?

nevermind, just saw:

because Rack's dep build automatically injects that, as well as -march=nocona etc into CFLAGS.

teaches me to reply while still half asleep.

AndrewBelt commented 4 years ago

It's already in the CFLAGS environment variable for Rack plugins. Not sure if it should be default, but it wasn't in the original QuickJS source.

JerrySievert commented 4 years ago

yeah, I knew it wasn't in the original QuickJS source, gcc gave me the error on Linux when embedding it within rack. I have the same issue when embedding on Linux with other code that uses -fPIC when compiling:

/usr/bin/ld: deps/quickjs/libquickjs.a(quickjs.nolto.o): relocation R_X86_64_PC32 against symbol `lre_id_start_table_ascii' can not be used when making a shared object; recompile with -fPIC

given that I usually only embed with code that's compiled as a .so, it should probably live there as being able to relocate isn't a problem when compiling against an executable.

AndrewBelt commented 4 years ago

@JerrySievert I've switched QuickJS from a submodule to the Makefile calling git clone .... This will probably change your workflow if maintaining QuickJS in the future, so you should know.