You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/03/17 03:28:14 UTC
[incubator-nuttx-apps] 01/02: interpreters/quickjs: Bump to latest
release
This is an automated email from the ASF dual-hosted git repository.
xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx-apps.git
commit 19b49ba045a9dad3a9eb3c3d64f3c07c35f30ed7
Author: Huang Qi <hu...@xiaomi.com>
AuthorDate: Fri Mar 12 17:10:54 2021 +0800
interpreters/quickjs: Bump to latest release
Signed-off-by: Huang Qi <hu...@xiaomi.com>
Change-Id: I1cd96c4333442f8c3a3c58c3f8ae5bfac1734f5c
---
interpreters/quickjs/.gitignore | 1 -
...001-Disabled-unsupported-feature-on-NuttX.patch | 71 +++++
interpreters/quickjs/Kconfig | 5 +-
interpreters/quickjs/Makefile | 39 ++-
interpreters/quickjs/quickjs.patch | 302 ---------------------
5 files changed, 102 insertions(+), 316 deletions(-)
diff --git a/interpreters/quickjs/.gitignore b/interpreters/quickjs/.gitignore
index 30534d8..b43e455 100644
--- a/interpreters/quickjs/.gitignore
+++ b/interpreters/quickjs/.gitignore
@@ -1,2 +1 @@
quickjs*
-*.tar.gz
diff --git a/interpreters/quickjs/0001-Disabled-unsupported-feature-on-NuttX.patch b/interpreters/quickjs/0001-Disabled-unsupported-feature-on-NuttX.patch
new file mode 100644
index 0000000..c89c62f
--- /dev/null
+++ b/interpreters/quickjs/0001-Disabled-unsupported-feature-on-NuttX.patch
@@ -0,0 +1,71 @@
+From a3374db7eca1141ec8a3909ff001f52f3e79d905 Mon Sep 17 00:00:00 2001
+From: Huang Qi <hu...@xiaomi.com>
+Date: Wed, 10 Mar 2021 16:30:13 +0800
+Subject: [PATCH] Disabled unsupported feature on NuttX.
+
+N/A
+
+Signed-off-by: Huang Qi <hu...@xiaomi.com>
+Change-Id: I4ff1793609b752320d64406deec3c0ed9b4da965
+---
+ qjs.c | 2 ++
+ quickjs-libc.c | 14 +++++++-------
+ 2 files changed, 9 insertions(+), 7 deletions(-)
+
+diff --git a/qjs.c b/qjs.c
+index 4dd11f8..a35a500 100644
+--- a/qjs.c
++++ b/qjs.c
+@@ -448,8 +448,10 @@ int main(int argc, char **argv)
+ }
+ }
+
++#ifdef CONFIG_BIGNUM
+ if (load_jscalc)
+ bignum_ext = 1;
++#endif
+
+ if (trace_memory) {
+ js_trace_malloc_init(&trace_data);
+diff --git a/quickjs-libc.c b/quickjs-libc.c
+index e8b81e9..858703c 100644
+--- a/quickjs-libc.c
++++ b/quickjs-libc.c
+@@ -3558,10 +3558,10 @@ static const JSCFunctionListEntry js_os_funcs[] = {
+ JS_CFUNC_MAGIC_DEF("setWriteHandler", 2, js_os_setReadHandler, 1 ),
+ JS_CFUNC_DEF("signal", 2, js_os_signal ),
+ OS_FLAG(SIGINT),
+- OS_FLAG(SIGABRT),
+- OS_FLAG(SIGFPE),
+- OS_FLAG(SIGILL),
+- OS_FLAG(SIGSEGV),
++ // OS_FLAG(SIGABRT),
++ // OS_FLAG(SIGFPE),
++ // OS_FLAG(SIGILL),
++ // OS_FLAG(SIGSEGV),
+ OS_FLAG(SIGTERM),
+ #if !defined(_WIN32)
+ OS_FLAG(SIGQUIT),
+@@ -3573,8 +3573,8 @@ static const JSCFunctionListEntry js_os_funcs[] = {
+ OS_FLAG(SIGCONT),
+ OS_FLAG(SIGSTOP),
+ OS_FLAG(SIGTSTP),
+- OS_FLAG(SIGTTIN),
+- OS_FLAG(SIGTTOU),
++ // OS_FLAG(SIGTTIN),
++ // OS_FLAG(SIGTTOU),
+ #endif
+ JS_CFUNC_DEF("setTimeout", 2, js_os_setTimeout ),
+ JS_CFUNC_DEF("clearTimeout", 1, js_os_clearTimeout ),
+@@ -3603,7 +3603,7 @@ static const JSCFunctionListEntry js_os_funcs[] = {
+ JS_CFUNC_DEF("realpath", 1, js_os_realpath ),
+ JS_CFUNC_DEF("symlink", 2, js_os_symlink ),
+ JS_CFUNC_DEF("readlink", 1, js_os_readlink ),
+- JS_CFUNC_DEF("exec", 1, js_os_exec ),
++ // JS_CFUNC_DEF("exec", 1, js_os_exec ),
+ JS_CFUNC_DEF("waitpid", 2, js_os_waitpid ),
+ OS_FLAG(WNOHANG),
+ JS_CFUNC_DEF("pipe", 0, js_os_pipe ),
+--
+2.25.1
+
diff --git a/interpreters/quickjs/Kconfig b/interpreters/quickjs/Kconfig
index 7e29d66..6db7026 100644
--- a/interpreters/quickjs/Kconfig
+++ b/interpreters/quickjs/Kconfig
@@ -11,7 +11,10 @@ if INTERPRETERS_QUICKJS
config INTERPRETERS_QUICKJS_BIGNUM
bool "Bignum support"
- default false
+ default n
+ ---help---
+ It's depend on libatomic,
+ Not all platform support it.
config INTERPRETERS_QUICKJS_PRIORITY
int "QuickJS interpreter priority"
diff --git a/interpreters/quickjs/Makefile b/interpreters/quickjs/Makefile
index 08de147..1a1f2ef 100644
--- a/interpreters/quickjs/Makefile
+++ b/interpreters/quickjs/Makefile
@@ -20,22 +20,35 @@
include $(APPDIR)/Make.defs
-QUICKJS_VERSION = 20200705
+QUICKJS_VERSION = 2020-11-08
QUICKJS_UNPACK = quickjs
-QUICKJS_TARBALL = $(QUICKJS_VERSION).tar.gz
-QUICKJS_URL_BASE = https://github.com/horhof/quickjs/archive
+QUICKJS_TARBALL = quickjs-$(QUICKJS_VERSION).tar.xz
+QUICKJS_URL_BASE = https://bellard.org/quickjs/
QUICKJS_URL = $(QUICKJS_URL_BASE)/$(QUICKJS_TARBALL)
-CSRCS = quickjs.c libregexp.c jscompress.c libbf.c libunicode.c
-CSRCS += cutils.c quickjs-libc.c repl.c
+CSRCS = quickjs.c libregexp.c libbf.c libunicode.c cutils.c
+CSRCS += quickjs-libc.c repl.c
MAINSRC = qjs.c
-VERSION=\"$(shell cat $(QUICKJS_UNPACK)/VERSION)\"
+VERSION=\"$(QUICKJS_VERSION)\"
CFLAGS += -DCONFIG_VERSION=$(VERSION) -Wno-shadow
CFLAGS += -Wno-array-bounds -I$(QUICKJS_UNPACK)
-ifneq ($(CONFIG_INTERPRETERS_QUICKJS_BIGNUM),)
+CFLAGS += -D__linux__ -include alloca.h
+CFLAGS += -Wno-incompatible-pointer-types
+CFLAGS += -Wno-implicit-function-declaration
+CFLAGS += -Wno-unused-function
+CFLAGS += -Wno-format
+
+ifeq ($(CONFIG_ARCH_ARM),y)
+CFLAGS += -DFE_TONEAREST=0x00000000
+CFLAGS += -DFE_UPWARD=0x00400000
+CFLAGS += -DFE_DOWNWARD=0x00800000
+CFLAGS += -DFE_TOWARDZERO=0x00c00000
+endif
+
+ifeq ($(CONFIG_INTERPRETERS_QUICKJS_BIGNUM),y)
CFLAGS += -DCONFIG_BIGNUM
CSRCS += qjscalc.c
endif
@@ -53,16 +66,18 @@ $(QUICKJS_TARBALL):
$(QUICKJS_UNPACK): $(QUICKJS_TARBALL)
$(Q) echo "Unpacking $(QUICKJS_TARBALL) to $(QUICKJS_UNPACK)"
- $(Q) tar xzvf $(QUICKJS_TARBALL)
+ $(Q) tar -Jxf $(QUICKJS_TARBALL)
$(Q) mv quickjs-$(QUICKJS_VERSION) $(QUICKJS_UNPACK)
- $(Q) patch -p0 < quickjs.patch
+ $(Q) patch -d $(QUICKJS_UNPACK) -p1 < 0001-Disabled-unsupported-feature-on-NuttX.patch
$(QUICKJS_UNPACK)/.patch: $(QUICKJS_UNPACK)
- $(Q) make -C $(QUICKJS_UNPACK) \
- CONFIG_BIGNUM=$(CONFIG_INTERPRETERS_QUICKJS_BIGNUM)
$(Q) touch $(QUICKJS_UNPACK)/.patch
-context:: $(QUICKJS_UNPACK)/.patch
+build_host: $(QUICKJS_UNPACK)/.patch
+ make -C $(QUICKJS_UNPACK) \
+ CONFIG_BIGNUM=$(CONFIG_INTERPRETERS_QUICKJS_BIGNUM)
+
+context:: build_host
clean::
$(Q) test ! -d $(QUICKJS_UNPACK) || make -C $(QUICKJS_UNPACK) clean
diff --git a/interpreters/quickjs/quickjs.patch b/interpreters/quickjs/quickjs.patch
deleted file mode 100644
index d3242b4..0000000
--- a/interpreters/quickjs/quickjs.patch
+++ /dev/null
@@ -1,302 +0,0 @@
-diff --color -upr quickjs/libregexp.c quickjs-20200705-modified/libregexp.c
---- quickjs/libregexp.c 2020-07-25 05:25:41.000000000 +0800
-+++ quickjs-20200705-modified/libregexp.c 2020-08-27 16:04:41.440000000 +0800
-@@ -21,6 +21,7 @@
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-+#include <alloca.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
-diff --color -upr quickjs/qjs.c quickjs-20200705-modified/qjs.c
---- quickjs/qjs.c 2020-07-25 05:25:41.000000000 +0800
-+++ quickjs-20200705-modified/qjs.c 2020-08-27 16:23:55.750000000 +0800
-@@ -34,7 +34,7 @@
- #include <time.h>
- #if defined(__APPLE__)
- #include <malloc/malloc.h>
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__NuttX__)
- #include <malloc.h>
- #endif
-
-@@ -242,7 +242,7 @@ static const JSMallocFunctions trace_mf
- (size_t (*)(const void *))_msize,
- #elif defined(EMSCRIPTEN)
- NULL,
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__NuttX__)
- (size_t (*)(const void *))malloc_usable_size,
- #else
- /* change this to `NULL,` if compilation fails */
-diff --color -upr quickjs/quickjs-libc.c quickjs-20200705-modified/quickjs-libc.c
---- quickjs/quickjs-libc.c 2020-07-25 05:25:41.000000000 +0800
-+++ quickjs-20200705-modified/quickjs-libc.c 2020-08-27 17:10:06.890000000 +0800
-@@ -46,6 +46,7 @@
- #include <termios.h>
- #include <sys/ioctl.h>
- #include <sys/wait.h>
-+#include <spawn.h>
-
- #if defined(__APPLE__)
- typedef sig_t sighandler_t;
-@@ -71,6 +72,42 @@ typedef sig_t sighandler_t;
- #include "list.h"
- #include "quickjs-libc.h"
-
-+#ifndef SIGQUIT
-+# define SIGQUIT 3
-+#endif
-+
-+#ifndef SIGILL
-+# define SIGILL 4
-+#endif
-+
-+#ifndef SIGABRT
-+# define SIGABRT 6
-+#endif
-+
-+#ifndef SIGFPE
-+# define SIGFPE 8
-+#endif
-+
-+#ifndef SIGSEGV
-+# define SIGSEGV 13
-+#endif
-+
-+#ifndef SIGTERM
-+# define SIGTERM 15
-+#endif
-+
-+#ifndef SIGTSTP
-+# define SIGTSTP 18
-+#endif
-+
-+#ifndef SIGTTIN
-+# define SIGTTIN 21
-+#endif
-+
-+#ifndef SIGTTOU
-+# define SIGTTOU 22
-+#endif
-+
- /* TODO:
- - add socket calls
- */
-@@ -2622,62 +2651,6 @@ static char **build_envp(JSContext *ctx,
- goto done;
- }
-
--/* execvpe is not available on non GNU systems */
--static int my_execvpe(const char *filename, char **argv, char **envp)
--{
-- char *path, *p, *p_next, *p1;
-- char buf[PATH_MAX];
-- size_t filename_len, path_len;
-- BOOL eacces_error;
--
-- filename_len = strlen(filename);
-- if (filename_len == 0) {
-- errno = ENOENT;
-- return -1;
-- }
-- if (strchr(filename, '/'))
-- return execve(filename, argv, envp);
--
-- path = getenv("PATH");
-- if (!path)
-- path = (char *)"/bin:/usr/bin";
-- eacces_error = FALSE;
-- p = path;
-- for(p = path; p != NULL; p = p_next) {
-- p1 = strchr(p, ':');
-- if (!p1) {
-- p_next = NULL;
-- path_len = strlen(p);
-- } else {
-- p_next = p1 + 1;
-- path_len = p1 - p;
-- }
-- /* path too long */
-- if ((path_len + 1 + filename_len + 1) > PATH_MAX)
-- continue;
-- memcpy(buf, p, path_len);
-- buf[path_len] = '/';
-- memcpy(buf + path_len + 1, filename, filename_len);
-- buf[path_len + 1 + filename_len] = '\0';
--
-- execve(buf, argv, envp);
--
-- switch(errno) {
-- case EACCES:
-- eacces_error = TRUE;
-- break;
-- case ENOENT:
-- case ENOTDIR:
-- break;
-- default:
-- return -1;
-- }
-- }
-- if (eacces_error)
-- errno = EACCES;
-- return -1;
--}
--
- /* exec(args[, options]) -> exitcode */
- static JSValue js_os_exec(JSContext *ctx, JSValueConst this_val,
- int argc, JSValueConst *argv)
-@@ -2687,12 +2660,13 @@ static JSValue js_os_exec(JSContext *ctx
- const char **exec_argv, *file = NULL, *str, *cwd = NULL;
- char **envp = environ;
- uint32_t exec_argc, i;
-- int ret, pid, status;
-+ int ret, status;
-+ pid_t pid;
- BOOL block_flag = TRUE, use_path = TRUE;
- static const char *std_name[3] = { "stdin", "stdout", "stderr" };
-- int std_fds[3];
- uint32_t uid = -1, gid = -1;
--
-+ posix_spawn_file_actions_t action;
-+
- val = JS_GetPropertyStr(ctx, args, "length");
- if (JS_IsException(val))
- return JS_EXCEPTION;
-@@ -2718,10 +2692,8 @@ static JSValue js_os_exec(JSContext *ctx
- exec_argv[i] = str;
- }
- exec_argv[exec_argc] = NULL;
-+ posix_spawn_file_actions_init(&action);
-
-- for(i = 0; i < 3; i++)
-- std_fds[i] = i;
--
- /* get the options, if any */
- if (argc >= 2) {
- options = argv[1];
-@@ -2762,7 +2734,9 @@ static JSValue js_os_exec(JSContext *ctx
- JS_FreeValue(ctx, val);
- if (ret)
- goto exception;
-- std_fds[i] = fd;
-+ if (fd != i) {
-+ posix_spawn_file_actions_adddup2(&action, fd, i);
-+ }
- }
- }
-
-@@ -2797,46 +2771,17 @@ static JSValue js_os_exec(JSContext *ctx
- }
- }
-
-- pid = fork();
-- if (pid < 0) {
-- JS_ThrowTypeError(ctx, "fork error");
-+ if (!file)
-+ file = exec_argv[0];
-+ if (use_path)
-+ ret = posix_spawnp(&pid, file, &action, NULL, (char **)exec_argv, envp);
-+ else
-+ ret = posix_spawn(&pid, file, &action, NULL, (char **)exec_argv, envp);
-+
-+ if (ret < 0) {
- goto exception;
- }
-- if (pid == 0) {
-- /* child */
-- int fd_max = sysconf(_SC_OPEN_MAX);
-
-- /* remap the stdin/stdout/stderr handles if necessary */
-- for(i = 0; i < 3; i++) {
-- if (std_fds[i] != i) {
-- if (dup2(std_fds[i], i) < 0)
-- _exit(127);
-- }
-- }
--
-- for(i = 3; i < fd_max; i++)
-- close(i);
-- if (cwd) {
-- if (chdir(cwd) < 0)
-- _exit(127);
-- }
-- if (uid != -1) {
-- if (setuid(uid) < 0)
-- _exit(127);
-- }
-- if (gid != -1) {
-- if (setgid(gid) < 0)
-- _exit(127);
-- }
--
-- if (!file)
-- file = exec_argv[0];
-- if (use_path)
-- ret = my_execvpe(file, (char **)exec_argv, envp);
-- else
-- ret = execve(file, (char **)exec_argv, envp);
-- _exit(127);
-- }
- /* parent */
- if (block_flag) {
- for(;;) {
-@@ -2856,6 +2801,7 @@ static JSValue js_os_exec(JSContext *ctx
- }
- ret_val = JS_NewInt32(ctx, ret);
- done:
-+ posix_spawn_file_actions_destroy(&action);
- JS_FreeCString(ctx, file);
- JS_FreeCString(ctx, cwd);
- for(i = 0; i < exec_argc; i++)
-diff --color -upr quickjs/quickjs.c quickjs-20200705-modified/quickjs.c
---- quickjs/quickjs.c 2020-07-25 05:25:41.000000000 +0800
-+++ quickjs-20200705-modified/quickjs.c 2020-08-27 17:10:33.520000000 +0800
-@@ -22,6 +22,7 @@
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-+#include <alloca.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <stdarg.h>
-@@ -34,7 +35,7 @@
- #include <math.h>
- #if defined(__APPLE__)
- #include <malloc/malloc.h>
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__NuttX__)
- #include <malloc.h>
- #endif
-
-@@ -104,6 +105,20 @@
- //#define DUMP_PROMISE
- //#define DUMP_READ_OBJECT
-
-+#ifndef FE_TONEAREST
-+# define FE_TONEAREST 0x00000000
-+#endif
-+#ifndef FE_UPWARD
-+# define FE_UPWARD 0x00400000
-+#endif
-+#ifndef FE_DOWNWARD
-+# define FE_DOWNWARD 0x00800000
-+#endif
-+#ifndef FE_TOWARDZERO
-+# define FE_TOWARDZERO 0x00c00000
-+#endif
-+
-+
- /* test the GC by forcing it before each object allocation */
- //#define FORCE_GC_AT_MALLOC
-
-@@ -1736,7 +1751,7 @@ static const JSMallocFunctions def_mallo
- (size_t (*)(const void *))_msize,
- #elif defined(EMSCRIPTEN)
- NULL,
--#elif defined(__linux__)
-+#elif defined(__linux__) || defined(__NuttX__)
- (size_t (*)(const void *))malloc_usable_size,
- #else
- /* change this to `NULL,` if compilation fails */