[vlc-commits] [Git][videolan/vlc][master] 6 commits: contrib: force CMake system to Android for Android

Steve Lhomme (@robUx4) gitlab at videolan.org
Tue Apr 23 18:44:46 UTC 2024



Steve Lhomme pushed to branch master at VideoLAN / VLC


Commits:
deb9246c by Steve Lhomme at 2024-04-23T17:19:41+00:00
contrib: force CMake system to Android for Android

So the the proper system detection happens:

https://github.com/Kitware/CMake/blob/master/Modules/Platform/Android-Determine.cmake

- - - - -
06a9b6b3 by Steve Lhomme at 2024-04-23T17:19:41+00:00
contrib: fix the CMake i386 and arm ARCH names

It works for Android and should be the same on other platforms.

- - - - -
0b92a08e by Steve Lhomme at 2024-04-23T17:19:41+00:00
contrib: fix CMake Android API typo

- - - - -
2a968ebb by Steve Lhomme at 2024-04-23T17:19:41+00:00
contrib: flac: don't use fseeko/ftello on older 32-bit Android

It's not supported [1]. NDK 26 will emit an error if you try to use it.

Upstream patch: https://github.com/xiph/flac/pull/691

[1] https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md

- - - - -
db5b75f0 by Steve Lhomme at 2024-04-23T17:19:41+00:00
contrib: upnp: don't use fseeko on older 32-bit Android

It's not supported [1]. NDK 26 will emit an error if you try to use it.

Upstream patch: https://github.com/pupnp/pupnp/pull/441

[1] https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md

- - - - -
e750fb57 by Steve Lhomme at 2024-04-23T17:19:41+00:00
contrib: x264: fix fseeko detection on older 32-bit Android

It's not supported [1]. NDK 26 will emit an error if you try to use it.

Upstream patch: https://code.videolan.org/videolan/x264/-/merge_requests/150

[1] https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md

- - - - -


8 changed files:

- + contrib/src/flac/0001-include-share-compat.h-use-fseek-if-fseeko-is-not-av.patch
- + contrib/src/flac/0002-CMake-disable-fseeko-on-32-bit-Android-before-API-24.patch
- contrib/src/flac/rules.mak
- contrib/src/main.mak
- + contrib/src/upnp/0001-disable-fseeko-usage-on-32-bit-Android-older-than-AP.patch
- contrib/src/upnp/rules.mak
- + contrib/src/x264/0001-configure-set-_FILE_OFFSET_BITS-to-detect-fseeko.patch
- contrib/src/x264/rules.mak


Changes:

=====================================
contrib/src/flac/0001-include-share-compat.h-use-fseek-if-fseeko-is-not-av.patch
=====================================
@@ -0,0 +1,33 @@
+From 15c68771d6001f09b68dd1aa14b84058584f7987 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 22 Apr 2024 12:01:02 +0200
+Subject: [PATCH 1/2] include/share/compat.h : use fseek if fseeko is not
+ available
+
+---
+ include/share/compat.h | 7 +++++++
+ 1 file changed, 7 insertions(+)
+
+diff --git a/include/share/compat.h b/include/share/compat.h
+index 7a865153..6e73b16d 100644
+--- a/include/share/compat.h
++++ b/include/share/compat.h
+@@ -62,8 +62,15 @@
+ #endif
+ #endif
+ #else
++#ifndef HAVE_FSEEKO
++#define fseeko fseek
++#define ftello ftell
++#define FLAC__off_t long
++#define FLAC__OFF_T_MAX LONG_MAX
++#else
+ #define FLAC__off_t off_t
+ #endif
++#endif
+ 
+ #ifdef HAVE_INTTYPES_H
+ #define __STDC_FORMAT_MACROS
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/flac/0002-CMake-disable-fseeko-on-32-bit-Android-before-API-24.patch
=====================================
@@ -0,0 +1,39 @@
+From 49708201f82d029d948d31e204213978e955eef0 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 22 Apr 2024 12:03:33 +0200
+Subject: [PATCH 2/2] [CMake] disable fseeko on 32-bit Android before API 24
+
+It can be linked in the NDK so check_function_exists detects it. But it's only supporting _FILE_OFFSET_BITS=64
+since Android API 24 [1].
+
+With NDK 26 it's no longer possible to build assuming the API is always available.
+
+[1] https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md
+---
+ CMakeLists.txt | 10 +++++++++-
+ 1 file changed, 9 insertions(+), 1 deletion(-)
+
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 316a8210..15490478 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -119,7 +119,15 @@ else()
+     check_include_file("x86intrin.h" FLAC__HAS_X86INTRIN)
+ endif()
+ 
+-check_function_exists(fseeko HAVE_FSEEKO)
++
++if(ANDROID AND CMAKE_SYSTEM_VERSION VERSION_LESS 24 AND (CMAKE_SYSTEM_PROCESSOR MATCHES "i686" OR CMAKE_SYSTEM_PROCESSOR MATCHES "armv7-a"))
++    # fseeko/ftello may link, but it's not usable before Android API 24 on 32-bit Android
++    # https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md
++    message(STATUS "Disabling fseeko/ftello for 32-bit Android before API 24")
++    set(HAVE_FSEEKO 0 CACHE INTERNAL "")
++else()
++    check_function_exists(fseeko HAVE_FSEEKO)
++endif()
+ 
+ check_c_source_compiles("int main() { return __builtin_bswap16 (0) ; }" HAVE_BSWAP16)
+ check_c_source_compiles("int main() { return __builtin_bswap32 (0) ; }" HAVE_BSWAP32)
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/flac/rules.mak
=====================================
@@ -16,6 +16,9 @@ $(TARBALLS)/flac-$(FLAC_VERSION).tar.xz:
 flac: flac-$(FLAC_VERSION).tar.xz .sum-flac
 	$(UNPACK)
 	$(APPLY) $(SRC)/flac/0001-Fixed-compilation-of-get_utf8_argv-for-Windows-UWP.patch
+	# use fseek/ftell on 32-bit Android < 24
+	$(APPLY) $(SRC)/flac/0001-include-share-compat.h-use-fseek-if-fseeko-is-not-av.patch
+	$(APPLY) $(SRC)/flac/0002-CMake-disable-fseeko-on-32-bit-Android-before-API-24.patch
 	# disable building a tool we don't use
 	sed -e 's,add_subdirectory("microbench"),#add_subdirectory("microbench"),' -i.orig $(UNPACK_DIR)/CMakeLists.txt
 	$(call pkg_static,"src/libFLAC/flac.pc.in")


=====================================
contrib/src/main.mak
=====================================
@@ -653,11 +653,20 @@ help:
 
 .PHONY: all fetch fetch-all install mostlyclean clean distclean package list help prebuilt tools
 
+CMAKE_HOST_ARCH=$(ARCH)
+ifeq ($(ARCH),i386)
+CMAKE_HOST_ARCH=i686
+else ifeq ($(ARCH),arm)
+CMAKE_HOST_ARCH=armv7-a
+endif
+
 CMAKE_SYSTEM_NAME =
 ifdef HAVE_CROSS_COMPILE
 CMAKE_SYSTEM_NAME = $(error CMAKE_SYSTEM_NAME required for cross-compilation)
 endif
-ifdef HAVE_LINUX
+ifdef HAVE_ANDROID
+CMAKE_SYSTEM_NAME = Android
+else
 CMAKE_SYSTEM_NAME = Linux
 endif
 ifdef HAVE_WIN32
@@ -682,7 +691,7 @@ CFLAGS += -DANDROID_NATIVE_API_LEVEL=$(ANDROID_API)
 endif
 
 # CMake toolchain
-CMAKE_TOOLCHAIN_ENV := $(HOSTTOOLS) HOST_ARCH="$(ARCH)" SYSTEM_NAME="$(CMAKE_SYSTEM_NAME)"
+CMAKE_TOOLCHAIN_ENV := $(HOSTTOOLS) HOST_ARCH="$(CMAKE_HOST_ARCH)" SYSTEM_NAME="$(CMAKE_SYSTEM_NAME)"
 ifdef HAVE_WIN32
 ifdef HAVE_CROSS_COMPILE
 	CMAKE_TOOLCHAIN_ENV += RC_COMPILER="$(WINDRES)"
@@ -704,7 +713,7 @@ endif
 ifdef HAVE_ANDROID
 	CMAKE_TOOLCHAIN_ENV += ANDROID_NDK=$(ANDROID_NDK)
 	CMAKE_TOOLCHAIN_ENV += ANDROID_ABI=$(ANDROID_ABI)
-	CMAKE_TOOLCHAIN_ENV += ANDROID_ABI=$(ANDROID_API)
+	CMAKE_TOOLCHAIN_ENV += ANDROID_API=$(ANDROID_API)
 # cmake will overwrite our --sysroot with a native (host) one on Darwin
 # Set it to "" right away to short-circuit this behaviour
 	CMAKE_TOOLCHAIN_ENV += CXX_SYSROOT_FLAG=


=====================================
contrib/src/upnp/0001-disable-fseeko-usage-on-32-bit-Android-older-than-AP.patch
=====================================
@@ -0,0 +1,31 @@
+From 270dd4063694c6138a893bfaebdddde4987c69d1 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 22 Apr 2024 13:17:15 +0200
+Subject: [PATCH] disable fseeko usage on 32-bit Android older than API 24
+
+feesko is not supported on 32-bit Android older than API 24 [1].
+Older SDKs would allow the call but the 64-bit off_t was not accurate.
+With the NDK26 the call is hidden in that case and calling fseeko() results in a compilation error.
+
+[1] https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md
+---
+ upnp/src/genlib/net/http/httpreadwrite.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/upnp/src/genlib/net/http/httpreadwrite.c b/upnp/src/genlib/net/http/httpreadwrite.c
+index 27e9c3a5..045e5d51 100644
+--- a/upnp/src/genlib/net/http/httpreadwrite.c
++++ b/upnp/src/genlib/net/http/httpreadwrite.c
+@@ -73,6 +73,9 @@
+ 	#include <sys/types.h>
+ 	#include <sys/utsname.h>
+ 	#include <sys/wait.h>
++	#if defined(__ANDROID__) && (!defined(__USE_FILE_OFFSET64) || __ANDROID_API__ < 24)
++		#define fseeko fseek
++	#endif
+ #endif /* _WIN32 */
+ 
+ /*
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/upnp/rules.mak
=====================================
@@ -42,6 +42,7 @@ endif
 ifdef HAVE_IOS
 	$(APPLY) $(SRC)/upnp/fix-reuseaddr-option.patch
 endif
+	$(APPLY) $(SRC)/upnp/0001-disable-fseeko-usage-on-32-bit-Android-older-than-AP.patch
 	$(MOVE)
 
 .upnp: upnp toolchain.cmake


=====================================
contrib/src/x264/0001-configure-set-_FILE_OFFSET_BITS-to-detect-fseeko.patch
=====================================
@@ -0,0 +1,26 @@
+From dc69fefa49726021d75e6a764357779a4b4d0800 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Mon, 22 Apr 2024 14:03:02 +0200
+Subject: [PATCH] configure: set _FILE_OFFSET_BITS to detect fseeko
+
+On Android fseeko is not detected properly if if _FILE_OFFSET_BITS is not set.
+---
+ configure | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/configure b/configure
+index c1fb599f..60ad229b 100755
+--- a/configure
++++ b/configure
+@@ -1369,7 +1369,7 @@ if [ $SYS = WINDOWS -a $ARCH = X86 -a $compiler = GNU ] ; then
+     cc_check '' -fno-zero-initialized-in-bss && CFLAGS="$CFLAGS -fno-zero-initialized-in-bss"
+ fi
+ 
+-if cc_check "stdio.h" "" "fseeko(stdin,0,0);" ; then
++if cc_check "stdio.h" "#define _FILE_OFFSET_BITS 64" "fseeko(stdin,0,0);" ; then
+     define fseek fseeko
+     define ftell ftello
+ elif cc_check "stdio.h" "" "fseeko64(stdin,0,0);" ; then
+-- 
+2.37.3.windows.1
+


=====================================
contrib/src/x264/rules.mak
=====================================
@@ -57,6 +57,7 @@ x264 x26410b: %: x264-$(X264_VERSION).tar.xz .sum-%
 	$(UPDATE_AUTOCONFIG)
 	$(APPLY) $(SRC)/x264/x264-winstore.patch
 	$(APPLY) $(SRC)/x264/0001-osdep-use-direct-path-to-internal-x264.h.patch
+	$(APPLY) $(SRC)/x264/0001-configure-set-_FILE_OFFSET_BITS-to-detect-fseeko.patch
 	$(MOVE)
 
 .x264: x264



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/738b974777638cae4631e65dc4f0e475cb734a93...e750fb576b5d2c7b1341c71697e26bad79bb5460

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/738b974777638cae4631e65dc4f0e475cb734a93...e750fb576b5d2c7b1341c71697e26bad79bb5460
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list