[compiler-rt] f445be9 - Reland "[compiler-rt][aarch64] Add SME ABI support routines." (#68875)

Stephan Bergmann via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 17 05:36:06 PDT 2023


On 10/17/23 12:10, Sander De Smalen wrote:
> Hi Stephan, can you share a reproducer?

Kind of.  This originally happened for me when building the python 
interpreter executable as part of building LibreOffice, but I'm not sure 
what a minimal C source code would look like that would trigger this 
issue.  It apparently needs to link in the init_aarch64_has_sme 
constructor from compiler-rt/lib/builtins/aarch64/sme-abi-init.c, which 
in turn apparently happens when calling e.g. __arm_sme_state from 
compiler-rt/lib/builtins/aarch64/sme-abi.S (a call to which would in 
turn be generated by AArch64TargetLowering::getPStateSM in 
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp, but I didn't bother to 
track down further how to get that triggered with a small C reproducer 
program).

So a minimal reproducer I came up with on macOS is

> $ cat test.c
> void _arm_sme_state();
> int main() { _arm_sme_state(); }

> $ ~/llvm/inst/bin/clang test.c -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.0.sdk
> ld: Undefined symbols:
>   ___aarch64_sme_accessible, referenced from:
>       _init_aarch64_has_sme in libclang_rt.osx.a[arm64][153](sme-abi-init.c.o)
> clang: error: linker command failed with exit code 1 (use -v to see invocation)

(There's probably a cleaner way to defeat the macOS C function name 
mangling that turns the given _arm_sme_state into the __arm_sme_state 
symbol that we're after, but I didn't bother to search for that (an 
__attribute__ maybe?), and just hacked around it this way.)



More information about the llvm-commits mailing list