1
1
ngx_lua_opt_I=
2
2
ngx_lua_opt_L=
3
+ luajit_ld_opt=
3
4
4
5
if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
5
6
# explicitly set LuaJIT paths
@@ -30,6 +31,7 @@ if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
30
31
ngx_feature_path="$LUAJIT_INC"
31
32
ngx_lua_opt_I="-I$LUAJIT_INC"
32
33
ngx_lua_opt_L="-L$LUAJIT_LIB"
34
+ luajit_ld_opt="-lm -ldl"
33
35
34
36
# ensure that -I$LUAJIT_INC and -L$LUAJIT_LIB come first
35
37
SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
@@ -38,9 +40,9 @@ if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
38
40
NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
39
41
40
42
if [ $NGX_RPATH = YES ]; then
41
- ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm -ldl "
43
+ ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt "
42
44
else
43
- ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm -ldl "
45
+ ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt "
44
46
fi
45
47
46
48
. auto/feature
@@ -55,6 +57,7 @@ if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
55
57
ngx_feature_path="$LUAJIT_INC"
56
58
ngx_lua_opt_I="-I$LUAJIT_INC"
57
59
ngx_lua_opt_L="-L$LUAJIT_LIB"
60
+ luajit_ld_opt="-lm"
58
61
59
62
# ensure that -I$LUAJIT_INC and -L$LUAJIT_LIB come first
60
63
SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
@@ -63,9 +66,9 @@ if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
63
66
NGX_TEST_LD_OPT="$ngx_lua_opt_L $NGX_TEST_LD_OPT"
64
67
65
68
if [ $NGX_RPATH = YES ]; then
66
- ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm "
69
+ ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt "
67
70
else
68
- ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm "
71
+ ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 $luajit_ld_opt "
69
72
fi
70
73
71
74
. auto/feature
88
91
case "$NGX_MACHINE" in
89
92
amd64 | x86_64 | i386)
90
93
echo "adding extra linking options needed by LuaJIT on $NGX_MACHINE"
94
+ luajit_ld_opt="$luajit_ld_opt -pagezero_size 10000 -image_base 100000000"
91
95
ngx_feature_libs="$ngx_feature_libs -pagezero_size 10000 -image_base 100000000"
92
96
;;
93
97
105
109
# FreeBSD with luajit-2.0 from ports collection
106
110
ngx_feature="LuaJIT library in /usr/local/"
107
111
ngx_feature_path="/usr/local/include/luajit-2.0"
112
+ luajit_ld_opt="-lm"
113
+ LUAJIT_LIB="/usr/local/lib"
108
114
if [ $NGX_RPATH = YES ]; then
109
115
ngx_feature_libs="-R/usr/local/lib -L/usr/local/lib -lluajit-5.1 -lm"
110
116
else
117
123
# Gentoo with LuaJIT-2.0, try with -ldl
118
124
ngx_feature="LuaJIT library in /usr/"
119
125
ngx_feature_path="/usr/include/luajit-2.0"
126
+ luajit_ld_opt="-lm -ldl"
127
+ LUAJIT_LIB="/usr/lib"
120
128
if [ $NGX_RPATH = YES ]; then
121
129
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1 -ldl"
122
130
else
129
137
# Gentoo with LuaJIT 2.0
130
138
ngx_feature="LuaJIT library in /usr/"
131
139
ngx_feature_path="/usr/include/luajit-2.0"
140
+ luajit_ld_opt="-lm"
141
+ LUAJIT_LIB="/usr/lib"
132
142
if [ $NGX_RPATH = YES ]; then
133
143
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1"
134
144
else
159
169
# ----------------------------------------
160
170
161
171
ngx_feature="LuaJIT 2.x"
162
- ngx_feature_name=
163
172
ngx_feature_run=no
164
173
ngx_feature_incs="#include <luajit.h>"
165
- ngx_feature_path=
166
174
ngx_feature_test='#if !defined(LUAJIT_VERSION_NUM) || (LUAJIT_VERSION_NUM < 20000)
167
175
# error unsupported LuaJIT version
168
176
#endif'
169
- SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
170
- CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
171
177
172
178
. auto/feature
173
179
@@ -178,22 +184,17 @@ END
178
184
exit 1
179
185
fi
180
186
181
- CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
182
-
183
187
# ----------------------------------------
184
188
185
189
ngx_feature="LuaJIT has FFI"
186
- ngx_feature_name=
190
+ ngx_feature_libs="$LUAJIT_LIB/libluajit-5.1.a $luajit_ld_opt"
187
191
ngx_feature_run=yes
188
192
ngx_feature_incs="#include <lualib.h>
189
193
#include <lauxlib.h>
190
194
#include <assert.h>"
191
- ngx_feature_path=
192
- ngx_feature_test='lua_State *L = luaL_newstate();
195
+ ngx_feature_test="lua_State *L = luaL_newstate();
193
196
assert(L != NULL);
194
- luaopen_ffi(L);'
195
- SAVED_CC_TEST_FLAGS="$CC_TEST_FLAGS"
196
- CC_TEST_FLAGS="$ngx_lua_opt_I $CC_TEST_FLAGS"
197
+ luaopen_ffi(L);"
197
198
198
199
. auto/feature
199
200
204
205
exit 1
205
206
fi
206
207
207
- CC_TEST_FLAGS="$SAVED_CC_TEST_FLAGS"
208
-
209
208
# ----------------------------------------
210
209
211
210
ngx_addon_name=ngx_http_lua_module
468
467
469
468
# ----------------------------------------
470
469
471
- if [ $PCRE != NO -a $PCRE != YES ]; then
472
- # force pcre_version symbol to be undefined when PCRE is statically linked
473
- ngx_feature="force undefined symbols (--undefined)"
474
- ngx_feature_libs="-Wl,--undefined=printf"
475
- ngx_feature_name=
476
- ngx_feature_run=no
477
- ngx_feature_incs="#include <stdio.h>"
478
- ngx_feature_path=
479
- ngx_feature_test='printf("hello");'
470
+ if [ $USE_PCRE = YES -o $PCRE != NONE ] && [ $PCRE != NO -a $PCRE != YES ]; then
471
+ # force pcre_version symbol to be required when PCRE is statically linked
472
+ case "$NGX_PLATFORM" in
473
+ Darwin:*)
474
+ ngx_feature="require defined symbols (-u)"
475
+ ngx_feature_name=
476
+ ngx_feature_path=
477
+ ngx_feature_libs="-Wl,-u,_strerror"
478
+ ngx_feature_run=no
479
+ ngx_feature_incs="#include <stdio.h>"
480
+ ngx_feature_test='printf("hello");'
480
481
481
- . auto/feature
482
+ . auto/feature
482
483
483
- if [ $ngx_found = yes ]; then
484
- CORE_LIBS="$CORE_LIBS -Wl,--undefined=pcre_version"
485
- fi
484
+ if [ $ngx_found = yes ]; then
485
+ CORE_LIBS="-Wl,-u,_pcre_version $CORE_LIBS"
486
+ fi
487
+ ;;
486
488
487
- # for LLVM ld (Darwin )
488
- ngx_feature="force undefined symbols (-all_load -U )"
489
- ngx_feature_libs="-all_load -U printf"
490
- ngx_feature_name =
491
- ngx_feature_run=no
492
- ngx_feature_incs="#include <stdio.h>"
493
- ngx_feature_path=
494
- ngx_feature_test='printf("hello");'
489
+ * )
490
+ ngx_feature="require defined symbols (--require-defined )"
491
+ ngx_feature_name=
492
+ ngx_feature_path =
493
+ ngx_feature_libs="-Wl,--require-defined=strerror"
494
+ ngx_feature_run=no
495
+ ngx_feature_incs="#include <stdio.h>"
496
+ ngx_feature_test='printf("hello");'
495
497
496
- . auto/feature
498
+ . auto/feature
497
499
498
- if [ $ngx_found = yes ]; then
499
- CORE_LIBS="$CORE_LIBS -all_load -U pcre_version"
500
- fi
500
+ if [ $ngx_found = yes ]; then
501
+ CORE_LIBS="-Wl,--require-defined=pcre_version $CORE_LIBS"
502
+ fi
503
+ ;;
504
+ esac
501
505
fi
502
506
503
507
# ----------------------------------------
0 commit comments