llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.09k stars 11.6k forks source link

Since Clang 19 `-mllvm --x86-asm-syntax=intel` seems to affect inline assembly syntax in source #109157

Open lhmouse opened 5 days ago

lhmouse commented 5 days ago

Hello,

I personally use Clang to translate x86 assembly between AT&T syntax and Intel syntax. Clang 18- can compile AT&T syntax to Intel syntax, as in

$ echo '__asm__("mov $1, %eax");'  \
  | clang -x c -  -mllvm --x86-asm-syntax=intel -O2 -S -o -  \
  | grep mov
        mov     eax, 1

but Clang 19 fails to parse the source. It seems to expect Intel syntax:

$ echo '__asm__("mov $1, %eax");' |  \
  | ./llvm-mingw-20240917-ucrt-x86_64/bin/clang -x c -  -mllvm --x86-asm-syntax=intel -O2 -S -o -  \
  | grep mov
<inline asm>:1:5: error: unknown token in expression

@MaskRay Do you have any idea whether this has something to do with #85367 ?

llvmbot commented 5 days ago

@llvm/issue-subscribers-clang-driver

Author: LIU Hao (lhmouse)

Hello, I personally use Clang to translate x86 assembly between AT&T syntax and Intel syntax. Clang 18- can compile AT&T syntax to Intel syntax, as in ``` $ echo '__asm__("mov $1, %eax");' \ | clang -x c - -mllvm --x86-asm-syntax=intel -O2 -S -o - \ | grep mov mov eax, 1 ``` but Clang 19 fails to parse the source. It seems to expect Intel syntax: ``` $ echo '__asm__("mov $1, %eax");' | \ | ./llvm-mingw-20240917-ucrt-x86_64/bin/clang -x c - -mllvm --x86-asm-syntax=intel -O2 -S -o - \ | grep mov <inline asm>:1:5: error: unknown token in expression ``` @MaskRay Do you have any idea whether this has something to do with #85367 ?
MaskRay commented 3 days ago

Created #109360 to allow AT&T input and Intel output using: echo 'asm("mov $1, %eax");' | clang -xc - -S -o - -Xclang --output-asm-variant=1.

-x86-asm-syntax=intel is for input assembly used for tools like llvm-mc, not Clang. echo 'asm("mov $1, %eax");' | clang -x c - -mllvm --x86-asm-syntax=intel -S -o -, which achieves a similar goal before Clang 19, was unintended.

@MaskRay Do you have any idea whether this has something to do with https://github.com/llvm/llvm-project/pull/85367 ?

85367 does make this unintended feature unavailable.

lhmouse commented 3 days ago

I appreciate your comment.