This is an archive of the discontinued LLVM Phabricator instance.

lldb: Fix usage of sve functions on arm64
ClosedPublic

Authored by manojgupta on Apr 19 2023, 3:52 PM.

Details

Summary

Use correct internal sve functions for arm64.
Otherwise, when cross-compling lld for AArch64 there are build
errors like:
NativeRegisterContextLinux_arm64.cpp:936:11:

error: use of undeclared identifier 'sve_vl_valid

NativeRegisterContextLinux_arm64.cpp:63:28:

error: variable has incomplete type 'struct user_sve_header'

Diff Detail

Event Timeline

manojgupta created this revision.Apr 19 2023, 3:52 PM
manojgupta requested review of this revision.Apr 19 2023, 3:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2023, 3:52 PM

HI Manoj
Which linux distro are you using for your cross build? I am wondering which version of gcc (aarch64-linux-gnu) are you using for your cross compilation build.
I believe sve headers are not defined in older versions of gcc or its packaged sysroot causing cross compilation build to break.
All sve:: functions and defines are just a make shift arrangement to accommodate build environment which dont have SVE headers/functions defined.

I am building on ChromeOS. We only have headers from linux kernel 4.14 available in our build system (The actual running kernel could be a higher version).
But given these functions/struct definitions (sve::<foo>) are already available and used, why are they not used consistently?

e.g. https://source.chromium.org/chromium/external/github.com/llvm/llvm-project/+/main:lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp;l=99
already uses sve::vl_valid and there are uses of sve::user_sve_header as well.

Are there any objecttions? This patch is only making a consistent use of pre-existing and already in-use APIs/struct defintions.

DavidSpickett edited reviewers, added: omjavaid; removed: DavidSpickett.Apr 24 2023, 2:32 AM

I don't know enough to approve, Omair is the expert here.

I am building on ChromeOS. We only have headers from linux kernel 4.14 available in our build system (The actual running kernel could be a higher version).
But given these functions/struct definitions (sve::<foo>) are already available and used, why are they not used consistently?

e.g. https://source.chromium.org/chromium/external/github.com/llvm/llvm-project/+/main:lldb/source/Plugins/Process/elf-core/RegisterContextPOSIXCore_arm64.cpp;l=99
already uses sve::vl_valid and there are uses of sve::user_sve_header as well.

sve:: namespace introduced SVE helpers from linux headers into LLDB just to avoid the problems such as the one you encountered. The only issue here is that we actually dont want to keep multiple copies of sve headers for ever and want to make sure that every use-case can pull SVE headers from linux headers and we can eventually remove the LLDB copy of these headers.

I am approving this patch but be aware that we may consider removing all sve:: helpers from LLDB in future.

omjavaid accepted this revision.Apr 26 2023, 4:56 AM
This revision is now accepted and ready to land.Apr 26 2023, 4:56 AM
This revision was automatically updated to reflect the committed changes.

Thanks, regarding sve from Linux headers, LLVM currently supports building with GCC 7.1 or clang 5.0 and both were released in 2017. SVE support in Linux kernel believe was added in Linux kernel 4.19 timeframe iso maybe late 2018.
If SVE needs to be built from recent headers as a pre-requisite, then the Linux headers version requirement must also be added to llvm docs at https://llvm.org/docs/GettingStarted.html.