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
This commit is contained in:
serge-sans-paille
2025-05-15 09:32:02 +00:00
committed by sguelton@mozilla.com
parent e828ae5ced
commit 5d938d8488
3 changed files with 27 additions and 4 deletions

View File

@@ -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,
)