bellard / quickjs

Public repository of the QuickJS Javascript Engine.
https://bellard.org/quickjs
Other
8.47k stars 888 forks source link

QuickJS not compilable under Mingw GCC 8.1.0 #105

Closed zzador closed 2 years ago

zzador commented 2 years ago

I was looking for an alternative to duktape and I wanted to give QuickJS a try. Sadly I was unable to compile it under MingGW-w64. Running the bundled makefile gives:

process_begin: CreateProcess(NULL, uname -s, ...) failed. make: Makefile:25: pipe: No error process_begin: CreateProcess(NULL, cat VERSION, ...) failed. make: Makefile:102: pipe: No error mkdir -p .obj .obj/examples .obj/tests Syntaxfehler. make: *** [Makefile:185: .obj] Error 1

Creating my own makefile with the bundeled files gives:

src/qjs.c: In function 'js_trace_malloc_printf': src/qjs.c:180:35: warning: unknown conversion type character 'l' in format [-Wformat=] printf("H%+06lld.%zd", ^ src/qjs.c:180:39: warning: unknown conversion type character 'z' in format [-Wformat=] printf("H%+06lld.%zd", ^ src/qjs.c:180:28: warning: too many arguments for format [-Wformat-extra-args] printf("H%+06lld.%zd", ^~~~~~~~~~~~~~ src/qjs.c:180:35: warning: unknown conversion type character 'l' in format [-Wformat=] printf("H%+06lld.%zd", ^ src/qjs.c:180:39: warning: unknown conversion type character 'z' in format [-Wformat=] printf("H%+06lld.%zd", ^ src/qjs.c:180:28: warning: too many arguments for format [-Wformat-extra-args] printf("H%+06lld.%zd", ^~~~~~~~~~~~~~ src/qjs.c:189:26: warning: unknown conversion type character 'z' in format [-Wformat=] printf("%zd", sz); ^ src/qjs.c:189:24: warning: too many arguments for format [-Wformat-extra-args] printf("%zd", sz); ^~~~~ src/qjs.c:189:26: warning: unknown conversion type character 'z' in format [-Wformat=] printf("%zd", sz); ^ src/qjs.c:189:24: warning: too many arguments for format [-Wformat-extra-args] printf("%zd", sz); ^~~~~ src/qjs.c: In function 'help': src/qjs.c:285:30: error: expected ')' before 'CONFIG_VERSION' printf("QuickJS version " CONFIG_VERSION "\n" ^~~~~~~~~~~~~~~ ) src/qjs.c: In function 'main': src/qjs.c:457:9: error: 'load_jscalc' undeclared (first use in this function); did you mean 'load_std'? if (load_jscalc) ^~~~~~~~~~~ load_std src/qjs.c:457:9: note: each undeclared identifier is reported only once for each function it appears in src/qjs.c:458:9: error: 'bignum_ext' undeclared (first use in this function) bignum_ext = 1; ^~~~~~~~~~ make: *** [makefile:18: bin/qjs.o] Error 1

Is this project generally written in C or is it specifically designed to be only compiled under one special compiler?

jaens commented 2 years ago

Works fine as expected on MSYS2 MingW GCC with UCRT64 runtime.

Just need to uncomment CONFIG_WIN32=y and comment out the following lines in Makefile (which enable MingW cross-compilation from Linux):

# ifdef CONFIG_WIN32
#   ifdef CONFIG_M32
#     CROSS_PREFIX=i686-w64-mingw32-
#   else
#     CROSS_PREFIX=x86_64-w64-mingw32-
#   endif
#   EXE=.exe
# else
#   CROSS_PREFIX=
#   EXE=
# endif

make output:

... bunch of gcc ...
./qjsc -fno-string-normalize -fno-map -fno-promise -fno-typedarray -fno-typedarray -fno-regexp -fno-json -fno-eval -fno-proxy -fno-date -m -o examples/hello_module examples/hello_module.js
Executable output is not supported for this target

(eventually one of the targets fails indeed but at least it compiles qjs.exe successfully)

Output works:

> ./qjs.exe
QuickJS - Type "\h" for help