大网数据广告活动
服务器运维问答

linux binary strip error when using pip install: Not enough room for program headers, try linking with -N

· 52CE 我爱测

When using strip on certain object files in Amazon Linux, it errors with: $ sudo strip dfitpack.so BFD: st6qqyd2: Not enough room for program headers, try linking with -N strip:st6qqyd2[.note.gnu.build-id]: Bad value The object f…

问题原文

原帖链接 · Emmet Murphy · CC BY-SA 3.0

When using strip on certain object files in Amazon Linux, it errors with: $ sudo strip dfitpack.so BFD: st6qqyd2: Not enough room for program headers, try linking with -N strip:st6qqyd2[.note.gnu.build-id]: Bad value

The object files are created by pip install, packages including numpy, sklearn, pandas, xgboost, numexpr. What we are trying to do is strip down the code and object files to fit within an AWS Lambda 250MB limit.

A google search finds references to binutils on GNU mailing lists, but most tips are intended for developers building their own code, and to making changes in header files and the like. I suspect there is a build configuration change I can make when running pip install, and am hoping that someone with a better understanding of binutils can help.

Specs: $ uname -a Linux ... 4.4.5-15.26.amzn1.x86_64 #1 SMP Wed Mar 16 17:15:34 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux $ yum info binutils ... Version : 2.23.52.0.1 Release : 55.65.amzn1 ...

已采纳解答

原帖链接 · Monica For CEO · CC BY-SA 3.0

Some pip packages (or their dependencies) download binaries instead of downloading sources and building on the local machine, and there can be issues when running strip on a binary built in a different environment. To download sources and build on the local machine, try:

CFLAGS='-O0' pip install --no-binary :all: PACKAGE

See pip documentation at https://pip.pypa.io/en/stable/reference/pip_install/#install-no-binary

There was a discussion of this issue in the context of building Debian packages at https://github.com/spotify/dh-virtualenv/issues/150

Note that some binaries might not build with optimization flags, hence setting CFLAGS to disable optimization flags, see: https://stackoverflow.com/questions/16149613/installing-lxml-with-pip-in-virtualenv-ubuntu-12-10-error-command-gcc-failed

Also note that it can take a long time to build all dependencies from source, so if you have the time to sort through which packages have issues, and which do not, and you want to speed up the build, you could try some variation of this recipe to install only some packages from source and with varying levels of optimization:

CFLAGS='-O0' pip install --no-binary :all: PACKAGE
pip install --no-binary :all: PACKAGE
pip install PACKAGE

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-05-03)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。