Compiling newlib fails

Hi,

I am trying to use clang to compile newlib for aarch64 on X86_64. I have succesfully compiled clang and llvm-tools for AArch64 target.
Now when I try to compile newlib it fails for:

…/…/…/newlib-cygwin/newlib/libc/machine/aarch64/memchr.S:113:10: error: invalid operand for instruction
mov x6, v6.2d[0]
^
…/…/…/newlib-cygwin/newlib/libc/machine/aarch64/memchr.S:133:10: error: invalid operand for instruction
mov x6, v6.2d[0]
^
…/…/…/newlib-cygwin/newlib/libc/machine/aarch64/memchr.S:143:10: error: invalid operand for instruction
mov x6, v6.2d[0]

It complains on the second operand of the instruction. But I’ve checked with ARM manual it looks like it’s a valid neon instruction.
Why is my clang cannot compile this file? I’ve tried compiling it with gcc, and it working in gcc

binutils regards mov x6, v6.d[0] as the canonical form for that, and LLVM only accepts that form. Reading the Arm ARM, MOV takes a size specifier (i.e. B/H/S/D) not an arrangement specifier (count plus size specifier), so it seems dodgy that binutils accepts the alternative form, and newlib shouldn’t be using something non-standard like that; looks like it needs to update to a newer version of the code it vendors (see string: Use .d rather than .2d for element mov instructions · ARM-software/optimized-routines@4f4e530 · GitHub).

I think I ran into the same issue a while ago.
This is the changes I made to a copy of newlib from a few years ago to make it build with clang: Fix gas-specific AArch64 assembly syntax in newlib (HEAD version) · ARM-software/LLVM-embedded-toolchain-for-Arm@91e8a03 · GitHub.
I never found the time to try and upstream this change to the newlib project.

Hi,

Yes, there are known syntax differences, GitHub - ARM-software/LLVM-embedded-toolchain-for-Arm: A project dedicated to building LLVM toolchain for 32-bit Arm embedded targets. maintains a patch as https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/blob/main/patches/newlib.patch Note that it is for newlib 4.1.0

As of last week, we published a dev drop which includes experimental pre-built newlib multilib variants Release preview-18.0.0-devdrop0 · ARM-software/LLVM-embedded-toolchain-for-Arm · GitHub - see the dev drop description for usage instructions. Please report any feedback to Issues · ARM-software/LLVM-embedded-toolchain-for-Arm · GitHub, if you give it a try.