clang-2.9 crt1 未找到错误

发布于 2024-11-01 03:34:33 字数 2277 浏览 5 评论 0原文

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

crt1.o: No such file: No such file or directory

LLVM 配置为默认 + --enable-shared。具有相同选项的 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)

同样的错误在这里 http://permalink.gmane.org/gmane .comp.compilers.clang.devel/12101http://comments.gmane.org/gmane.comp.compilers .clang.devel/14269http://permalink .gmane.org/gmane.comp.compilers.llvm.bugs/11352

与 llvm-2.8 比较时我可以学到什么——新版本尝试自行组装文件,旧版本调用 gcc 进行组装和链接步骤。

请,这不是 clang 链接器问题<​​/a> 的重复,因为我无法编辑 LLVM 的源,所以接受的解决方案是对我没用。

Just compiled clang-2.9 release and it can't link an hello world example. There is the error:

crt1.o: No such file: No such file or directory

LLVM is configured as default + --enable-shared. The llvm-2.8 build with same options works normally on the same machine.

$ 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)

The same error was here http://permalink.gmane.org/gmane.comp.compilers.clang.devel/12101
and http://comments.gmane.org/gmane.comp.compilers.clang.devel/14269 and http://permalink.gmane.org/gmane.comp.compilers.llvm.bugs/11352

What I can learn while comparing with llvm-2.8 -- newer version tries to assemble file itself, and older version calls gcc to do assemble and link steps.

Please, this is not a duplicate of clang linker problem as I can't edit sources of LLVM, so the accepted solution isn't useful to me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只有一腔孤勇 2024-11-08 03:34:33

正如 http://permalink.gmane.org/gmane.comp 所建议的那样。 compilers.llvm.bugs/11352(llvm bug 8897)这是因为

gcc used to build clang is not in a standard location

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"};

两种情况都适合我的安装。

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

这对我有帮助。

As suggested at http://permalink.gmane.org/gmane.comp.compilers.llvm.bugs/11352 (llvm bug 8897) this is because

gcc used to build clang is not in a standard location

or

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"};

Both cases are true for my installation.

To fix this, I'll try to add my version of gcc into list GccVersions[].

This helps me.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文