当前位置: 首页 > 工具软件 > greenlet > 使用案例 >

greenlet模块在linux安装,Python的greenlet和gevent在Linux x86_64上對於PowerPC的交叉編譯...

仲阳朔
2023-12-01

在我的Linux x86_64主機上,我想爲我的PowerPC目標交叉編譯一些額外的Python模塊,具體來說就是greenlet,gevent,gevent-websockets。目前,我只是試圖交叉構建greenlet模塊。Python的greenlet和gevent在Linux x86_64上對於PowerPC的交叉編譯

使用信息從這個站點:使用此設置爲我的編譯環境

# Undo variables for cross-compile environment

unset ROOT

unset SDKDIR

unset KLIBDIR

unset NFSDIR

unset CONFIG

unset CONFIGURED

unset ARCH

unset OS

unset TOOLCHAIN_BASE

unset TOOLCHAIN_BIN

unset CROSS_COMPILE

unset c

unset KERNEL_DIR

unset AS

unset LD

unset CC

unset AR

unset STRIP

unset SSTRIP

unset OBJCOPY

unset OBJDUMP

unset MAKE

unset CFLAGS

# Set cross-compile variables:

export TOOLCHAIN=/opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-

export CC=${TOOLCHAIN}gcc

export CXX=${TOOLCHAIN}g++

export AR=${TOOLCHAIN}ar

export RANLIB=${TOOLCHAIN}ranlib

export BLDSHARED="${TOOLCHAIN}gcc -shared"

export LDSHARED="${TOOLCHAIN}gcc -shared"

export RFS="../../ltib/rootfs"

export CFLAGS="-save-temps -Wall -I${RFS}/usr/include -I${RFS}/include/python2.7 -L${RFS}/usr/lib -L${RFS}/lib"

export LDFLAGS="-I${RFS}/usr/include -I${RFS}/include/python2.7 -L${RFS}/usr/lib -L${RFS}/lib"

export CROSS_COMPILE=ppc-linux

export CROSS_COMPILE_TARGET=yes

export HOSTARCH=ppc-linux

export BUILDARCH=x86_64-linux-gnu

我能交叉編譯的Python 2.7.2與上面的配置我的環境腳本,然後嘗試構建greenlet模塊產量:

$ python ./setup.py build

running build

running build_ext

building 'greenlet' extension

creating build

creating build/temp.linux-x86_64-2.7

/opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc -I../../../ltib/rootfs/usr/include -L../../../ltib/rootfs/usr/lib -L../../../ltib/rootfs/lib -fPIC -I/usr/include/python2.7 -c greenlet.c -o build/temp.linux-x86_64-2.7/greenlet.o

In file included from /usr/include/python2.7/Python.h:58,

from greenlet.h:8,

from greenlet.c:5:

/usr/include/python2.7/pyport.h:849:2: error: #error "LONG_BIT definition appears wrong for platform (bad gcc/glibc config?)."

error: command '/opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc' failed with exit status 1

爲什麼setup.py從我的主機系統上的/usr/include/python2.7中提取?我無法在我的目標上找到那個目標。我如何爲我的目標創建它?

有什麼建議嗎?

謝謝!

特雷弗

更新#1:

我對目標的根文件系統的我的主機的複製相對引用是不正確的。糾正它並重新運行良率:

$ python ./setup.py build

running build

running build_ext

building 'greenlet' extension

creating build

creating build/temp.linux-x86_64-2.7

/opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc -save-temps -Wall -I../../ltib/rootfs/usr/include -I../../ltib/rootfs/include/python2.7 -L../../ltib/rootfs/usr/lib -L../../ltib/rootfs/lib -fPIC -I/usr/include/python2.7 -c greenlet.c -o build/temp.linux-x86_64-2.7/greenlet.o

greenlet.s: Assembler messages:

greenlet.s:832: Error: syntax error; found `(' but expected `,'

greenlet.s:832: Error: junk at end of line: `(31),1'

error: command '/opt/freescale/usr/local/gcc-4.3.74-eglibc-2.8.74-dp-2/powerpc-none-linux-gnuspe/bin/powerpc-none-linux-gnuspe-gcc' failed with exit status 1

至少它是找到更多我的目標的包含庫,但現在我真的難倒了! :(

任何建議

感謝

更新#2:?!

通過添加-save-temps標誌編譯器(上更新錯誤),我才得以保全,並檢查中間的彙編代碼在上面的錯誤信息中提到,虛線包括:

#APP

# 52 "platform/switch_ppc_linux.h" 1

mr 8(31), 1

# 0 "" 2

MR(移動寄存器)op是公平的簡單,只接受2個參數(mr to-reg, from-reg)。我不知道如何添加附加寄存器編號的括號。 FWIW,這裏是上述頭文件中引用的宏:

#define STACK_REFPLUS 1

#ifdef SLP_EVAL

#define STACK_MAGIC 3

/* !!!!WARNING!!!! need to add "r31" in the next line if this header file

* is meant to be compiled non-dynamically!

*/

#define REGS_TO_SAVE "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20", \

"r21", "r22", "r23", "r24", "r25", "r26", "r27", "r28", "r29", \

"cr2", "cr3", "cr4"

static int

slp_switch(void)

{

register int *stackref, stsizediff;

__asm__ volatile ("" : : : REGS_TO_SAVE);

__asm__ ("mr %0, 1" : "=g" (stackref) :);

{

SLP_SAVE_STATE(stackref, stsizediff);

__asm__ volatile (

"mr 11, %0\n"

"add 1, 1, 11\n"

"add 30, 30, 11\n"

: /* no outputs */

: "g" (stsizediff)

: "11"

);

SLP_RESTORE_STATE();

}

__asm__ volatile ("" : : : REGS_TO_SAVE);

return 0;

}

#endif

我開始懷疑,如果這是在編譯器中的錯誤,因爲宏似乎很簡單!有什麼建議麼? ... 謝謝!

2012-07-20

Trevor

+0

鑑於該博客文章的評論似乎意味着人們甚至沒有獲得目標Python來導入標準庫模塊,指令不適用於第三方模塊也不足爲奇...... –

2012-07-20 22:26:17

+1

這不是問題所在(標題問題?),我可能會遺漏一些東西,但是您沒有指定PPC而不是ARM工具鏈? –

2012-07-20 22:27:03

+0

@TiloWiklund:很好。他從中複製的博客是關於ARM和PPC的交叉編譯,他似乎抄襲了錯誤的博客。這實際上並不能解釋他的問題,因爲如果他使用了ARM工具鏈,情況會完全相同。但這意味着他在嘗試爲它構建擴展之前,還沒有嘗試過對其構建的Python進行最低限度的測試。 –

2012-07-20 22:30:29

 类似资料: