20210314: Building the QuickJS library update

Just an update... persued 4 different tracks... some success, some failures... they are -

1. Using mingw-64 emulator - OK, but todo edbrowse with same mingw...
2. Using MSVC 2019 native .x64 - got close, but close is not good enough
3. Using the MS WSL emulator - wow, a million steps to do... so far only built tidy, edbrowse, ... 4. Using github.com/c-smile/quickjspp - the premake5.exe tool FAILED to build MSVC solution... hmmmm...

The detailed exploration is below... or jump to the 'Summary:'

1. Using mingw-64
###################

Encountered an error, I can NOT seem to get past... but sort of got there, eventually...

[  9%] Building C object CMakeFiles/quickjs.dir/quickjs.c.obj
D:\mingw-w64\mingw64\bin\gcc.exe -DCONFIG_BIGNUM -DCONFIG_VERSION=\"2020-11-08\" -D_GNU_SOURCE \  -Wall -Wno-array-bounds -Wno-format-truncation -Wno-unused-variable -Wno-unused-but-set-variable \ -MMD -MF -O  -D_REENTRANT -O3 -DNDEBUG   -o CMakeFiles\quickjs.dir\quickjs.c.obj   -c D:\Projects\quickjs\quickjs.c

C:\Users\ubunt\AppData\Local\Temp\cchgmH6R.s: Assembler messages:
C:\Users\ubunt\AppData\Local\Temp\cchgmH6R.s:30898: Error: .seh_savexmm offset is negative C:\Users\ubunt\AppData\Local\Temp\cchgmH6R.s:30899: Error: .seh_savexmm offset is negative

I am using mingw-64, with gcc version (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0

I searched long and hard, but can /NOT/ find an update to my installation of mingw-64 - from -
http://mingw-w64.org/doku.php/download
2020/05/13  19:30           960,504 mingw-w64-install.exe
Appears I have the 'latest'...

From here https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86048 found -
(a) Which says: "not if -fno-reorder-blocks-and-partition" - to try
(b) Eric Botcazou 2018-06-13 11:26:27 UTC
This will be fixed in the 8.2 release.  Thanks for reporting the problem.

Ok, added '-fno-reorder-blocks-and-partition', and it compiled! WOW ;=)) success!!!

Now to figure out how to link edbrowse to this 'libquickjs.a'???

Probably need to build 'edbrowse' using the same emulator... TODO...


2. Using MSVC native
###################

A: Fixed the buildin crt with creating a "ctz_clz.h" header which adds these functions..
Add to cutils.h -
+#ifdef _MSC_VER
+#include "ctz_clz.h"
+#define __attribute__(x)
+#endif // _MSC_VER
+

B: Commented out <unistd.h>, in various places - like -

+#ifndef _MSC_VER
 #include <unistd.h>
+#endif /* #ifndef _MSC_VER */

C: Few other relatively minor fixes in the source... \

D: On __int128 being used. At the moment can not find a patch to cover this...

E: Swiched OFF CONFIG_BIGNUM support... eventually got 'quickjs.lib' to build

F: Big problem - the 'qjsc' compiler failed to convert 'repl.js' to 'repl.c', and likewise with 'qjscalc.js' to C code... overcame this with copy the generated *.c files from the mingw-64 build... not a good solution!

So, I have a 'quickjs.lib'... need to sort out which headers to install - list looks like 'quickjs-atom.h, quickjs-libc.h, quickjs-opcode.h, quickjs.h'... so TODO: finish the INSTALL step... then TODO: build of eb-qjs...


3. More exploration into WSL - it's getting to be much more than expected!
###################

Per the install docs - https://docs.microsoft.com/en-us/windows/wsl/install-win10 -

Joined the Windows Insiders Program, as requested... hope I do not regret this... do not like words like - you will receive emails, and the only way to stop this (spam), is to un-join the program... well, ok, but not nice...

Am running the min version - Microsoft Windows [Version 10.0.19041.804], so that's ok...
ran 2021/03/11  18:34        15,282,176 wsl_update_x64.msi
Did a Windows feature update, which took about 1/2 hour - must now reboot...

Had to jump through some other hoops, installed Ubuntu 20.04... and evenually got an 'Ubuntu' app, which opens as a terminal... and it certainly looks and feels like Ubuntu...

Then spent some time setting up this 'bash' terminal... add my own '.bash_aliases'... installed g++, cmake... even git cloned tidy, built, and installed it...

TODO: But still to figure out where all this is stored? So presently NO access to my native Windows filesystem... and when in Ubuntu, can't yet access outside of the unix root, '/'...

So at this time this is a MAJOR setback... yes I could re-download all the sources... TODO: but...

At this time this is no different to using a 2nd machine...

And really puts me no closer to building QuickJS in native Windows???

On WSL, in general, so far it feels like a very good linux emulator... single click access to terminal... much faster than a dual boot... just missing the native filesystem access... or at least access to my expansion drives - G: and H:

Hmmm, found /mnt/g, /mnt/h, and then /mnt/c and /mnt/d, so do have access to full filesystem... will try some more things...

Wow, I have to say that it is quite a 'complete' emulation... maybe more than an 'emulation'... it is running a linux kernel...
ubunt@DELL03:~/bin$ hvers
Show LSB version 'lsb_release -a'
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04.2 LTS
Release:        20.04
Codename:       focal

Show version 'uname -a'
Linux DELL03 5.4.72-microsoft-standard-WSL2 #1 SMP Wed Oct 28 23:40:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
ubunt@DELL03:~/bin$

As indicated, really a 'Virtual Machine'... to download my edbrowse-fork, had to even copy a rca .pub to my github account...

And can now see my complete disk system, in terms that I know - A:, B:, C:, ... drives - namely -
$ df -H | grep -v /dev/loop
Filesystem      Size  Used Avail Use% Mounted on
/dev/sdb        270G  2.3G  254G   1% /
tmpfs            10G     0   10G   0% /mnt/wsl
tools           492G  180G  312G  37% /init
none             10G     0   10G   0% /dev
none             10G   17k   10G   1% /run
none             10G     0   10G   0% /run/lock
none             10G     0   10G   0% /run/shm
none             10G     0   10G   0% /run/user
tmpfs            10G     0   10G   0% /sys/fs/cgroup
C:\             492G  180G  312G  37% /mnt/c
D:\             1.1T  598G  403G  60% /mnt/d
G:\             2.1T  1.6T  430G  79% /mnt/g
H:\             2.1T  775G  1.3T  39% /mnt/h

There is quite a problem with line endings... git, in native windows, adds CR/LF pair to text/script files, which causes the '#! /bin/sh' shell to break, and need to do 'dos2unix <script>' to make it right...

Ran into a problem building in '/mnt/h/UTILS/eb-fork/temp' - can NOT find CURL, but curl IS installed... I think... DONE: Solved the build prob...

To start, cloned my eb-fork into this filesystem... at ~/projects/eb-fork... and commenced a build - needed to install pcre - pcre-dev, libreadline-dev, duktape-dev, ... and it built fine... ran a ../src/jsrt test... looks ok... http://yahoo.com loaded, seemingly fine... got links...

Then back to the native clone... ran my build-me.sh, and now it builds fine here too - log -
-- +++ Search using paths /home/ubunt
-- *** Tidy found inc /usr/include lib /usr/lib/libtidy.so
-- *** CURL found inc /usr/include/x86_64-linux-gnu lib /usr/lib/x86_64-linux-gnu/libcurl.so
-- cURL version 7.68.0
-- *** PCRE found inc /usr/include lib /usr/lib/x86_64-linux-gnu/libpcre.so
-- *** READLINE found inc /usr/include lib /usr/lib/x86_64-linux-gnu/libreadline.so -- *** Duktape found inc /usr/include lib /usr/lib/x86_64-linux-gnu/libduktape.so
-- *** Building static library STATIC
-- Language ebrc files: LANG_EBRC_FILES=/mnt/h/UTILS/eb-fork/lang/ebrc-de;/mnt/h/UTILS/eb-fork/lang/ebrc-en;/mnt/h/UTIL>-- Doc guide files: DOC_GUIDE_FILES=/mnt/h/UTILS/eb-fork/doc/usersguide.html;/mnt/h/UTILS/eb-fork/doc/usersguide_fr.htm>-- Language msg files: LANG_MSG_FILES=/mnt/h/UTILS/eb-fork/lang/msg-de;/mnt/h/UTILS/eb-fork/lang/msg-en;/mnt/h/UTILS/eb>-- *** Setup build of ebrc.c, msg-strings.c, and startwindow.c
-- Configuring done
-- Generating done
-- Build files have been written to: /mnt/h/UTILS/eb-fork/temp
[100%] Built target edbrowse

Moved onto QuickJS - re-cloned it into ~/projects/quickjs - ran '$ make'... and it completed ok... did 'make install', and it put the compiled exes in /usr/local/bin, and the headers into /usr/local/include...

Back to edbrowse build, and can not find a target in the 'makefile'...

TODO: How to build eb-qjs, using the above 'quickjs' lib, in '/usr/local/lib'???0

4. Found c-smile:fork, using 'premake5' for MSVC 2019
###################

Cloned this repo - https://github.com/c-smile/quickjspp

And downloaded - https://premake.github.io/download.html - to get 'premake5.exe'...

In a 'build' dir, did - premake5 "--file=..\premake5.lua" vs2019
Built MSVC sln in a '.build\vs2019\quickjs.sln, but it FAILED to load??? Could not find my MSVC 2019 installation... Maybe if I run 'premake5 vs2019' in a MSVC command prompt... no still FAILED!
But from the gen'ed quikcjs.vcxproj noted some potential MACROS to add -
<PreprocessorDefinitions>JS_STRICT_NAN_BOXING;CONFIG_BIGNUM;_HAS_EXCEPTIONS=0
which may help, in my getting close MSVC build, and verifies a lot of things...

I am getting closer with my CMakeLists/MSVC build... so TODO: persue a build in this repo... especially interested in how the BIGNUM/__int128 problem is dealt with... it it is...

Summary:
########

You can see quite a few TODO: markers, and will continue to work on these, as time permits...

TODO:mingw: build edbrowse in mingw-64 emulator...
TODO:msvc: set up a link for eb-qjs.exe build...
TODO:WSL: access or download 'edbrowse' source, and build... but does this help? Yes and NO! time sink... TDOO:WSL: build eb-qjs version... need to mod CMakeLists.txt... shift most of the source to an eb.lib, then build various versions, with minor src changes - no repeated srcs...
TOTO:c-smile: take this a few steps further forward... a big maybe...


If interested, at this time, could push a win-bld branch, in my fork... if you have time to catch up to a few purely Windows things... not urgent... it may be a few commits behind master...

Any feedback appreciated... lots of FUN, and time, exploring...

Best regards, Geoff.


Reply via email to