Bug 444247

Summary: CheckAtomic doesn't set LLVM_COMPILER_IS_GCC_COMPATIBLE and fails check on Apple Clang
Product: [Frameworks and Libraries] extra-cmake-modules Reporter: amyspark <amy>
Component: generalAssignee: ecm-bugs-null <ecm-bugs-null>
Status: REPORTED ---    
Severity: major    
Priority: NOR    
Version: 5.87.0   
Target Milestone: ---   
Platform: Compiled Sources   
OS: macOS   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description amyspark 2021-10-22 22:10:44 UTC
SUMMARY

When CheckAtomic was updated to the upstream version, the author missed that LLVM_COMPILER_IS_GCC_COMPATIBLE is a check set by another LLVM module, DetermineGCCCompatible. This module isn't anywhere in ECM, so the check fails.
This is needed especially on Apple Clang, because `-latomic` doesn't exist there.

STEPS TO REPRODUCE
1. On a macOS platform, include(CheckAtomic) and try linking an executable.

OBSERVED RESULT
https://binary-factory.kde.org/job/Krita_Nightly_MacOS_Build/919/consoleText

> [2021-10-22T07:15:21.063Z] ld: library not found for -latomic

EXPECTED RESULT

Executables using `std::atomic` work successfully.


SOFTWARE/OS VERSIONS
Windows: 
macOS: See the ARM runner in binary factory.
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION

Cherry-pick https://invent.kde.org/graphics/krita/-/commit/8e7ccd3cd7601ac4c27696eafd8cd1bb8a40296c to fix this.
Comment 1 sh_zam 2021-10-28 14:44:13 UTC
Git commit 0b755beaa1fdba03d38f887b93a15a58fc0830c7 by Sharaf Zaman.
Committed on 28/10/2021 at 14:42.
Pushed by szaman into branch 'master'.

Fix build on linux clang targets

In CheckAtomic.cmake we include is_lock_free because these routines
don't seem to be included in the compiler's "simple atomics". This
triggers a failure in clang toolchain, forcing it to link libatomic.

Resulting in error: ld.lld: error: undefined symbol: __atomic_is_lock_free
Related: bug 444547

M  +1    -0    cmake/modules/CheckAtomic.cmake
M  +2    -4    libs/image/CMakeLists.txt

https://invent.kde.org/graphics/krita/commit/0b755beaa1fdba03d38f887b93a15a58fc0830c7
Comment 2 amyspark 2022-03-17 14:52:29 UTC
Git commit 1418085400e95b5a13218e98d318333dd591e8b9 by L. E. Segovia, on behalf of Sharaf Zaman.
Committed on 17/03/2022 at 14:50.
Pushed by lsegovia into branch 'krita/5.0'.

Fix build on linux clang targets

In CheckAtomic.cmake we include is_lock_free because these routines
don't seem to be included in the compiler's "simple atomics". This
triggers a failure in clang toolchain, forcing it to link libatomic.

Resulting in error: ld.lld: error: undefined symbol: __atomic_is_lock_free
Related: bug 444547
(cherry picked from commit 0b755beaa1fdba03d38f887b93a15a58fc0830c7)

M  +1    -0    cmake/modules/CheckAtomic.cmake
M  +2    -4    libs/image/CMakeLists.txt

https://invent.kde.org/graphics/krita/commit/1418085400e95b5a13218e98d318333dd591e8b9