As this question shows, with g++, I can do g++ -S -masm=intel test.cpp
.
Also, with clang, I can do clang++ -S test.cpp
, but -masm=intel
is not supported by clang (warning argument unused during compilation: -masm=intel
). How do I get intel syntax with clang?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
This should get clang to emit assembly code with Intel syntax:
clang++ -S -mllvm --x86-asm-syntax=intel test.cpp
You can use -mllvm <arg>
to pass in llvm options from the clang command line. Sadly this option doesn't appear to be well documented, and thus I only found it by browsing through the llvm mailing lists.
As noted below by @thakis, this is no longer needed in newer versions of Clang (3.5+) as it now support the -masm=intel
syntax.
回答2:
As of clang r208683 (clang 3.5+), it understands -masm=intel
. So if your clang is new enough, you can just use that.
回答3:
Presuming you can have Clang emit normal LLVM byte codes, you can then use llc to compile to assembly language, and use its --x86-asm-syntax=intel
option to get the result in Intel syntax.