gpt4 book ai didi

clang - clang 使用哪个汇编器?

转载 作者:行者123 更新时间:2023-12-03 08:53:33 34 4
gpt4 key购买 nike

我不清楚 clang 使用的汇编器。 AFAIK native 又名 GNU 汇编器和链接器被使用(与 gcc 一起提供)。

clang -v main.c
clang version 3.4.2
Target: x86_64-unknown-linux-gnu
Thread model: posix
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5.3
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.6.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.5.3
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6
Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/4.6.3
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5
"/usr/bin/clang-3.4" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -main-file-name main.c -mrelocation-model static -mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -target-cpu x86-64 -v -resource-dir /usr/bin/../lib/clang/3.4.2 -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/clang/3.4.2/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fdebug-compilation-dir /home/shrkamat/test/hello-c -ferror-limit 19 -fmessage-length 230 -mstackrealign -fobjc-runtime=gcc -fdiagnostics-show-option -vectorize-slp -o /tmp/main-18929a.o -x c main.c
clang -cc1 version 3.4.2 based upon LLVM 3.4.2 default target x86_64-unknown-linux-gnu
ignoring nonexistent directory "/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/bin/../lib/clang/3.4.2/include
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
"/usr/bin/ld" -z relro --hash-style=gnu --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o a.out /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.5 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/4.5/../../.. -L/lib -L/usr/lib /tmp/main-18929a.o -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/4.5/../../../x86_64-linux-gnu/crtn.o

我也看到了llvm-as,不太清楚它是否被使用。

which llvm-as
/usr/bin/llvm-as
root@e2cccbdeac09# llvm-as --version
LLVM (http://llvm.org/):
LLVM version 3.4.2
Optimized build.
Built Aug 8 2019 (08:55:24).
Default target: x86_64-unknown-linux-gnu
Host CPU: core-avx-i

我确实尝试使用 strace 来查看系统调用,以检查是否有为任何汇编器调用的 exec,但没有运气

grep -r exec trace.601*
trace.6016:execve("/usr/bin/clang", ["clang", "-v", "main.c"], [/* 12 vars */]) = 0
trace.6017:execve("/usr/bin/clang-3.4", ["/usr/bin/clang-3.4", "-cc1", "-triple", "x86_64-unknown-linux-gnu", "-emit-obj", "-mrelax-all", "-disable-free", "-disable-llvm-verifier", "-main-file-name", "main.c", "-mrelocation-model", "static", "-mdisable-fp-elim", "-fmath-errno", "-masm-verbose", "-mconstructor-aliases", ...], [/* 12 vars */]) = 0
trace.6018:execve("/usr/bin/ld", ["/usr/bin/ld", "-z", "relro", "--hash-style=gnu", "--build-id", "--eh-frame-hdr", "-m", "elf_x86_64", "-dynamic-linker", "/lib64/ld-linux-x86-64.so.2", "-o", "a.out", "/usr/bin/../lib/gcc/x86_64-linux"..., "/usr/bin/../lib/gcc/x86_64-linux"..., "/usr/bin/../lib/gcc/x86_64-linux"..., "-L/usr/bin/../lib/gcc/x86_64-lin"..., ...], [/* 12 vars */]) = 0

我可以将 GNU 汇编器 (/usr/bin/as) 与 clang 一起使用吗?

最佳答案

LLVM 有自己的汇编器,称为集成汇编器。它由多个库组成,并且没有面向用户的前端(嗯,有 llvm-mc,但它并不是真正的 as 替代品)。当传递 -filetype=obj 选项时,llc 实用程序可以调用集成汇编器。这也是您在跟踪 execve 调用时看不到任何汇编程序调用的原因。

Clang 有 -no-integrated-as 标志来关闭 LLVM 汇编器。

关于clang - clang 使用哪个汇编器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57425663/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com