From 5d938d8488efa9c7246cd792affeb33dc27262bf Mon Sep 17 00:00:00 2001 From: serge-sans-paille Date: Thu, 15 May 2025 09:32:02 +0000 Subject: [PATCH] Bug 1962300 - Provide support for unavailable symbols as weak symbols r=m_kato,gfx-reviewers,firefox-build-system-reviewers,glandium,necko-reviewers,geckoview-reviewers,cubeb-reviewers,valentin,padenot,jnicol Compiler support make it possible to detect missing checks at compile time, so it's relatively safe, as described in https://developer.android.com/ndk/guides/using-newer-apis It's now applied globally on android. Deactivate the associate compiler warning on cubeb as it otherwise throws warning for type computations. Differential Revision: https://phabricator.services.mozilla.com/D246803 --- build/moz.configure/android-ndk.configure | 24 ++++++++++++++++++++--- media/libcubeb/src/moz.build | 2 +- memory/replace/logalloc/replay/moz.build | 5 +++++ 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/build/moz.configure/android-ndk.configure b/build/moz.configure/android-ndk.configure index 648782790e2d..1312b9c9228e 100644 --- a/build/moz.configure/android-ndk.configure +++ b/build/moz.configure/android-ndk.configure @@ -274,11 +274,29 @@ def extra_toolchain_flags(android_sysroot, toolchain_dir): @depends(extra_toolchain_flags) def android_flags(extra_toolchain_flags): + wead_symbols_defines = [ + "-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__", + ] + weak_symbols_flags = wead_symbols_defines + [ + "-Werror=unguarded-availability", + ] return namespace( - cflags=extra_toolchain_flags + ["-fno-short-enums"], - cxxflags=extra_toolchain_flags + ["-fno-short-enums"], + cflags=extra_toolchain_flags + + [ + "-fno-short-enums", + ] + + weak_symbols_flags, + cxxflags=extra_toolchain_flags + + [ + "-fno-short-enums", + ] + + weak_symbols_flags, ldflags=extra_toolchain_flags, - asflags=extra_toolchain_flags + ["-DANDROID"], + asflags=extra_toolchain_flags + + [ + "-DANDROID", + ] + + wead_symbols_defines, ) diff --git a/media/libcubeb/src/moz.build b/media/libcubeb/src/moz.build index fd6c6842a48d..7ab524bfc7e8 100644 --- a/media/libcubeb/src/moz.build +++ b/media/libcubeb/src/moz.build @@ -95,7 +95,7 @@ if CONFIG['MOZ_AAUDIO'] or CONFIG['MOZ_OPENSL']: if CONFIG['MOZ_AAUDIO']: SOURCES += ['cubeb_aaudio.cpp'] - SOURCES['cubeb_aaudio.cpp'].flags += ['-D__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__'] + SOURCES['cubeb_aaudio.cpp'].flags += ['-Wno-unguarded-availability'] DEFINES['USE_AAUDIO'] = True if CONFIG['MOZ_OPENSL']: diff --git a/memory/replace/logalloc/replay/moz.build b/memory/replace/logalloc/replay/moz.build index fe8d1d65e4b0..cae14f31a661 100644 --- a/memory/replace/logalloc/replay/moz.build +++ b/memory/replace/logalloc/replay/moz.build @@ -29,6 +29,11 @@ if CONFIG["OS_TARGET"] == "Darwin": # when building with MACOSX_DEPLOYMENT_TARGET < 10.15 with >= 10.15 SDK. # We have our own definition of the function, so it doesn't matter what the SDK says. SOURCES["Replay.cpp"].flags += ["-Wno-unguarded-availability-new"] +elif CONFIG["OS_TARGET"] == "Android": + # Work around "warning: 'aligned_alloc' is only available on Android 27 or + # lower. We have our own definition of the function, so it doesn't matter. + SOURCES["Replay.cpp"].flags += ["-Wno-unguarded-availability"] + if CONFIG["MOZ_REPLACE_MALLOC_STATIC"] and (CONFIG["MOZ_DMD"] or CONFIG["MOZ_PHC"]): UNIFIED_SOURCES += [