中村です。
llvm の Cフロントエンド clang で LLVM をバックエンドに指定して
コンパイルできないようです。
解決方法はありますが、全てをすぐに対応するのは大変そうなので
とりあえずbts に入れておきました。
$ clang sample.c
/usr/bin/ld: cannot find crtbegin.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s
clang: error: linker command failed with exit code 1 (use -v to see invocation)
また、llvmのビルド中にもメール末尾 (*1) に添付したようなテストの
エラーが起こっています。
原因のひとつはこれです。
Bug 9798 - Linker flags fail / can't find crtbegin.o
http://llvm.org/bugs/show_bug.cgi?id=9798
こちらは、libgcc のサーチパスを追加する添付のパッチで対応できます。
ただ、これでは clang でバックエンドに llvm を使った場合に
コンパイルできない問題が残り対応としては不十分です。
$ clang sample.c
$ clang -emit-llvm sample.c
/tmp/cc-QzzmdA.o: file not recognized: File format not recognized
clang: error: linker command failed with exit code 1 (use -v to see invocation)
これは以下の問題になります。
Bug 9897 - "File format not recognized" when compiling with -O4
http://llvm.org/bugs/show_bug.cgi?id=9897
この解決としては次の 3つの対応が必要となります。
1. binutils を gold とプラグインを有効にしてビルドし直す
--enable-gold=both と --enable-plugins を追加
2. llvm で gold pulgin を有効にする
-with-binutils-include=%{_includedir} --enable-pic を追加
3. llvm で ld.gold を使うように変更
メール末尾 (*2) に添付のパッチ
このうち、1については Vine 6の開発時点で binutils での gold サポートを
保留とした背景があります。
VineSeedでツールチェーンを更新するタイミングで gold も有効にして LLVM
側も修正を入れたいと思います。
--------------------------------
(*1) llvm-2.9-1vl7ビルド時のログ(抜粋)
--- Running clang tests for x86_64-unknown-linux-gnu ---
lit.py: lit.cfg:143: note: using clang: '/home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/Release/bin/clang'
-- Testing: 2918 tests, 4 threads --
Testing: 0 .. 10.. 20.. 30.. 40
FAIL: Clang :: Driver/hello.c (1287 of 2918)
******************** TEST 'Clang :: Driver/hello.c' FAILED ********************
Script:
--
/home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/Release/bin/clang -ccc-echo -o /home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test/Driver/Output/hello.c.tmp.exe /home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test/Driver/hello.c 2> /home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test/Driver/Output/hello.c.tmp.log
grep 'clang\(-[0-9.]\+\)\?\(\.[Ee][Xx][Ee]\)\?" -cc1 .*hello.c' /home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test/Driver/Output/hello.c.tmp.log
/home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test/Driver/Output/hello.c.tmp.exe > /home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test/Driver/Output/hello.c.tmp.out
grep "I'm a little driver, short and stout." /home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test/Driver/Output/hello.c.tmp.out
--
Exit Code: 1
********************
Testing: 0 .. 10.. 20.. 30.. 40.. 50.. 60.. 70.. 80.. 90..
Testing Time: 31.54s
********************
Failing Tests (1):
Clang :: Driver/hello.c
Expected Passes : 2895
Expected Failures : 22
Unexpected Failures: 1
make: *** [all] Error 1
make: Leaving directory `/home/kenta/work/VineLinux/rpm/BUILD/llvm-2.9/tools/clang/test'
+ exit 0
Processing files: llvm-2.9-1vl7.x86_64
--------------------------------
(*2) clang で明示的に ld.gold を選択するパッチ(x86_64の場合)
--- llvm-2.9/tools/clang/lib/Driver/ToolChains.cpp 2011-08-27 15:21:31.892964808 +0900
+++ llvm-2.9/tools/clang/lib/Driver/ToolChains.cpp 2011-08-27 15:51:30.858967386 +0900
@@ -1487,7 +1493,7 @@
if (!llvm::sys::fs::exists(LinkerPath.str(), Exists) && Exists)
Linker = LinkerPath.str();
else
- Linker = GetProgramPath("ld");
+ Linker = GetProgramPath("ld.gold");
LinuxDistro Distro = DetectLinuxDistro(Arch);
--- llvm-2.9/tools/clang/lib/Driver/Tools.cpp 2011-08-28 18:42:57.183510696 +0900
+++ llvm-2.9/tools/clang/lib/Driver/Tools.cpp 2011-08-28 18:28:14.370510067 +0900
@@ -3731,7 +3731,7 @@
if (Args.hasArg(options::OPT_use_gold_plugin)) {
CmdArgs.push_back("-plugin");
- std::string Plugin = ToolChain.getDriver().Dir + "/../lib/LLVMgold.so";
+ std::string Plugin = ToolChain.getDriver().Dir + "/../lib64/llvm/LLVMgold.so";
CmdArgs.push_back(Args.MakeArgString(Plugin));
}
==================================================
NAKAMURA Kenta / 中村健太
Mail: kenta@xxxxxxxxxxxxx
==================================================
Attachment:
llvm-fix9798.patch
Description: Binary data
_______________________________________________ VineSeed mailing list VineSeed@xxxxxxxxxxxxx http://lists.vinelinux.org/mailman/listinfo/vineseed