ngx_devel_kit

461 views
Skip to first unread message

Andrei Belov

unread,
Feb 22, 2016, 8:46:49 AM2/22/16
to Yichun Zhang (agentzh), openresty-en
Hi agentzh,

just wondering - is ngx_devel_kit still a prerequisite for lua-nginx-module, even after this commit:
https://github.com/openresty/lua-nginx-module/commit/4f2954302ce642a6f17255cff294663aa6552d8d

I realized that ngx-lua can be built flawlessly either as embedded (--add-module) module or as external shared object (--add-dynamic-module) - regardless of the ngx_devel_kit presence.

Could you please shed some light on this?

TIA!

Andrei Belov

unread,
Feb 22, 2016, 9:01:16 AM2/22/16
to openre...@googlegroups.com, Yichun Zhang (agentzh)
I also realized that in case when there is no ngx_devel_kit at ngx-lua compile time, the "set_by_lua" and "set_by_lua_file" directives will be unavailable.

I'm trying to understand whether it's possible to convert ngx_devel_kit to a dynamic module - but from what I see, it does not make sense due to compile-time dependency.

Am I wrong? Are there any other specifics I'm missing?

Thanks.

Yichun Zhang (agentzh)

unread,
Feb 24, 2016, 9:55:29 PM2/24/16
to Andrei Belov, openresty-en
Hello!

On Mon, Feb 22, 2016 at 6:01 AM, Andrei Belov wrote:
>
>
> I also realized that in case when there is no ngx_devel_kit at ngx-lua compile time, the "set_by_lua" and "set_by_lua_file" directives will be unavailable.
>

Yeah, these directives as well as the ndk.set_var.* Lua API depend on
NDK. These features are gone when you build ngx_lua without NDK.

> I'm trying to understand whether it's possible to convert ngx_devel_kit to a dynamic module - but from what I see, it does not make sense due to compile-time dependency.
>

Well, patches welcome :) I think it's technically possible.

BTW, you don't need to cc me when you post to the mailing list since
I'm also on the list.

Regards,
-agentzh

Andrei Belov

unread,
Feb 29, 2016, 1:37:31 PM2/29/16
to openre...@googlegroups.com

> On 25 Feb 2016, at 05:55, Yichun Zhang (agentzh) <age...@gmail.com> wrote:
>
> Hello!
>
> On Mon, Feb 22, 2016 at 6:01 AM, Andrei Belov wrote:
>>
>>
>> I also realized that in case when there is no ngx_devel_kit at ngx-lua compile time, the "set_by_lua" and "set_by_lua_file" directives will be unavailable.
>>
>
> Yeah, these directives as well as the ndk.set_var.* Lua API depend on
> NDK. These features are gone when you build ngx_lua without NDK.

Thanks for confirming this.


>
>> I'm trying to understand whether it's possible to convert ngx_devel_kit to a dynamic module - but from what I see, it does not make sense due to compile-time dependency.
>>
>
> Well, patches welcome :) I think it's technically possible.

I was able to build latest nginx with ngx_devel_kit and lua-nginx-module dynamically (both from current github heads) with the following patch:
https://github.com/simpl/ngx_devel_kit/pull/11

ndk_http_module.so provides enough set of needed symbols:

$ nm ndk_http_module.so | fgrep ndk_set
000000000000135b T ndk_set_var
000000000000181d t ndk_set_var_code
0000000000001330 T ndk_set_var_core
0000000000001450 t ndk_set_var_data_code
000000000000107d t ndk_set_var_filter_value
0000000000001378 t ndk_set_var_hash_code
000000000000176a T ndk_set_var_multi_value
00000000000019ca t ndk_set_var_multi_value_code
00000000000016e9 T ndk_set_var_multi_value_core
00000000000018ea t ndk_set_var_multi_value_data_code
0000000000000ef0 t ndk_set_var_name
00000000000017f0 T ndk_set_var_value
0000000000001b73 t ndk_set_var_value_code
000000000000178e T ndk_set_var_value_core
0000000000001aa4 t ndk_set_var_value_data_code
0000000000000ed0 t ndk_set_variable_value_space

so, ngx_http_lua_module.so includes "set_by_lua*" functions:

$ nm ngx_http_lua_module.so | fgrep set_by_lua
0000000000022eb6 T ngx_http_lua_filter_set_by_lua_file
0000000000022fbd T ngx_http_lua_filter_set_by_lua_inline
0000000000023170 T ngx_http_lua_set_by_lua
0000000000021f52 T ngx_http_lua_set_by_lua_block
0000000000023099 T ngx_http_lua_set_by_lua_file
0000000000022cde t ngx_http_lua_set_by_lua_init

I did it all successfully under CentOS 6.7. Previously, I spent some time trying to make it work under OS X (10.11.3) with luajit 2.0.4 from MacPorts, but had no luck due to extra flags introduced here:

https://github.com/openresty/lua-nginx-module/blob/master/config#L102

Disabling those flags allowed me to build .so objects without issues, but nginx was not able to start with the "failed to initialize Lua VM" error.

I suppose this is something you are aware of :) just shared my findings here.

Andrei Belov

unread,
Mar 1, 2016, 1:42:24 AM3/1/16
to openre...@googlegroups.com

> On 29 Feb 2016, at 21:37, Andrei Belov <de...@nginx.com> wrote:
>

[..]

> I did it all successfully under CentOS 6.7. Previously, I spent some time trying to make it work under OS X (10.11.3) with luajit 2.0.4 from MacPorts, but had no luck due to extra flags introduced here:
>
> https://github.com/openresty/lua-nginx-module/blob/master/config#L102

Just to clarify what I was talking about:

...
objs/addon/src/ngx_http_lua_ssl_certby.o \
objs/addon/src/ngx_http_lua_ssl_ocsp.o \
objs/addon/src/ngx_http_lua_lex.o \
objs/addon/src/ngx_http_lua_balancer.o \
objs/ngx_http_lua_module_modules.o \
-L/opt/local/lib -L/opt/local/lib -lluajit-5.1 -lm -ldl -pagezero_size 10000 -image_base 100000000 \
-shared -Wl,-undefined,dynamic_lookup
ld: -pagezero_size option can only be used when linking a main executable
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [objs/ngx_http_lua_module.so] Error 1
make: *** [build] Error 2

Yichun Zhang (agentzh)

unread,
Mar 2, 2016, 2:40:58 PM3/2/16
to openresty-en
Hello!

On Mon, Feb 29, 2016 at 10:37 AM, Andrei Belov wrote:
> I did it all successfully under CentOS 6.7. Previously, I spent some time trying to make it work under OS X (10.11.3) with luajit 2.0.4 from MacPorts, but had no luck due to extra flags introduced here:
>
> https://github.com/openresty/lua-nginx-module/blob/master/config#L102
>
> Disabling those flags allowed me to build .so objects without issues, but nginx was not able to start with the "failed to initialize Lua VM" error.
>

Oh, those flags need to be applied to the nginx executable linker
command instead of the so linker command for ngx_lua. Those flags are
required for Mac OS X. Patches welcome for ngx_lua's config file :)

Regards,
-agentzh
Reply all
Reply to author
Forward
0 new messages