Llvm clang-2.9未找到crt1错误

Llvm clang-2.9未找到crt1错误,llvm,clang,llvm-clang,Llvm,Clang,Llvm Clang,刚刚编译了clang-2.9版本,它无法链接hello world示例。有一个错误: crt1.o: No such file: No such file or directory LLVM配置为默认+——启用共享。具有相同选项的llvm-2.8版本通常在同一台机器上工作 $ clang -v a.c clang version 2.9 (tags/RELEASE_29/final) Target: i386-pc-linux-gnu Thread model: posix "/root/b

刚刚编译了clang-2.9版本,它无法链接hello world示例。有一个错误:

crt1.o: No such file: No such file or directory
LLVM配置为默认+
——启用共享。具有相同选项的llvm-2.8版本通常在同一台机器上工作

$ clang -v a.c
clang version 2.9 (tags/RELEASE_29/final)
Target: i386-pc-linux-gnu
Thread model: posix
 "/root/bin/clang" -cc1 -triple i386-pc-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name a.c -mrelocation-model static -mdisable-fp-elim -masm-verbose -mconstructor-aliases -target-cpu pentium4 -target-linker-version 2.18 -momit-leaf-frame-pointer -v -resource-dir /root/lib/clang/2.9 -ferror-limit 19 -fmessage-length 157 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-2ueoYy.o -x c a.c
clang -cc1 version 2.9 based upon llvm 2.9 hosted on i386-pc-linux-gnu
ignoring nonexistent directory "/usr/local/include"
#include "..." search starts here:
#include <...> search starts here:
 /root/lib/clang/2.9/include
 /usr/include
End of search list.
a.c:1:1: warning: type specifier missing, defaults to 'int' [-Wimplicit-int]
main(){}
^~~~
1 warning generated.
 "/usr/bin/ld" --eh-frame-hdr -m elf_i386 -dynamic-linker /lib/ld-linux.so.2 -o a.out crt1.o crti.o crtbegin.o -L -L/../../.. /tmp/cc-2ueoYy.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed crtend.o crtn.o
/usr/bin/ld: crt1.o: No such file: No such file or directory
clang: error: linker command failed with exit code 1 (use -v to see invocation)
$clang-v a.c
clang版本2.9(标签/发行版\u 29/最终版)
目标:i386 pc linux gnu
线程模型:posix
“/root/bin/clang”-cc1-triple i386 pc linux gnu-emit obj-mrelax all-disable free-disable llvm verifier-main file name a.c-mrelocation model static-mdisable fp elim-masm verbose-mconstructor别名-target cpu pentium4-target linker version 2.18-momit叶帧指针-v-resource dir/root/lib/clang/2.9-feror limit 19-fmessage length 157-fgnu运行时-FDDiagnostics显示选项-fcolor diagnostics-o/tmp/cc-2ueoYy.o-x c a.c
clang-cc1 2.9版,基于托管在i386 pc linux gnu上的llvm 2.9
忽略不存在的目录“/usr/local/include”
#包括“…”搜索从这里开始:
#包括搜索从这里开始:
/root/lib/clang/2.9/include
/usr/包括
搜索列表结束。
a、 c:1:1:警告:缺少类型说明符,默认为“int”[-Wimplicit int]
main(){}
^~~~
生成1个警告。
“/usr/bin/ld”--eh frame hdr-m elf_i386-dynamic linker/lib/ld linux.so.2-o a.out crt1.o crti.o crtbegin.o-L-L/..//tmp/cc-2ueoYy.o-lgcc——按需——lgcc_s——不按需——lc-lgcc——按需——lgcc_s——不按需——crtend.o crtn.o
/usr/bin/ld:crt1.o:没有这样的文件:没有这样的文件或目录
叮当声:错误:链接器命令失败,退出代码为1(使用-v查看调用)
这里也有同样的错误 及

与llvm-2.8相比,我可以学到的是——较新版本尝试自行组装文件,而较旧版本调用gcc来执行组装和链接步骤

请注意,这不是的副本,因为我无法编辑LLVM的源代码,所以接受的解决方案对我没有用处。

如(LLVM bug 8897)所建议的,这是因为

gcc used to build clang is not in a standard location

这两种情况都适用于我的安装

为了解决这个问题,我将尝试将我的gcc版本添加到列表
GccVersions[]


这对我很有帮助。

@skeept,您尝试过答案中的解决方案吗?将您的gcc版本添加到GccVersions阵列。
system gcc is not listed in the ToolChains.cpp GccVersions list:

./tools/clang/lib/Driver/ToolChains.cpp:  const char* GccVersions[] = {"4.5.2", "4.5.1", "4.5", "4.4.5", "4.4.4",
./tools/clang/lib/Driver/ToolChains.cpp-                               "4.4.3", "4.4", "4.3.4", "4.3.3", "4.3.2",
./tools/clang/lib/Driver/ToolChains.cpp-                               "4.3", "4.2.4", "4.2.3", "4.2.2", "4.2.1",
./tools/clang/lib/Driver/ToolChains.cpp-                               "4.2"};