使用无GCC的汇编LLVM/Clang

发布于 2025-01-27 18:50:06 字数 961 浏览 1 评论 0原文

我一直在尝试从源和使用此脚本)。我正在使用GCC 11.2编译clang,该11.2本身也是由源构建的,因此位于我的系统(/scratch/opt/GCC-ML-11.2)上的非默认位置中。请注意,它仅与启用Multilib编译的GCC一起使用。

问题在于,我可以使用编译clangclang ++二进制文件,如果我提供GCC位置如下:-GCC-ToolChain =/scratch/opt /GCC-ML-11.2.0。如果没有该标志,我会遇到链接器错误:

clang test.c -o test
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s

我不明白为什么一个clang汇编的二进制文件需要针对某种GCC库链接,以及为什么Clang不提供crtbegins.o文件。

我还尝试使用LLVM链接器以及用于C ++测试应用程序的LLVM标准库,即,“ - FUSE-LD = lld = lld -stdlib = libc ++ 。这也没有帮助

。 Just 导出CXXFLAGS = -GCC-ToolChain =/scratch/opt/opt/gcc-ml-11.2.0,我不确定这是否是正确的方法。没有GCC安装的功能

? 文件还需要GCC -Toolchain标志。

二进制 GCC

非常感谢您的帮助

! maxbit

I have been trying to compile LLVM/clang from source, both by myself and using this script. I am compiling clang using gcc 11.2, which itself was also built from source, and hence resides in a non-default location on my system (/scratch/opt/gcc-ml-11.2). Note that it only works with a gcc that was compiled with multilib enabled.

The problem is that I can use the compiled clang and clang++ binaries only if I supply the gcc location as follows: --gcc-toolchain=/scratch/opt/gcc-ml-11.2.0. Without that flag, I run into linker errors:

clang test.c -o test
/usr/bin/ld: cannot find crtbeginS.o: No such file or directory
/usr/bin/ld: cannot find -lgcc
/usr/bin/ld: cannot find -lgcc_s

I do not understand why a clang compiled binary needs to link against some kind of gcc library and why clang does not supply the crtbeginS.O file.

I have also tried using the LLVM linker as well as the LLVM standard library for C++ test applications, i.e., "-fuse-ld=lld -stdlib=libc++. This did not help either.

While I could just export CXXFLAGS=--gcc-toolchain=/scratch/opt/gcc-ml-11.2.0, I am not sure whether this is the right approach. Shouldn't clang/LLVM be able to function without a gcc installation?

I have also tried using my clang installation with the --gcc-toolchain=/scratch/opt/gcc-ml-11.2.0 flag to compile clang again, but the new binary also requires the gcc-toolchain flag.

Should I just globally export the path to my gcc toolchain? Why is this necessary? Isn't clang a standalone compiler that - if supplied with the option to use its own standard library - does not require gcc?

Thank you very much for your help!

Best,
Maxbit

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文