New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cmake] link atomic library for certain CPU architectures #21743
Conversation
https://bugs.gentoo.org/864421 |
CMakeLists.txt
Outdated
@@ -127,6 +127,9 @@ set(THREADS_PREFER_PTHREAD_FLAG ON) | |||
find_package(Threads REQUIRED QUIET) | |||
list(APPEND DEPLIBS ${CMAKE_THREAD_LIBS_INIT}) | |||
|
|||
# Atomics | |||
find_package(Atomics REQUIRED) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since this is linux and riscv/arm specific, this is not globally required. Instead move detection to https://github.com/xbmc/xbmc/blob/master/cmake/scripts/linux/ArchSetup.cmake and add atomics to PLATFORM_REQUIRED_DEPS only when needed
For those CPU architectures: RISC-V lack 8-bit and 16-bit atomic instructions, and ARM/MIPS/PPC lack 64-bit atomic instruction. GCC is supposed to convert these atomics via masking and shifting like LLVM, which means anything that wants to use these instructions needs the link option -latomic. In this patch, we will try to detect if 8-bit, 64-bit atomic instructions exist, otherwise the atomic library will append to the DEPLIBS list. Original issue: * https://gitlab.kitware.com/cmake/cmake/-/issues/23021#note_1098733 For reference: * https://gcc.gnu.org/wiki/Atomic/GCCMM riscv64 specific: * https://lists.debian.org/debian-riscv/2022/01/msg00009.html Signed-off-by: Yixun Lan <dlan@gentoo.org>
@wsnipex hi, how about this new version? is it ok to merge? or, I'd really appreciate if you can give some comments |
@wsnipex can you please review this updated PR? Thank you! |
Upstream: xbmc/xbmc#21743 Closes: https://bugs.gentoo.org/864421 Signed-off-by: Yixun Lan <dlan@gentoo.org> Closes: #27016 Signed-off-by: Jakov Smolić <jsmolic@gentoo.org>
Thanks for the PR. |
For those CPU architectures:
RISC-V lack 8-bit and 16-bit atomic instructions, and
ARM/MIPS/PPC lack 64-bit atomic instruction.
GCC is supposed to convert these atomics via masking and shifting
like LLVM, which means anything that wants to use these instructions
needs the link option -latomic.
In this patch, we will try to detect if 8-bit, 64-bit atomic instructions exist,
otherwise the atomic library will append to the DEPLIBS list.
Signed-off-by: Yixun Lan dlan@gentoo.org
Description
Motivation and context
How has this been tested?
What is the effect on users?
Screenshots (if appropriate):
Types of change
Checklist: