0

我的 Debian 系统上同时安装了 clang 和 gcc。我想尝试clang并给出以下命令。从输出来看,clang 似乎使用了更多的 gcc,而不仅仅是前端。在编译这个简单的程序时,如何确认 clang 确实使用了 llvm-as、llvm-ld 和其他 llvm 命令?我已经安装了大部分 llvm-* 命令。感谢您提供任何信息。

clang -v c.c
Debian clang version 3.0-6 (tags/RELEASE_30/final) (based on LLVM 3.0)
Target: x86_64-pc-linux-gnu
Thread model: posix
"/usr/bin/clang" -cc1 -triple x86_64-pc-linux-gnu -emit-obj -mrelax-all -disable-free
-disable-llvm-verifier -main-file-name c.c -mrelocation-model static -mdisable-fp-elim 
-masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -target-linker-
version 2.22 -momit-leaf-frame-pointer -v -resource-dir /usr/bin/../lib/clang/3.0 
-fmodule-cache-path /var/tmp/clang-module-cache -internal-isystem /usr/local/include 
-internal-isystem /usr/bin/../lib/clang/3.0/include -internal-externc-isystem 
/usr/include/x86_64-linux-gnu -internal-externc-isystem /usr/include -ferror-limit 19 
-fmessage-length 198 -fgnu-runtime -fobjc-runtime-has-arc -fobjc-runtime-has-weak 
-fobjc-fragile-abi -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/c-MLrq5I.o -x 
c c.c
clang -cc1 version 3.0 based upon llvm 3.0 hosted on x86_64-pc-linux-gnu
ignoring nonexistent directory "/usr/bin/../lib/clang/3.0/include"
ignoring nonexistent directory "/usr/bin/../lib/clang/3.0/include"
ignoring duplicate directory "/usr/local/include"
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
ignoring duplicate directory "/usr/include/x86_64-linux-gnu"
ignoring duplicate directory "/usr/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/include/x86_64-linux-gnu
/usr/include
/usr/include/clang/3.0/include/
/usr/lib/gcc/x86_64-linux-gnu/4.6/include/
/usr/lib/gcc/x86_64-linux-gnu/4.6/include-fixed/
End of search list.
"/usr/bin/ld" --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 
-o a.out /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crt1.o /usr/lib
/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crti.o /usr/lib/gcc/x86_64-linux-
gnu/4.6/crtbegin.o -L/usr/lib/gcc/x86_64-linux-gnu/4.6 -L/usr/lib/gcc/x86_64-linux-
gnu/4.6/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr
/lib/x86_64-linux-gnu -L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu 
-L/usr/lib/gcc/x86_64-linux-gnu/4.6/../../.. -L/lib/x86_64-linux-gnu -L/lib -L/usr
/lib/x86_64-linux-gnu -L/usr/lib /tmp/c-MLrq5I.o -lgcc --as-needed -lgcc_s --no-as-
needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/x86_64-linux-gnu/4.6
/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/crtn.o
4

1 回答 1

0

您可以传递-###给 clang 以查看它调用的所有程序。在大多数系统上,clang 直接链接到汇编程序库并在 cc1 进程中在进程内调用它,而不是向外部as程序发送。

于 2013-02-12T21:08:03.363 回答