Aarch64 ASM quirk

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?



.global MyFunc ; .section “.text.My Func” ; .type My Func, %function ; MyFunc:

do something really important


.global MyFunSize

.long . - MyFunc


error: symbol ‘My Func’ can not be undefined in a subtraction expression
.long . - MyFunc


global MyFunc; .section “.text.MyFunc” .type MyFunc, %function;
My Func:

do something really important


.global MyFuncSize

.long . - MyFunc

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 AArch64-Chars (Using as)
, 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.


I don't know about the separator string, but if you look in AArch64MCAsmInfoELF (and AArch64MCAsmInfoGNUCOFF), the comment string is set to "//" instead.

I suggested changing this for the GNUCOFF (aka MinGW) target, as mingw-w64 contains a number of assembler files that uses this pattern of piling up a few directives on one line.

As there's very little predecent for GNU style .s assembler for aarch64-windows-msvc targets (as the official tool from microsoft, armasm64, uses a totally different syntax), I'm guess it would be fine to change the comment string to "//" there as well, as there apparently is a demand for it?

With a target that doesn't treat ";" as a comment char, your assembler example errors out due to issues with the section and type directives though, now that they actually are interpreted and not stripped out as comments.

// Martin

Ah yes, a comment…

Is there a seperator character that works?

I don't think that there is an alternative separator for the Windows
target as both the CommentString and SeparatorString are ";". I don't
have a strong opinion over changing the comment character for AArch64
Windows target. Probably best addressed by the people that use/develop
on it. It is true that armasm(64) uses ";" as its comment character,
but as Martin says many of the directives and other bits of syntax are
different so at least some form of scripted conversion is likely to be
needed anyway.


I added a Sed step. I double up the semicolon, and only convert for Clang aarch64-unkown-windows. Not ideal, but it works.

I’m onto lld-link problems now.

Thanks for all the input.