1

I am attempting to package the Python module cx_Freeze for OpenWrt. I have written the Makefile (included below) and am comfortable with how it works and what I've defined (it's my understanding that Build/Compile/PyMod will effectively run setup.py with the toolchain's compiler setup).

When trying to build cx_Freeze (as part of the usual make world job), it fails when linking to python2.7 claiming that there are undefined references __isnan, __isinf, __finite, and __rawmemchr. I have included the full error listing below.

I have cleaned the buildroot, and gone as far as recompiling the entire toolchain. I have also tried multiple architectures (specifically x86 and brcm2708), only to get the same error. I have no problems building any other Python package - it seems the differentiator is cx_Freeze attempting to link against Python itself.

Switching the C library to glibc works, however I would like to support the default C library, musl, as well.

Please let me know if I can provide any more information about the host system or any additional context around the problem.

Makefile

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))

Linker error output:

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

Versions of software:

  • OpenWrt 17.01.4
  • cx_Freeze 5.1.1
  • Python 2.7
  • Build OS: CentOS 7.4 in VirtualBox

Installed packages on the CentOS 7 build VM:

  • Development Tools package group
  • gcc-c++
  • git
  • ncurses-devel
  • perl
  • perl-Thread-Queue
  • python
  • unzip
  • wget
  • xz
  • zlib-devel
  • zlib-static
user2583109
  • 185
  • 4
  • 12

0 Answers0