[BUG] NDK 27 no longer supports passing in CMAKE_SYSTEM_PROCESSOR
to CMake to set the arch #2049
Description
Description
This simple command always worked in the past for most CMake repos:
> cmake -GNinja /home/finagolfin/swift-corelibs-libdispatch/ -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_ANDROID_NDK=/home/finagolfin/android-ndk-r27/
CMake Error at /usr/share/cmake/Modules/Platform/Android-Determine.cmake:378 (message):
Android: Unknown processor CMAKE_SYSTEM_PROCESSOR='aarch64'.
Call Stack (most recent call first):
/usr/share/cmake/Modules/CMakeDetermineSystem.cmake:212 (include)
CMakeLists.txt:12 (project)
CMake Error: CMake was unable to find a build program corresponding to "Ninja". CMAKE_MAKE_PROGRAM is not set. You probably need to select a different build tool.
CMake Error: CMAKE_C_COMPILER not set, after EnableLanguage
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
-- Configuring incomplete, errors occurred!
For example, with NDK 26d:
> cmake -GNinja /home/finagolfin/swift-corelibs-libdispatch/ -DCMAKE_SYSTEM_NAME=Android -DCMAKE_SYSTEM_VERSION=21 -DCMAKE_SYSTEM_PROCESSOR=aarch64 -DCMAKE_ANDROID_NDK=/home/finagolfin/android-ndk-r26d/
-- Android: Targeting API '21' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64'
-- Android: Selected unified Clang toolchain
-- The C compiler identification is Clang 17.0.2
-- The CXX compiler identification is Clang 17.0.2
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /home/finagolfin/android-ndk-r26d//toolchains/llvm/prebuilt/linux-x86_64/bin/clang - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /home/finagolfin/android-ndk-r26d//toolchains/llvm/prebuilt/linux-x86_64/bin/clang++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Threads: TRUE
-- Looking for __GNU_LIBRARY__
-- Looking for __GNU_LIBRARY__ - not found
-- Performing Test __BUILTIN_TRAP
-- Performing Test __BUILTIN_TRAP - Success
-- Looking for _pthread_workqueue_init
-- Looking for _pthread_workqueue_init - not found
-- Looking for getprogname
-- Looking for getprogname - found
-- Looking for mach_absolute_time
-- Looking for mach_absolute_time - not found
-- Looking for mach_approximate_time
-- Looking for mach_approximate_time - not found
-- Looking for mach_port_construct
-- Looking for mach_port_construct - not found
-- Looking for malloc_create_zone
-- Looking for malloc_create_zone - not found
-- Looking for posix_fadvise
-- Looking for posix_fadvise - found
-- Looking for posix_spawnp
-- Looking for posix_spawnp - not found
-- Looking for pthread_key_init_np
-- Looking for pthread_key_init_np - not found
-- Looking for pthread_attr_setcpupercent_np
-- Looking for pthread_attr_setcpupercent_np - not found
-- Looking for pthread_yield_np
-- Looking for pthread_yield_np - not found
-- Looking for pthread_main_np
-- Looking for pthread_main_np - not found
-- Looking for pthread_workqueue_setdispatch_np
-- Looking for pthread_workqueue_setdispatch_np - not found
-- Looking for strlcpy
-- Looking for strlcpy - found
-- Looking for sysconf
-- Looking for sysconf - found
-- Looking for arc4random
-- Looking for arc4random - found
-- Looking for include file TargetConditionals.h
-- Looking for include file TargetConditionals.h - not found
-- Looking for include file dlfcn.h
-- Looking for include file dlfcn.h - found
-- Looking for include file fcntl.h
-- Looking for include file fcntl.h - found
-- Looking for include file inttypes.h
-- Looking for include file inttypes.h - found
-- Looking for include file libkern/OSAtomic.h
-- Looking for include file libkern/OSAtomic.h - not found
-- Looking for include file libkern/OSCrossEndian.h
-- Looking for include file libkern/OSCrossEndian.h - not found
-- Looking for include file libproc_internal.h
-- Looking for include file libproc_internal.h - not found
-- Looking for include file mach/mach.h
-- Looking for include file mach/mach.h - not found
-- Looking for include file malloc/malloc.h
-- Looking for include file malloc/malloc.h - not found
-- Looking for include file memory.h
-- Looking for include file memory.h - found
-- Looking for include file pthread/qos.h
-- Looking for include file pthread/qos.h - not found
-- Looking for include file pthread/workqueue_private.h
-- Looking for include file pthread/workqueue_private.h - not found
-- Looking for include file pthread_machdep.h
-- Looking for include file pthread_machdep.h - not found
-- Looking for include file pthread_np.h
-- Looking for include file pthread_np.h - not found
-- Looking for include file pthread_workqueue.h
-- Looking for include file pthread_workqueue.h - not found
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file stdlib.h
-- Looking for include file stdlib.h - found
-- Looking for include file string.h
-- Looking for include file string.h - found
-- Looking for include file strings.h
-- Looking for include file strings.h - found
-- Looking for include file sys/guarded.h
-- Looking for include file sys/guarded.h - not found
-- Looking for include file sys/stat.h
-- Looking for include file sys/stat.h - found
-- Looking for include file sys/types.h
-- Looking for include file sys/types.h - found
-- Looking for include file objc/objc-internal.h
-- Looking for include file objc/objc-internal.h - not found
-- Looking for sem_init in pthread
-- Looking for sem_init in pthread - not found
-- Looking for CLOCK_UPTIME
-- Looking for CLOCK_UPTIME - not found
-- Looking for CLOCK_UPTIME_FAST
-- Looking for CLOCK_UPTIME_FAST - not found
-- Looking for CLOCK_MONOTONIC
-- Looking for CLOCK_MONOTONIC - found
-- Looking for CLOCK_REALTIME
-- Looking for CLOCK_REALTIME - found
-- Looking for CLOCK_MONOTONIC_COARSE
-- Looking for CLOCK_MONOTONIC_COARSE - found
-- Looking for FD_COPY
-- Looking for FD_COPY - not found
-- Looking for NOTE_LOWAT
-- Looking for NOTE_LOWAT - not found
-- Looking for NOTE_NONE
-- Looking for NOTE_NONE - not found
-- Looking for NOTE_REAP
-- Looking for NOTE_REAP - not found
-- Looking for NOTE_REVOKE
-- Looking for NOTE_REVOKE - not found
-- Looking for NOTE_SIGNAL
-- Looking for NOTE_SIGNAL - not found
-- Looking for POSIX_SPAWN_START_SUSPENDED
-- Looking for POSIX_SPAWN_START_SUSPENDED - not found
-- Looking for SIGEMT
-- Looking for SIGEMT - not found
-- Looking for VQ_DESIRED_DISK
-- Looking for VQ_DESIRED_DISK - not found
-- Looking for VQ_NEARLOWDISK
-- Looking for VQ_NEARLOWDISK - not found
-- Looking for VQ_QUOTA
-- Looking for VQ_QUOTA - not found
-- Looking for VQ_UPDATE
-- Looking for VQ_UPDATE - not found
-- Looking for VQ_VERYLOWDISK
-- Looking for VQ_VERYLOWDISK - not found
-- Looking for VQ_FREE_SPACE_CHANGE
-- Looking for VQ_FREE_SPACE_CHANGE - not found
-- Looking for program_invocation_name
-- Looking for program_invocation_name - not found
-- Looking for __printflike
-- Looking for __printflike - not found
-- Performing Test C_SUPPORTS_OMIT_LEAF_FRAME_POINTER
-- Performing Test C_SUPPORTS_OMIT_LEAF_FRAME_POINTER - Success
-- Configuring done (3.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/finagolfin/swift-corelibs-libdispatch/build
I looked into that error and the problem is that CMake expects NDK_PROC_aarch64_ABI
and so on to be set, but the new abis.cmake
no longer does:
> diff android-ndk-r26d/build/cmake/abis.cmake android-ndk-r27/build/cmake/abis.cmake 4,5c4,5
< set(NDK_KNOWN_DEVICE_ABI64S "arm64-v8a;x86_64")
< set(NDK_KNOWN_DEVICE_ABIS "arm64-v8a;armeabi-v7a;x86;x86_64")
---
> set(NDK_KNOWN_DEVICE_ABI64S "arm64-v8a;riscv64;x86_64")
> set(NDK_KNOWN_DEVICE_ABIS "arm64-v8a;armeabi-v7a;riscv64;x86;x86_64")
10,11c10
< set(NDK_PROC_armv7-a_ABI "armeabi-v7a")
< set(NDK_ARCH_arm_ABI "armeabi-v7a")
---
> set(NDK_ABI_armeabi-v7a_MIN_OS_VERSION "21")
16,17c15,20
< set(NDK_PROC_aarch64_ABI "arm64-v8a")
< set(NDK_ARCH_arm64_ABI "arm64-v8a")
---
> set(NDK_ABI_arm64-v8a_MIN_OS_VERSION "21")
> set(NDK_ABI_riscv64_PROC "riscv64")
> set(NDK_ABI_riscv64_ARCH "riscv64")
> set(NDK_ABI_riscv64_TRIPLE "riscv64-linux-android")
> set(NDK_ABI_riscv64_LLVM_TRIPLE "riscv64-none-linux-android")
> set(NDK_ABI_riscv64_MIN_OS_VERSION "35")
22,23c25
< set(NDK_PROC_i686_ABI "x86")
< set(NDK_ARCH_x86_ABI "x86")
---
> set(NDK_ABI_x86_MIN_OS_VERSION "21")
28,29c30,31
< set(NDK_PROC_x86_64_ABI "x86_64")
< set(NDK_ARCH_x86_64_ABI "x86_64")
\ No newline at end of file
---
> set(NDK_ABI_x86_64_MIN_OS_VERSION "21")
\ No newline at end of file
I looked in the source for this file, but it's not there and saw no mention of it in the scripts either. Is it generated externally somewhere?
Was dropping these a mistake or a choice? If I add back NDK_PROC_aarch64_ABI
, the config works again.
Many build systems likely simply set that CMAKE_SYSTEM_NAME
/CMAKE_SYSTEM_VERSION
/CMAKE_SYSTEM_PROCESSOR
triad to compile for all platforms, just setting CMAKE_ANDROID_NDK
additionally for Android. It would be good to continue supporting that basic CMake config.
Affected versions
r27
Canary version
No response
Host OS
Linux
Host OS version
Fedora 40 x86_64
Affected ABIs
armeabi-v7a, arm64-v8a, x86, x86_64
Build system
CMake
Other build system
No response
minSdkVersion
21
Device API level
No response