details:   
https://github.com/nginx/njs/commit/99aac0dca38c0b3dd247e02b15164b8bf73849f7
branches:  master
commit:    99aac0dca38c0b3dd247e02b15164b8bf73849f7
user:      Vadim Zhestikov <v.zhesti...@f5.com>
date:      Fri, 29 Aug 2025 09:42:18 -0700
description:
QuickJS: fix nginx configure with not configured njs module.

This fixes issue #960 which was introduced in 8259f9a.

---
 .github/workflows/check-pr.yml |  2 ++
 auto/quickjs                   | 14 +++++++-------
 external/njs_shell.c           |  1 +
 nginx/config                   |  2 +-
 src/qjs.h                      | 23 +----------------------
 src/quickjs_compat.h           | 24 ++++++++++++++++++++++++
 6 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/.github/workflows/check-pr.yml b/.github/workflows/check-pr.yml
index 2be02e7b..c75f3cbe 100644
--- a/.github/workflows/check-pr.yml
+++ b/.github/workflows/check-pr.yml
@@ -134,7 +134,9 @@ jobs:
 
       - 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)
 
diff --git a/auto/quickjs b/auto/quickjs
index cbf860a2..8d6b544f 100644
--- a/auto/quickjs
+++ b/auto/quickjs
@@ -15,7 +15,7 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
     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 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         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 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         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 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         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 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         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 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
 
         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 @@ if [ $NJS_TRY_QUICKJS = YES ]; then
         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)
diff --git a/external/njs_shell.c b/external/njs_shell.c
index 75316339..c2294f75 100644
--- a/external/njs_shell.c
+++ b/external/njs_shell.c
@@ -13,6 +13,7 @@
 
 #if (NJS_HAVE_QUICKJS)
 #include <qjs.h>
+#include <pthread.h>
 #endif
 
 #if (!defined NJS_FUZZER_TARGET && defined NJS_HAVE_READLINE)
diff --git a/nginx/config b/nginx/config
index 474be8f3..3386dac0 100644
--- a/nginx/config
+++ b/nginx/config
@@ -31,7 +31,7 @@ if [ $NJS_QUICKJS != NO ]; then
     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;
diff --git a/src/qjs.h b/src/qjs.h
index 954cc23c..cd5c2521 100644
--- a/src/qjs.h
+++ b/src/qjs.h
@@ -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
diff --git a/src/quickjs_compat.h b/src/quickjs_compat.h
new file mode 100644
index 00000000..3b7a618c
--- /dev/null
+++ b/src/quickjs_compat.h
@@ -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
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
https://mailman.nginx.org/mailman/listinfo/nginx-devel

Reply via email to