Skip to content

Commit f67aefc

Browse files
committed
bugfix: we might miss the linker option -ldl when we shouldn't.
1 parent 91ff51f commit f67aefc

File tree

1 file changed

+34
-17
lines changed

1 file changed

+34
-17
lines changed

config

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,31 @@ ngx_lua_opt_I=
1212
ngx_lua_opt_L=
1313

1414
if [ -n "$LUAJIT_INC" -o -n "$LUAJIT_LIB" ]; then
15-
# explicitly set Lua lib path
16-
ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env)"
15+
# explicitly set LuaJIT paths
16+
17+
# attempt to link with -ldl, static linking on Linux requires it.
18+
ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl)"
1719
ngx_feature_path="$LUAJIT_INC"
1820
ngx_lua_opt_I="-I$LUAJIT_INC"
1921
ngx_lua_opt_L="-L$LUAJIT_LIB"
2022
if [ $NGX_RPATH = YES ]; then
21-
ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm"
23+
ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm -ldl"
2224
else
23-
ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm"
25+
ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm -ldl"
2426
fi
2527

2628
. auto/feature
2729

2830
if [ $ngx_found = no ]; then
29-
# retry with -ldl, static linking on Linux requires it.
30-
ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env, with -ldl)"
31+
# retry without -ldl
32+
ngx_feature="LuaJIT library in $LUAJIT_LIB and $LUAJIT_INC (specified by the LUAJIT_LIB and LUAJIT_INC env)"
3133
ngx_feature_path="$LUAJIT_INC"
3234
ngx_lua_opt_I="-I$LUAJIT_INC"
3335
ngx_lua_opt_L="-L$LUAJIT_LIB"
3436
if [ $NGX_RPATH = YES ]; then
35-
ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm -ldl"
37+
ngx_feature_libs="-R$LUAJIT_LIB $ngx_lua_opt_L -lluajit-5.1 -lm"
3638
else
37-
ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm -ldl"
39+
ngx_feature_libs="$ngx_lua_opt_L -lluajit-5.1 -lm"
3840
fi
3941

4042
. auto/feature
@@ -65,19 +67,34 @@ END
6567
esac
6668
else
6769
if [ -n "$LUA_INC" -o -n "$LUA_LIB" ]; then
68-
# explicitly set Lua lib path
70+
# explicitly set Lua paths
6971
ngx_feature="Lua library in $LUA_LIB and $LUA_INC (specified by the LUA_LIB and LUA_INC env)"
7072
ngx_feature_path="$LUA_INC"
7173
ngx_lua_opt_I="-I$LUA_INC"
7274
ngx_lua_opt_L="-L$LUA_LIB"
7375
if [ $NGX_RPATH = YES ]; then
74-
ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm"
76+
ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm -ldl"
7577
else
76-
ngx_feature_libs="$ngx_lua_opt_L -llua -lm"
78+
ngx_feature_libs="$ngx_lua_opt_L -llua -lm -ldl"
7779
fi
7880

7981
. auto/feature
8082

83+
if [ $ngx_found = no ]; then
84+
# retry without -ldl
85+
86+
ngx_feature_path="$LUA_INC"
87+
ngx_lua_opt_I="-I$LUA_INC"
88+
ngx_lua_opt_L="-L$LUA_LIB"
89+
if [ $NGX_RPATH = YES ]; then
90+
ngx_feature_libs="-R$LUA_LIB $ngx_lua_opt_L -llua -lm"
91+
else
92+
ngx_feature_libs="$ngx_lua_opt_L -llua -lm"
93+
fi
94+
95+
. auto/feature
96+
fi
97+
8198
if [ $ngx_found = no ]; then
8299
cat << END
83100
$0: error: ngx_http_lua_module requires the Lua or LuaJIT library and LUA_LIB is defined as $LUA_LIB and LUA_INC (path for lua.h) is $LUA_INC, but we cannot find standard Lua there.
@@ -175,25 +192,25 @@ END
175192
fi
176193

177194
if [ $ngx_found = no ]; then
178-
# Gentoo with LuaJIT-2.0
195+
# Gentoo with LuaJIT-2.0, try with -ldl
179196
ngx_feature="LuaJIT library in /usr/"
180197
ngx_feature_path="/usr/include/luajit-2.0"
181198
if [ $NGX_RPATH = YES ]; then
182-
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1"
199+
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1 -ldl"
183200
else
184-
ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1"
201+
ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1 -ldl"
185202
fi
186203
. auto/feature
187204
fi
188205

189206
if [ $ngx_found = no ]; then
190-
# Gentoo with LuaJIT-2.0, retry with -ldl
207+
# Gentoo with LuaJIT 2.0
191208
ngx_feature="LuaJIT library in /usr/"
192209
ngx_feature_path="/usr/include/luajit-2.0"
193210
if [ $NGX_RPATH = YES ]; then
194-
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1 -ldl"
211+
ngx_feature_libs="-R/usr/lib -L/usr/lib -lm -lluajit-5.1"
195212
else
196-
ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1 -ldl"
213+
ngx_feature_libs="-L/usr/lib -lm -lluajit-5.1"
197214
fi
198215
. auto/feature
199216
fi

0 commit comments

Comments
 (0)