This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cross building extensions picks up host headers
Type: compile error Stage: resolved
Components: Cross-Build Versions: Python 3.5, Python 2.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: setup.py: do not add system header locations when cross compiling
View: 20211
Assigned To: Nosy List: Alex.Willmer, doko, hundeboll
Priority: normal Keywords: patch

Created on 2016-02-26 15:19 by hundeboll, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
include-dirs.patch hundeboll, 2016-02-26 15:19 remove addition of host dirs to include dirs when building extensions
Messages (3)
msg260894 - (view) Author: Martin Hundebøll (hundeboll) Date: 2016-02-26 15:19
When cross building python, the building of extensions is called with -I/usr/include and -L/usr/lib

This makes some extensions fail to compile due to picking up inline assembly from host headers (e.g. _socket[1]).

I have fixed this locally by applying the attached patch, but I cannot tell if that would make other builds fail.

[1] log output:
building '_socket' extension
arm-cortexa9neon-linux-gnueabi-gcc -fPIC -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/stage/machine/usr/lib/libffi-3.2.1/include -O2 -fexpensive-optimizations -fomit-frame-pointer -frename-registers -Werror=declaration-after-statement -I./Include -I/usr/include -I. -IInclude -I/home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/stage/cross/bin/../arm-cortexa9neon-linux-gnueabi/sysroot/usr/include -I/home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/src/Python-3.5.1/Include -I/home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/src/Python-3.5.1 -c /home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/src/Python-3.5.1/Modules/socketmodule.c -o build/temp.linux-arm-3.5/home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/src/Python-3.5.1/Modules/socketmodule.o
In file included from /usr/include/bits/byteswap.h:35:0,
                 from /usr/include/endian.h:60,
                 from /usr/include/bits/string2.h:51,
                 from /usr/include/string.h:635,
                 from ./Include/Python.h:30,
                 from /home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/src/Python-3.5.1/Modules/socketmodule.c:95:
/home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/src/Python-3.5.1/Modules/socketmodule.c: In function 'socket_getservbyport':
/usr/include/bits/byteswap-16.h:31:5: error: invalid 'asm': invalid operand for code 'w'
     __asm__ ("rorw $8, %w0"           \
     ^
/usr/include/netinet/in.h:403:21: note: in expansion of macro '__bswap_16'
 #   define htons(x) __bswap_16 (x)
                     ^
/home/mnhu/projects/pil/oe/tmp/work/machine/arm-cortexa9neon-linux-gnueabi/python-3.5.1/src/Python-3.5.1/Modules/socketmodule.c:4861:24: note: in expansion of macro 'htons'
     sp = getservbyport(htons((short)port), proto);
                        ^
msg261094 - (view) Author: Alex Willmer (Alex.Willmer) * Date: 2016-03-02 00:33
This looks like a duplicate of #20211, and IMO the patch there is more correct.
msg261434 - (view) Author: Martin Hundebøll (hundeboll) Date: 2016-03-09 15:11
Yes, it is a duplicate of #20211, and I agree with the fix proposed in there.

Thanks for pointing it out.
History
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70630
2016-03-09 15:22:33berker.peksagsetsuperseder: setup.py: do not add system header locations when cross compiling
stage: resolved
2016-03-09 15:11:29hundebollsetstatus: open -> closed
resolution: duplicate
messages: + msg261434
2016-03-02 00:33:17Alex.Willmersetmessages: + msg261094
2016-03-02 00:22:30Alex.Willmersetnosy: + Alex.Willmer
2016-02-28 06:33:19ned.deilysetnosy: + doko
2016-02-26 15:19:33hundebollcreate