#1043 detect_lua_version in configure script for cross compilation
Reporter
Ilja
Owner
Zash
Created
Updated
Stars
★ (1)
Tags
Status-Fixed
Component-Scripts
Priority-Medium
Type-Defect
Milestone-0.10
Ilja
on
There is a problem when detect_lua_version function in configure script tries execute cross-compiled lua binary to obtain a version.
Zash
on
Then what happens?
Changes
owner Zash
tags Component-Scripts Status-NeedInfo
Ilja
on
detect_lua_version detects lua version of the host system, but not the target system. Traget system lua binary can't be executed on the host, so we can't properly obtain lua version of the target system and configure script fails.
Zash
on
The lua binary is not required for building.
One or more of --lua-version --lua-suffix and --runwith may be needed to bypass the detection.
Ilja
on
OK, let's look at configure script
There is a block:
lua_interp_found=no
if [ "$LUA_SUFFIX_SET" != "yes" ]
then
if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ]
then
suffixes="5.1 51 -5.1 -51"
elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.2" ]
then
suffixes="5.2 52 -5.2 -52"
elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.3" ]
then
suffixes="5.3 53 -5.3 -53"
else
suffixes="5.1 51 -5.1 -51 5.2 52 -5.2 -52 5.3 53 -5.3 -53"
fi
for suffix in "" `echo $suffixes`
do
search_interpreter "$suffix" && {
lua_interp_found=yes
break
}
done
else
search_interpreter "$LUA_SUFFIX" && {
lua_interp_found=yes
}
fi
Function search_interpreter will be executed in any case, it's listing:
search_interpreter() {
suffix="$1"
if [ "$LUA_BINDIR_SET" = "yes" ]
then
find_lua="$LUA_BINDIR"
elif [ "$LUA_DIR_SET" = "yes" ]
then
LUA_BINDIR="$LUA_DIR/bin"
if [ -f "$LUA_BINDIR/lua$suffix" ]
then
find_lua="$LUA_BINDIR"
fi
else
find_lua=`find_program lua$suffix`
fi
if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ]
then
if detect_lua_version "$find_lua/lua$suffix"
then
echo "Lua interpreter found: $find_lua/lua$suffix..."
if [ "$LUA_BINDIR_SET" != "yes" ]
then
LUA_BINDIR="$find_lua"
fi
if [ "$LUA_DIR_SET" != "yes" ]
then
LUA_DIR=`dirname "$find_lua"`
fi
LUA_SUFFIX="$suffix"
return 0
fi
fi
return 1
}
Let's say I'll pass some of the variables through script options as you said, but it does not cancel detect_lua_version execution for the successful script completion.
detect_lua_version() {
detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null`
if [ "$detected_lua" != "nil" ]
then
if [ "$LUA_VERSION_SET" != "yes" ]
then
echo "Lua version detected: $detected_lua"
LUA_VERSION=$detected_lua
return 0
elif [ "$LUA_VERSION" = "$detected_lua" ]
then
return 0
fi
fi
return 1
}
The first string:
detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null`
Here variable $1 contains a path to target system lua binary. It can't be executed on the host system and we can not to successfully check version of the target system lua binary, and script fails.
Zash
on
What version are you using?
I'm unable to reproduce a configure script failure after https://hg.prosody.im/0.10/rev/eb38f3b919be
With an armhf lua5.1 installed:
$ lua5.1
bash: /usr/bin/lua5.1: cannot execute binary file: Exec format error
$ ./configure --lua-version=5.1 --lua-suffix=5.1 --runwith=lua5.1
Checking Lua includes... lua.h found in /usr/include/lua5.1/lua.h (Debian/Ubuntu)
Writing configuration...
Installation prefix: /usr/local
Prosody configuration directory: /usr/local/etc/prosody
Using Lua from: /usr
Done. You can now run 'make' to build.
Zash
on
Haven't heard anything in a while, assuming it was fixed. Poke if otherwise.
There is a problem when detect_lua_version function in configure script tries execute cross-compiled lua binary to obtain a version.
Then what happens?
Changesdetect_lua_version detects lua version of the host system, but not the target system. Traget system lua binary can't be executed on the host, so we can't properly obtain lua version of the target system and configure script fails.
The lua binary is not required for building. One or more of --lua-version --lua-suffix and --runwith may be needed to bypass the detection.
OK, let's look at configure script There is a block: lua_interp_found=no if [ "$LUA_SUFFIX_SET" != "yes" ] then if [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.1" ] then suffixes="5.1 51 -5.1 -51" elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.2" ] then suffixes="5.2 52 -5.2 -52" elif [ "$LUA_VERSION_SET" = "yes" -a "$LUA_VERSION" = "5.3" ] then suffixes="5.3 53 -5.3 -53" else suffixes="5.1 51 -5.1 -51 5.2 52 -5.2 -52 5.3 53 -5.3 -53" fi for suffix in "" `echo $suffixes` do search_interpreter "$suffix" && { lua_interp_found=yes break } done else search_interpreter "$LUA_SUFFIX" && { lua_interp_found=yes } fi Function search_interpreter will be executed in any case, it's listing: search_interpreter() { suffix="$1" if [ "$LUA_BINDIR_SET" = "yes" ] then find_lua="$LUA_BINDIR" elif [ "$LUA_DIR_SET" = "yes" ] then LUA_BINDIR="$LUA_DIR/bin" if [ -f "$LUA_BINDIR/lua$suffix" ] then find_lua="$LUA_BINDIR" fi else find_lua=`find_program lua$suffix` fi if [ -n "$find_lua" -a -x "$find_lua/lua$suffix" ] then if detect_lua_version "$find_lua/lua$suffix" then echo "Lua interpreter found: $find_lua/lua$suffix..." if [ "$LUA_BINDIR_SET" != "yes" ] then LUA_BINDIR="$find_lua" fi if [ "$LUA_DIR_SET" != "yes" ] then LUA_DIR=`dirname "$find_lua"` fi LUA_SUFFIX="$suffix" return 0 fi fi return 1 } Let's say I'll pass some of the variables through script options as you said, but it does not cancel detect_lua_version execution for the successful script completion. detect_lua_version() { detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null` if [ "$detected_lua" != "nil" ] then if [ "$LUA_VERSION_SET" != "yes" ] then echo "Lua version detected: $detected_lua" LUA_VERSION=$detected_lua return 0 elif [ "$LUA_VERSION" = "$detected_lua" ] then return 0 fi fi return 1 } The first string: detected_lua=`$1 -e 'print(_VERSION:match(" (5%.[123])$"))' 2> /dev/null` Here variable $1 contains a path to target system lua binary. It can't be executed on the host system and we can not to successfully check version of the target system lua binary, and script fails.
What version are you using? I'm unable to reproduce a configure script failure after https://hg.prosody.im/0.10/rev/eb38f3b919be With an armhf lua5.1 installed: $ lua5.1 bash: /usr/bin/lua5.1: cannot execute binary file: Exec format error $ ./configure --lua-version=5.1 --lua-suffix=5.1 --runwith=lua5.1 Checking Lua includes... lua.h found in /usr/include/lua5.1/lua.h (Debian/Ubuntu) Writing configuration... Installation prefix: /usr/local Prosody configuration directory: /usr/local/etc/prosody Using Lua from: /usr Done. You can now run 'make' to build.
Haven't heard anything in a while, assuming it was fixed. Poke if otherwise.
Changes