Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to build njs with QuickJS support as a module #801

Closed
woxxo opened this issue Oct 16, 2024 · 4 comments
Closed

Unable to build njs with QuickJS support as a module #801

woxxo opened this issue Oct 16, 2024 · 4 comments

Comments

@woxxo
Copy link

woxxo commented Oct 16, 2024

When building Nginx with njs as a static module according to this instruction, everything works like a charm:

./configure --add-module=<NJS_SRC_ROOT_DIR>/nginx

I would like to use QuickJS engine, but can't configure the compilation properly, always getting these logs:

configuring additional modules
adding module in /home/opt/src/njs-master/nginx
checking for QuickJS library -lquickjs.lto ... not found
checking for QuickJS library -lquickjs ... not found
checking for QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs.lto ... not found
checking for QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs ... not found
 enabled webcrypto module
 enabled xml module
 enabled zlib module
 + ngx_js_module was configured

Using these options with precompiled QuickJS libs in the mentioned folders don't give any positive result:

--with-cc-opt="-I/usr/include/quickjs/" --with-ld-opt="-L/usr/lib/quickjs/"

Please provide an instruction how to successfully compile njs supporting QuickJS as a static nginx module!

@xeioex
Copy link
Contributor

xeioex commented Oct 17, 2024

Hi @woxxo,

checking for tries to compile a certain C file, please, make sure you are using the recent QuickJS library. The last released version is not enough. For details check <NJS_SRC_ROOT_DIR>/build/autoconf.err.

I am going to improve the reporting to make this process more transparent.

@woxxo
Copy link
Author

woxxo commented Oct 17, 2024

After setting PREFIX?=/usr and make && make install for the recent Quickjs downloaded direct from the github repo, the ./configure log has changed:

configuring additional modules
adding module in /home/opt/src/njs-master/nginx
checking for QuickJS library -lquickjs.lto ... not found
checking for QuickJS library -lquickjs ... not found
checking for QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs.lto ... not found
checking for QuickJS library -I/usr/include/quickjs/ -L/usr/lib/quickjs/ -lquickjs ... found
checking for QuickJS JS_NewTypedArray() ... found
 enabled QuickJS engine
 enabled webcrypto module
 enabled xml module
 enabled zlib module
 + ngx_js_module was configured

And the resulting nginx executable got +5 Mb in size. I guess the QuickJS library was linked.

But there is another problem now:

nginx: [emerg] invalid value "qjs" in .......conf:5
server {
    js_path ".....";
    js_import main from .....;
    js_import ......;
    js_engine qjs;           <---- line 5

With the line 5 commented out everything works fine, as well as with js_engine njs; set explicitly. How to setup js_engine to use QuickJS in the config file?

@xeioex
Copy link
Contributor

xeioex commented Oct 17, 2024

Hmm, it is controlled by the same define, which is defined here. Adding -DNJS_HAVE_QUICKJS=1 to --with-cc-opt= should fix this. But we need to find why it does not propagate.

@woxxo
Copy link
Author

woxxo commented Oct 17, 2024

Ok, it is working now, js_engine can be changed as expected! Thank you!

@woxxo woxxo closed this as completed Oct 17, 2024
xeioex added a commit to xeioex/njs that referenced this issue Oct 23, 2024
Add explicit testing for JS_GetClassID() function since it is not available
in older QuickJS versions.

This closes nginx#801 issue on Github.
xeioex added a commit that referenced this issue Oct 23, 2024
Add explicit testing for JS_GetClassID() function since it is not available
in older QuickJS versions.

This closes #801 issue on Github.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants