Skip to content

Commit e3adfaf

Browse files
ppigazzinivondele
authored andcommitted
build & ci: update to NDK r27c API level 29
Update to the latest LTS version NDK r27c (27.2.12479018), the previous NDK are unsupported by Google, see: https://developer.android.com/ndk/downloads A build with NDK r27c and API level < 29 returns this error: "executable's TLS segment is underaligned: alignment is 8 (skew 0), needs to be at least 64 for ARM64 Bionic" Update the API level to 29 to use the native ELF LTS and avoid the error: https://android.googlesource.com/platform/bionic/+/HEAD/docs/elf-tls.md https://android.googlesource.com/platform/bionic/+/HEAD/android-changes-for-ndk-developers.md#elf-tls-available-for-api-level-29 A dynamic link build of Stockfish uses these libraries: ldd stockfish-android-armv8-dynamic-api35 libm.so => /system/lib64/libm.so libdl.so => /system/lib64/libdl.so libc.so => /system/lib64/libc.so ld-android.so => /system/lib64/ld-android.so ld-android.so : the dynamic linker used by Android (on Linux is named ld-linux.so), responsible for loading and linking shared libraries into an executable at runtime. libdl.so : interface/library layer that provides function for dynamic loading, relies on the underlying functionality provided by the dynamic linker libm.so : math library for Android libc.so : standard C library for Android References: Doc for native (C/C++) API https://developer.android.com/ndk/guides/stable_apis C libraries (libc, libm, libdl): https://developer.android.com/ndk/guides/stable_apis#c_library Bionic changes with API levels: https://android.googlesource.com/platform/bionic/+/HEAD/docs/status.md NDK r27c build system: https://android.googlesource.com/platform/ndk/+/ndk-r27-release/docs/BuildSystemMaintainers.md CI: Update to NDK r27c (27.2.12479018), the default version in GitHub runner, to switch to a recent clang 18. A PGO build requires static linking, because the NDK doesn't ship the Android loaders (linker/linker64), see: https://groups.google.com/g/android-ndk/c/3Ep6zD3xxSY The API level should not be an issue when distributing a static build, use the API 29, the oldest one not affected by the LTS alignement issue. closes #6081 No functional change
1 parent bebffc5 commit e3adfaf

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

.github/ci/arm_matrix.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"name": "Android NDK aarch64",
55
"os": "ubuntu-22.04",
66
"simple_name": "android",
7-
"compiler": "aarch64-linux-android21-clang++",
7+
"compiler": "aarch64-linux-android29-clang++",
88
"emu": "qemu-aarch64",
99
"comp": "ndk",
1010
"shell": "bash",
@@ -14,7 +14,7 @@
1414
"name": "Android NDK arm",
1515
"os": "ubuntu-22.04",
1616
"simple_name": "android",
17-
"compiler": "armv7a-linux-androideabi21-clang++",
17+
"compiler": "armv7a-linux-androideabi29-clang++",
1818
"emu": "qemu-arm",
1919
"comp": "ndk",
2020
"shell": "bash",
@@ -26,25 +26,25 @@
2626
{
2727
"binaries": "armv8-dotprod",
2828
"config": {
29-
"compiler": "armv7a-linux-androideabi21-clang++"
29+
"compiler": "armv7a-linux-androideabi29-clang++"
3030
}
3131
},
3232
{
3333
"binaries": "armv8",
3434
"config": {
35-
"compiler": "armv7a-linux-androideabi21-clang++"
35+
"compiler": "armv7a-linux-androideabi29-clang++"
3636
}
3737
},
3838
{
3939
"binaries": "armv7",
4040
"config": {
41-
"compiler": "aarch64-linux-android21-clang++"
41+
"compiler": "aarch64-linux-android29-clang++"
4242
}
4343
},
4444
{
4545
"binaries": "armv7-neon",
4646
"config": {
47-
"compiler": "aarch64-linux-android21-clang++"
47+
"compiler": "aarch64-linux-android29-clang++"
4848
}
4949
}
5050
]

.github/workflows/arm_compilation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
if: runner.os == 'Linux'
3939
run: |
4040
if [ $COMP == ndk ]; then
41-
NDKV="21.4.7075529"
41+
NDKV="27.2.12479018"
4242
ANDROID_ROOT=/usr/local/lib/android
4343
ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
4444
SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager

.github/workflows/tests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ jobs:
2929
shell: bash
3030
- name: Android NDK aarch64
3131
os: ubuntu-22.04
32-
compiler: aarch64-linux-android21-clang++
32+
compiler: aarch64-linux-android29-clang++
3333
comp: ndk
3434
run_armv8_tests: true
3535
shell: bash
3636
- name: Android NDK arm
3737
os: ubuntu-22.04
38-
compiler: armv7a-linux-androideabi21-clang++
38+
compiler: armv7a-linux-androideabi29-clang++
3939
comp: ndk
4040
run_armv7_tests: true
4141
shell: bash
@@ -126,7 +126,7 @@ jobs:
126126
if: runner.os == 'Linux'
127127
run: |
128128
if [ $COMP == ndk ]; then
129-
NDKV="21.4.7075529"
129+
NDKV="27.2.12479018"
130130
ANDROID_ROOT=/usr/local/lib/android
131131
ANDROID_SDK_ROOT=$ANDROID_ROOT/sdk
132132
SDKMANAGER=$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager

src/Makefile

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -533,14 +533,12 @@ ifeq ($(KERNEL),Darwin)
533533
XCRUN = xcrun
534534
endif
535535

536-
# To cross-compile for Android, NDK version r21 or later is recommended.
537-
# In earlier NDK versions, you'll need to pass -fno-addrsig if using GNU binutils.
538-
# Currently we don't know how to make PGO builds with the NDK yet.
536+
# To cross-compile for Android, use NDK version r27c or later.
539537
ifeq ($(COMP),ndk)
540-
CXXFLAGS += -stdlib=libc++ -fPIE
538+
CXXFLAGS += -stdlib=libc++
541539
comp=clang
542540
ifeq ($(arch),armv7)
543-
CXX=armv7a-linux-androideabi16-clang++
541+
CXX=armv7a-linux-androideabi29-clang++
544542
CXXFLAGS += -mthumb -march=armv7-a -mfloat-abi=softfp -mfpu=neon
545543
ifneq ($(shell which arm-linux-androideabi-strip 2>/dev/null),)
546544
STRIP=arm-linux-androideabi-strip
@@ -549,22 +547,22 @@ ifeq ($(COMP),ndk)
549547
endif
550548
endif
551549
ifeq ($(arch),armv8)
552-
CXX=aarch64-linux-android21-clang++
550+
CXX=aarch64-linux-android29-clang++
553551
ifneq ($(shell which aarch64-linux-android-strip 2>/dev/null),)
554552
STRIP=aarch64-linux-android-strip
555553
else
556554
STRIP=llvm-strip
557555
endif
558556
endif
559557
ifeq ($(arch),x86_64)
560-
CXX=x86_64-linux-android21-clang++
558+
CXX=x86_64-linux-android29-clang++
561559
ifneq ($(shell which x86_64-linux-android-strip 2>/dev/null),)
562560
STRIP=x86_64-linux-android-strip
563561
else
564562
STRIP=llvm-strip
565563
endif
566564
endif
567-
LDFLAGS += -static-libstdc++ -pie -lm -latomic
565+
LDFLAGS += -static-libstdc++
568566
endif
569567

570568
### Allow overwriting CXX from command line

0 commit comments

Comments
 (0)