changeset 2608:76ccd4e7d5d7

QuickJS: fix nginx configure with not configured njs module. This fixes issue #960 which was introduced in 8259f9a.
author Vadim Zhestikov <v.zhestikov@f5.com>
date Fri, 29 Aug 2025 09:42:18 -0700
parents 362ef716eabc
children c86522744d77
files .github/workflows/check-pr.yml auto/quickjs external/njs_shell.c nginx/config src/qjs.h src/quickjs_compat.h
diffstat 6 files changed, 36 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/.github/workflows/check-pr.yml	Mon Aug 18 21:21:09 2025 -0700
+++ b/.github/workflows/check-pr.yml	Fri Aug 29 09:42:18 2025 -0700
@@ -134,7 +134,9 @@
 
       - name: Configure and build nginx and njs modules with quickjs, asan, static modules
         run: |
+          $MAKE_UTILITY clean
           cd nginx-source
+          $MAKE_UTILITY clean
           $NGINX_CONFIGURE_CMD --with-cc-opt="$CC_OPT -I${{ github.workspace }}/quickjs -fsanitize=address -DNJS_DEBUG_MEMORY -DNGX_DEBUG_PALLOC -DNGX_DEBUG_MALLOC" --with-ld-opt="$LD_OPT -L${{ github.workspace }}/quickjs -fsanitize=address" --add-module=../nginx || cat objs/autoconf.err
           $MAKE_UTILITY -j$(nproc)
 
--- a/auto/quickjs	Mon Aug 18 21:21:09 2025 -0700
+++ b/auto/quickjs	Fri Aug 29 09:42:18 2025 -0700
@@ -15,7 +15,7 @@
     njs_feature_run=yes
     njs_feature_incs="$NJS_QUICKJS_DEFAULT_INCS"
     njs_feature_libs="-lquickjs.lto -lm -ldl -lpthread"
-    njs_feature_test="#include <qjs.h>
+    njs_feature_test="#include <quickjs_compat.h>
 
                       int main() {
                           JSRuntime *rt;
@@ -62,7 +62,7 @@
 
         njs_feature="QuickJS JS_GetClassID()"
         njs_feature_name=NJS_HAVE_QUICKJS_GET_CLASS_ID
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               (void) JS_GetClassID(JS_UNDEFINED);
@@ -80,7 +80,7 @@
 
         njs_feature="QuickJS JS_NewTypedArray()"
         njs_feature_name=NJS_HAVE_QUICKJS_NEW_TYPED_ARRAY
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSValue   ta, argv;
@@ -102,7 +102,7 @@
 
         njs_feature="QuickJS JS_IsSameValue()"
         njs_feature_name=NJS_HAVE_QUICKJS_IS_SAME_VALUE
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSRuntime *rt;
@@ -120,7 +120,7 @@
 
         njs_feature="QuickJS JS_IsArray()"
         njs_feature_name=NJS_HAVE_QUICKJS_IS_ARRAY_SINGLE_ARG
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSRuntime *rt;
@@ -138,7 +138,7 @@
 
         njs_feature="QuickJS JS_AddIntrinsicBigInt()"
         njs_feature_name=NJS_HAVE_QUICKJS_ADD_INTRINSIC_BIG_INT
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
                               JSRuntime *rt;
@@ -157,7 +157,7 @@
         njs_feature="QuickJS version"
         njs_feature_name=NJS_QUICKJS_VERSION
         njs_feature_run=value
-        njs_feature_test="#include <qjs.h>
+        njs_feature_test="#include <quickjs_compat.h>
 
                           int main() {
 #if defined(QJS_VERSION_MAJOR)
--- a/external/njs_shell.c	Mon Aug 18 21:21:09 2025 -0700
+++ b/external/njs_shell.c	Fri Aug 29 09:42:18 2025 -0700
@@ -13,6 +13,7 @@
 
 #if (NJS_HAVE_QUICKJS)
 #include <qjs.h>
+#include <pthread.h>
 #endif
 
 #if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE)
--- a/nginx/config	Mon Aug 18 21:21:09 2025 -0700
+++ b/nginx/config	Fri Aug 29 09:42:18 2025 -0700
@@ -31,7 +31,7 @@
     ngx_feature="QuickJS library -lquickjs.lto"
     ngx_feature_name=NJS_HAVE_QUICKJS
     ngx_feature_run=yes
-    ngx_feature_incs="#include <qjs.h>"
+    ngx_feature_incs="#include <quickjs_compat.h>"
     ngx_feature_path="$NJS_QUICKJS_DEFAULT_INCS"
     ngx_feature_libs="-lquickjs.lto -lm -ldl -lpthread"
     ngx_feature_test="JSRuntime *rt;
--- a/src/qjs.h	Mon Aug 18 21:21:09 2025 -0700
+++ b/src/qjs.h	Fri Aug 29 09:42:18 2025 -0700
@@ -19,28 +19,7 @@
 #include <njs_chb.h>
 #include <njs_utils.h>
 #include <njs_assert.h>
-
-#ifndef __has_warning
-#  define __has_warning(x) 0
-#endif
-
-#if (defined(__GNUC__) && (__GNUC__ >= 8))                                    \
-    || (defined(__clang__) && __has_warning("-Wcast-function-type"))
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wcast-function-type"
-#endif
-
-#include <quickjs.h>
-
-#ifndef JS_BOOL
-#define JS_BOOL bool
-#endif
-
-#if (defined(__GNUC__) && (__GNUC__ >= 8))                                    \
-    || (defined(__clang__) && __has_warning("-Wcast-function-type"))
-#pragma GCC diagnostic pop
-#endif
-#include <pthread.h>
+#include <quickjs_compat.h>
 
 
 #define QJS_CORE_CLASS_ID_OFFSET    64
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/quickjs_compat.h	Fri Aug 29 09:42:18 2025 -0700
@@ -0,0 +1,24 @@
+
+/*
+ * Copyright (C) F5, Inc.
+ */
+
+#ifndef __has_warning
+    #define __has_warning(x) 0
+#endif
+
+#if (defined(__GNUC__) && (__GNUC__ >= 8))                                    \
+    || (defined(__clang__) && __has_warning("-Wcast-function-type"))
+    #pragma GCC diagnostic push
+    #pragma GCC diagnostic ignored "-Wcast-function-type"
+
+    #include <quickjs.h>
+
+    #pragma GCC diagnostic pop
+#else
+    #include <quickjs.h>
+#endif
+
+#ifndef JS_BOOL
+    #define JS_BOOL bool
+#endif