[cfe-dev] Aarch64 ASM quirk

Peter Smith via cfe-dev cfe-dev at lists.llvm.org
Fri Nov 8 02:03:35 PST 2019


Hello Joel,

The root cause is that the AArch64 target is using ';' as a comment
character, whereas in GNU as (and many other llvm MC backends),  the
';' is used as a statement separator. In your example only the text up
to ';' is being parsed.

Looking at AArch64MCAsmInfo.cpp
  SeparatorString = "%%";
  CommentString = ";";

I think that this is likely to have been derived from Darwin as I
can't get the "%%" to work as a statement separator for
aarch64-linux-gnu targets.

Is this intentional? Probably, as the initial implementation is likely
to have come from Darwin. Is it a bug? At least for linux targets it
is a difference from GNU which documents ";" as the statement
separator https://sourceware.org/binutils/docs/as/AArch64_002dChars.html#AArch64_002dChars
, Is it fixable? I don't know, changing the separator to ';' even for
non darwin targets could break code that has only been assembled with
clang, yet only used ';' as a comment character.

Feel free to raise a PR if you have a strong opinion. Alternatively,
always use a newline for statement separator to be compatible with
both GNU and LLVM.

Peter


On Thu, 7 Nov 2019 at 23:53, Joel Winarske via cfe-dev
<cfe-dev at lists.llvm.org> wrote:
>
> I'm running Clang 9.0.0 on Windows, with target aarch64-unknown-windows.  I get the same error building on Linux.  Code below.
>
> The difference is a CR/LF.  The original builds fine with GCC.
>
> By design, or bug?
>
>
> Joel
>
>
> ### Code ###
>
> .global MyFunc ; .section ".text.My Func" ; .type My Func, %function ; MyFunc:
>
>  # do something really important
>   ret
>
> .global MyFunSize
>
> MyFunSize
>   .long . - MyFunc
>
>
> ### Error ###
>
> error: symbol 'My Func' can not be undefined in a subtraction expression
>   .long . - MyFunc
>             ^
>
> ### Resolution ###
>
> global MyFunc; .section ".text.MyFunc" .type MyFunc, %function;
> My Func:
>
>   # do something really important
>   ret
>
> .global MyFuncSize
>
> MyFuncSize
>   .long . - MyFunc
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev



More information about the cfe-dev mailing list