1

我正在尝试为 OpenWrt 打包 Python 模块cx_Freeze。我已经编写了 Makefile(包括在下面),并且对它的工作方式和我定义的内容感到满意(我的理解Build/Compile/PyMod将有效地setup.py与工具链的编译器设置一起运行)。

尝试构建 cx_Freeze (作为常规make world工作的一部分)时,链接到python2.7声称存在未定义的引用__isnan__isinf__finite__rawmemchr. 我在下面列出了完整的错误列表。

我已经清理了 buildroot,并重新编译了整个工具链。我还尝试了多种架构(特别是 x86 和 brcm2708),只是得到了同样的错误。我在构建任何其他 Python 包时没有问题 - 似乎区别在于 cx_Freeze 试图链接 Python 本身。

将 C 库切换到 glibc 是可行的,但是我也想支持默认的 C 库 musl。

如果我可以提供有关主机系统的更多信息或围绕该问题的任何其他上下文,请告诉我。

生成文件

include $(TOPDIR)/rules.mk

PKG_NAME:=cx_Freeze
PKG_VERSION:=5.1.1
PKG_RELEASE:=1
PKG_LICENSE:=PSF

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://pypi.python.org/packages/5f/16/eab51d6571dfec2554248cb027c51babd04d97f594ab6359e0707361297d/
PKG_HASH:=2eadddde670f5c5f6cf88638a0ac4e5d5fe181292a31063275fa56c7bf22426b

PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
PKG_BUILD_DEPENDS:=python

include $(INCLUDE_DIR)/package.mk
$(call include_mk, python-package.mk)

define Package/python-cx_Freeze
    SUBMENU:=Python
    SECTION:=lang
    CATEGORY:=Languages
    TITLE:=cx_Freeze
    URL:=https://github.com/anthony-tuininga/cx_Freeze
    DEPENDS:=+python
endef

define Package/python-cx_Freeze/description
    cx_Freeze is a set of scripts and modules for freezing Python scripts into executables, in much the same way that py2exe and py2app do.
endef

define Build/Compile
    $(call Build/Compile/PyMod,,install --prefix=/usr --root=$(PKG_INSTALL_DIR))
endef

define Package/python-cx_Freeze/install
    $(INSTALL_DIR) $(1)$(PYTHON_PKG_DIR)
    $(INSTALL_DIR) $(1)/usr/bin
    $(CP) \
        $(PKG_INSTALL_DIR)$(PYTHON_PKG_DIR)/* \
        $(1)$(PYTHON_PKG_DIR)/
    $(CP) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
endef

$(eval $(call BuildPackage,python-cx_Freeze))

链接器错误输出:

running build_ext
building 'cx_Freeze.util' extension
creating build/temp.linux2-2.7
creating build/temp.linux2-2.7/source
x86_64-openwrt-linux-musl-gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap /home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/cx_Freeze-5.1.1:cx_Freeze-5.1.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/include -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/usr/include -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/include/fortify -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/include -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include/python2.7 -fPIC -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include/python2.7 -c source/util.c -o build/temp.linux2-2.7/source/util.o
x86_64-openwrt-linux-musl-gcc -shared -L/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/lib -L/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/lib -L/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/usr/lib -L/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/lib -znow -zrelro -lpython2.7 -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap /home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/cx_Freeze-5.1.1:cx_Freeze-5.1.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/include -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/usr/include -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/include/fortify -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/include -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include/python2.7 build/temp.linux2-2.7/source/util.o -o build/lib.linux2-2.7/cx_Freeze/util.so
creating build/temp.linux2-2.7/source/bases
x86_64-openwrt-linux-musl-gcc -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -pipe -fno-caller-saves -fno-plt -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result -iremap /home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/cx_Freeze-5.1.1:cx_Freeze-5.1.1 -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/include -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/usr/include -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/include/fortify -I/home/vagrant/workspace/staging_dir/toolchain-x86_64_gcc-5.4.0_musl-1.1.16/include -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include/python2.7 -fPIC -I/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/usr/include/python2.7 -c source/bases/Console.c -o build/temp.linux2-2.7/source/bases/Console.o
creating build/lib.linux2-2.7/cx_Freeze/bases
x86_64-openwrt-linux-musl-gcc build/temp.linux2-2.7/source/bases/Console.o -L/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config -lpython2.7 -o build/lib.linux2-2.7/cx_Freeze/bases/Console -Xlinker -export-dynamic -lpthread -ldl -lutil -lm -lz -s
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_richcompare':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:431: undefined reference to `__finite'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_is_integer':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:992: undefined reference to `__finite'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:992: undefined reference to `__finite'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_as_integer_ratio':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:1731: undefined reference to `__isinf'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:1737: undefined reference to `__isnan'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_hex':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:1383: undefined reference to `__isnan'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:1383: undefined reference to `__isinf'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `float_pow':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:837: undefined reference to `__isnan'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:840: undefined reference to `__isnan'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:843: undefined reference to `__isinf'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:858: undefined reference to `__isinf'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(floatobject.o): In function `_PyFloat_Pack4':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:2396: undefined reference to `__isinff'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/floatobject.c:2396: undefined reference to `__isinf'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(longobject.o): In function `PyLong_FromDouble':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/longobject.c:178: undefined reference to `__isinf'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/longobject.c:183: undefined reference to `__isnan'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(object.o): In function `_Py_HashDouble':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/object.c:1033: undefined reference to `__finite'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/object.c:1034: undefined reference to `__isinf'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(sysmodule.o): In function `makepathobject':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Python/sysmodule.c:1552: undefined reference to `__rawmemchr'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(posixmodule.o): In function `posix_tmpnam':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/./Modules/posixmodule.c:7614: undefined reference to `tmpnam_r'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(tokenizer.o): In function `tok_nextc':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Parser/tokenizer.c:1000: undefined reference to `__rawmemchr'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Parser/tokenizer.c:953: undefined reference to `__rawmemchr'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Parser/tokenizer.c:927: undefined reference to `__rawmemchr'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Parser/tokenizer.c:870: undefined reference to `__rawmemchr'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(complexobject.o): In function `_Py_c_abs':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:196: undefined reference to `__finite'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:196: undefined reference to `__finite'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:200: undefined reference to `__isinf'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:205: undefined reference to `__isinf'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:215: undefined reference to `__finite'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:196: undefined reference to `__finite'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:196: undefined reference to `__finite'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:200: undefined reference to `__isinf'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:205: undefined reference to `__isinf'
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Objects/complexobject.c:215: undefined reference to `__finite'
/home/vagrant/workspace/staging_dir/target-x86_64_musl-1.1.16/host/lib/python2.7/config/libpython2.7.a(bltinmodule.o): In function `builtin_round':
/home/vagrant/workspace/build_dir/target-x86_64_musl-1.1.16/host/Python-2.7.13/Python/bltinmodule.c:2198: undefined reference to `__finite'
collect2: error: ld returned 1 exit status
error: command 'x86_64-openwrt-linux-musl-gcc' failed with exit status 1

软件版本:

  • OpenWrt 17.01.4
  • cx_Freeze 5.1.1
  • 蟒蛇 2.7
  • 构建操作系统:VirtualBox 中的 CentOS 7.4

在 CentOS 7 构建 VM 上安装的软件包:

  • 开发工具包组
  • gcc-c++
  • 混帐
  • ncurses-开发
  • perl
  • perl-线程队列
  • Python
  • 解压
  • wget
  • xz
  • zlib-开发
  • zlib-静态
4

0 回答 0