2

llvm の clang を使用して CPython 3.2 をビルドしようとしています。gcc で問題なくビルドできます。Linux Mint 12 を使用しています。

コンパイルは、./python バイナリの生成を試みる最後までうまくいくようです。私が得るエラーは次のとおりです。

clang -pthread   -Xlinker -export-dynamic -o python Modules/python.o libpython3.2m.a -lpthread -ldl  -lutil   -lm
/usr/bin/ld: error: libpython3.2m.a: malformed archive header name at 8
./Modules/python.c:25: error: undefined reference to 'PyMem_Malloc'
./Modules/python.c:27: error: undefined reference to 'PyMem_Malloc'
./Modules/python.c:51: error: undefined reference to '_Py_char2wchar'
./Modules/python.c:59: error: undefined reference to 'Py_Main'
./Modules/python.c:61: error: undefined reference to 'PyMem_Free'
./Modules/python.c:63: error: undefined reference to 'PyMem_Free'
./Modules/python.c:64: error: undefined reference to 'PyMem_Free'
clang: error: linker command failed with exit code 1 (use -v to see invocation)

私は、信頼できる Linux Mint 12 .deb リポジトリにある llvm 2.9 と、今日から llvm の SVN トランクを試しましたが、どちらも同じエラーが発生します。

リンクに /usr/bin/ld の代わりに llvm-link を使用するように clang を説得できれば、おそらくうまくいくと思いますが、それを行う方法についてのドキュメントには何もありません。$LD を llvm-link に設定するだけでは役に立たないようです。

これらの未定義の参照はおそらくニシンです: nm -o libpython3.2m.a (または llvm-nm -o libpython3.2m.a - 両方が機能する) 場合、これらのシンボルの少なくとも 1 つが実際に定義されていることがわかります (もちろん nm に - 他のツールはおそらく他のアイデアを持っている可能性があり、そうする可能性が高いです)。

最終的には、ELF バイナリではなく llvm ビットコードを生成したいのですが、最初に llvm を使用して動作する Python ELF バイナリを取得することは、満足のいくミニマイルストーンです。

私は現在、コンパイルのために以下を使用しています:

export PATH=/usr/local/llvm/bin:$PATH
prefix=/usr/local/p3ib-3.2
export CC='clang'
export AR='llvm-ar'
export LD='llvm-link -emit-llvm-bc'
export RANLIB='llvm-ranlib'
./configure --prefix="$prefix" && make -j 3

ありがとう!

4

0 に答える 0