Backed out 2 changesets (bug 1820947) for causing build bustage CLOSED TREE

Backed out changeset eb6419bb8748 (bug 1820947)
Backed out changeset 9990083e8ea2 (bug 1820947)
This commit is contained in:
Norisz Fay 2023-03-14 01:20:54 +02:00
Родитель 0eabfe04d0
Коммит 4a35828e21
8 изменённых файлов: 215 добавлений и 100 удалений

Просмотреть файл

@ -11,7 +11,7 @@ case "$target" in
LDFLAGS="$extra_android_flags $LDFLAGS"
CPPFLAGS="$extra_android_flags $CPPFLAGS"
CFLAGS="-fno-short-enums $CFLAGS"
CXXFLAGS="-fno-short-enums $CXXFLAGS"
CXXFLAGS="-fno-short-enums $CXXFLAGS $stlport_cppflags"
ASFLAGS="$extra_android_flags -DANDROID $ASFLAGS"
;;
esac

Просмотреть файл

@ -121,50 +121,84 @@ set_config("ANDROID_NDK_MAJOR_VERSION", ndk_version.major)
set_config("ANDROID_NDK_MINOR_VERSION", ndk_version.minor)
@depends(target, android_version, ndk)
@checking("for android platform directory")
@imports(_from="os.path", _import="isdir")
@imports(_from="mozbuild.shellutil", _import="quote")
def host_dir(host, base_dir):
dir_format = "%s/%s-%s"
host_kernel = "windows" if host.kernel == "WINNT" else host.kernel.lower()
def android_platform(target, android_version, ndk):
if target.os != "Android":
return
dir = dir_format % (base_dir, host_kernel, host.cpu)
log.debug("Trying %s" % quote(dir))
if not isdir(dir) and host.cpu == "x86_64":
dir = dir_format % (base_dir, host_kernel, "x86")
log.debug("Trying %s" % quote(dir))
if not isdir(dir) and host.kernel == "Darwin" and host.cpu == "aarch64":
dir = dir_format % (base_dir, host_kernel, "x86_64")
log.debug("Trying %s" % quote(dir))
if isdir(dir):
return dir
if "aarch64" == target.cpu:
target_dir_name = "arm64"
else:
target_dir_name = target.cpu
# Not all Android releases have their own platform release. We use
# the next lower platform version in these cases.
if android_version in (11, 10):
platform_version = 9
elif android_version in (20, 22):
platform_version = android_version - 1
else:
platform_version = android_version
platform_dir = os.path.join(
ndk, "platforms", "android-%s" % platform_version, "arch-%s" % target_dir_name
)
if not isdir(platform_dir):
die(
"Android platform directory not found. With the current "
"configuration, it should be in %s" % platform_dir
)
return platform_dir
@depends(ndk, target, host)
@depends(ndk, target)
@checking("for android sysroot directory")
@imports(_from="os.path", _import="isdir")
def android_sysroot(ndk, target, host):
def android_sysroot(ndk, target):
if target.os != "Android":
return
search_dirs = [
os.path.join(
host_dir(host, os.path.join(ndk, "toolchains", "llvm", "prebuilt")),
"sysroot",
),
# (<if this directory exists>, <return this directory>)
(os.path.join(ndk, "sysroot"), os.path.join(ndk, "sysroot")),
]
for sysroot_dir in search_dirs:
if isdir(sysroot_dir):
for test_dir, sysroot_dir in search_dirs:
if isdir(test_dir):
return sysroot_dir
die(
"Android sysroot directory not found in %s."
% str([sysroot_dir for sysroot_dir in search_dirs])
% str([sysroot_dir for test_dir, sysroot_dir in search_dirs])
)
@depends(ndk, target)
@checking("for android system directory")
@imports(_from="os.path", _import="isdir")
def android_system(ndk, target):
if target.os != "Android":
return
search_dirs = [
os.path.join(ndk, "sysroot", "usr", "include", target.toolchain),
]
for system_dir in search_dirs:
if isdir(system_dir):
return system_dir
die("Android system directory not found in %s." % str(search_dirs))
@depends(target, host, ndk, "--with-android-toolchain")
@checking("for the Android toolchain directory", lambda x: x or "not found")
@imports(_from="os.path", _import="isdir")
@imports(_from="mozbuild.shellutil", _import="quote")
def android_toolchain(target, host, ndk, toolchain):
if not ndk:
return
@ -182,8 +216,18 @@ def android_toolchain(target, host, ndk, toolchain):
else:
die("Target cpu is not supported.")
toolchain = host_dir(host, "%s/toolchains/%s-4.9/prebuilt" % (ndk, target_base))
if toolchain:
toolchain_format = "%s/toolchains/%s-4.9/prebuilt/%s-%s"
host_kernel = "windows" if host.kernel == "WINNT" else host.kernel.lower()
toolchain = toolchain_format % (ndk, target_base, host_kernel, host.cpu)
log.debug("Trying %s" % quote(toolchain))
if not isdir(toolchain) and host.cpu == "x86_64":
toolchain = toolchain_format % (ndk, target_base, host_kernel, "x86")
log.debug("Trying %s" % quote(toolchain))
if not isdir(toolchain) and host.kernel == "Darwin" and host.cpu == "aarch64":
toolchain = toolchain_format % (ndk, target_base, host_kernel, "x86_64")
log.debug("Trying %s" % quote(toolchain))
if isdir(toolchain):
return toolchain
die("You have to specify --with-android-toolchain=" "/path/to/ndk/toolchain.")
@ -237,6 +281,58 @@ def android_lldb_server(target, host, ndk, lldb):
set_config("ANDROID_LLDB_SERVER", android_lldb_server)
option(
env="STLPORT_CPPFLAGS",
nargs=1,
help="Options compiler should pass for standard C++ library",
)
@depends("STLPORT_CPPFLAGS", ndk)
@imports(_from="os.path", _import="isdir")
def stlport_cppflags(value, ndk):
if value and len(value):
return value.split()
if not ndk:
return
ndk_base = os.path.join(ndk, "sources", "cxx-stl")
cxx_base = os.path.join(ndk_base, "llvm-libc++")
cxx_include = os.path.join(cxx_base, "libcxx", "include")
cxxabi_base = os.path.join(ndk_base, "llvm-libc++abi")
cxxabi_include = os.path.join(cxxabi_base, "libcxxabi", "include")
if not isdir(cxx_include):
# NDK r13 removes the inner "libcxx" directory.
cxx_include = os.path.join(cxx_base, "include")
if not isdir(cxx_include):
die("Couldn't find path to libc++ includes in the android ndk")
if not isdir(cxxabi_include):
# NDK r13 removes the inner "libcxxabi" directory.
cxxabi_include = os.path.join(cxxabi_base, "include")
if not isdir(cxxabi_include):
die("Couldn't find path to libc++abi includes in the android ndk")
# Add android/support/include/ for prototyping long double math
# functions, locale-specific C library functions, multibyte support,
# etc.
return [
# You'd think we'd want to use -stdlib=libc++, but this doesn't work
# (cf. https://bugzilla.mozilla.org/show_bug.cgi?id=1510897#c2)
# Using -stdlib=libc++ and removing some of the -I below also doesn't
# work because not everything that is in cxx_include comes in the C++
# header directory that comes with clang.
"-stdlib=libstdc++",
"-I%s" % cxx_include,
"-I%s" % os.path.join(ndk, "sources", "android", "support", "include"),
"-I%s" % cxxabi_include,
]
add_old_configure_assignment("stlport_cppflags", stlport_cppflags)
option(
env="STLPORT_LIBS",
nargs=1,
@ -244,27 +340,48 @@ option(
)
@depends("STLPORT_LIBS", ndk)
@depends("STLPORT_LIBS", ndk, android_cpu_arch)
@imports(_from="os.path", _import="isfile")
def stlport_libs(value, ndk):
def stlport_libs(value, ndk, android_cpu_arch):
if value and len(value):
return value.split()
if not ndk:
return
return ["-static-libstdc++"]
cxx_libs = os.path.join(
ndk, "sources", "cxx-stl", "llvm-libc++", "libs", android_cpu_arch
)
if not isfile(os.path.join(cxx_libs, "libc++_static.a")):
die("Couldn't find path to llvm-libc++ in the android ndk")
libs = [
"-L%s" % cxx_libs,
"-lc++_static",
]
for lib in ("c++abi", "unwind", "android_support"):
if isfile(os.path.join(cxx_libs, "lib%s.a" % lib)):
libs.append("-l%s" % lib)
return libs
set_config("STLPORT_LIBS", stlport_libs)
@depends(android_sysroot, android_toolchain)
def extra_toolchain_flags(android_sysroot, toolchain_dir):
@depends(android_system, android_sysroot, android_toolchain, android_version)
def extra_toolchain_flags(
android_system, android_sysroot, toolchain_dir, android_version
):
if not android_sysroot:
return []
flags = [
"--sysroot={}".format(android_sysroot),
"-isystem",
android_system,
"-isystem",
os.path.join(android_sysroot, "usr", "include"),
"--gcc-toolchain={}".format(toolchain_dir),
"-D__ANDROID_API__=%d" % android_version,
]
return flags
@ -272,9 +389,12 @@ def extra_toolchain_flags(android_sysroot, toolchain_dir):
add_old_configure_assignment("extra_android_flags", extra_toolchain_flags)
@depends(extra_toolchain_flags)
def bindgen_cflags_android(toolchain_flags):
return toolchain_flags
@depends(extra_toolchain_flags, stlport_cppflags)
def bindgen_cflags_android(toolchain_flags, stlport_flags):
if not toolchain_flags:
return
return toolchain_flags + stlport_flags
@depends("--with-android-googlevr-sdk", target)

Просмотреть файл

@ -123,7 +123,6 @@ option(
clang_search_path,
target,
target_sysroot.path,
android_version,
)
@checking("for clang for bindgen", lambda x: x.path if x else "not found")
def bindgen_clang_compiler(
@ -134,7 +133,6 @@ def bindgen_clang_compiler(
clang_search_path,
target,
sysroot_path,
android_version,
):
# When the target compiler is clang, use that, including flags.
if cxx_compiler.type == "clang":
@ -174,18 +172,14 @@ def bindgen_clang_compiler(
flags = []
if sysroot_path:
flags.extend(("--sysroot", sysroot_path))
info = check_compiler(
configure_cache, [clang_path] + flags, "C++", target, android_version
)
info = check_compiler(configure_cache, [clang_path] + flags, "C++", target)
# Usually, one check_compiler pass would be enough, but when cross-compiling
# and the host and target don't use the same default C++ standard, we don't
# get the --std flag, so try again. This is the same thing as valid_compiler()
# does in toolchain.configure.
if info.flags:
flags += info.flags
info = check_compiler(
configure_cache, [clang_path] + flags, "C++", target, android_version
)
info = check_compiler(configure_cache, [clang_path] + flags, "C++", target)
return namespace(
path=clang_path,
flags=flags + info.flags,

Просмотреть файл

@ -105,6 +105,7 @@ def compiler_class(compiler, host_or_target):
self,
dependable(flags),
extra_toolchain_flags,
stlport_cppflags,
dependable(header),
onerror,
configure_cache,
@ -115,6 +116,7 @@ def compiler_class(compiler, host_or_target):
compiler,
flags,
extra_flags,
stlport_flags,
header,
onerror,
configure_cache,
@ -122,6 +124,8 @@ def compiler_class(compiler, host_or_target):
flags = list(flags or [])
if is_target:
flags += extra_flags or []
if compiler.language == "C++":
flags += stlport_flags or []
header = header or ""
if isinstance(header, (list, tuple)):
header = "\n".join(header)

Просмотреть файл

@ -410,7 +410,7 @@ def same_arch_different_bits():
@imports(_from="mozbuild.shellutil", _import="quote")
@imports(_from="mozbuild.configure.constants", _import="OS_preprocessor_checks")
def check_compiler(configure_cache, compiler, language, target, android_version):
def check_compiler(configure_cache, compiler, language, target):
info = get_compiler_info(configure_cache, compiler, language)
flags = []
@ -445,13 +445,6 @@ def check_compiler(configure_cache, compiler, language, target, android_version)
# Check compiler target
# --------------------------------------------------------------------
has_target = False
if target.os == "Android" and android_version:
# This makes clang define __ANDROID_API__ and use versioned library
# directories from the NDK.
toolchain = "%s%d" % (target.toolchain, android_version)
else:
toolchain = target.toolchain
if info.type == "clang":
# Add the target explicitly when the target is aarch64 macosx, because
# the Xcode clang target is named differently, and we need to work around
@ -470,7 +463,7 @@ def check_compiler(configure_cache, compiler, language, target, android_version)
or not info.endianness
or info.endianness != target.endianness
):
flags.append("--target=%s" % toolchain)
flags.append("--target=%s" % target.toolchain)
has_target = True
# Add target flag when there is an OS mismatch (e.g. building for Android on
@ -479,7 +472,7 @@ def check_compiler(configure_cache, compiler, language, target, android_version)
elif target.os in OS_preprocessor_checks and (
not info.os or info.os != target.os
):
flags.append("--target=%s" % toolchain)
flags.append("--target=%s" % target.toolchain)
has_target = True
if not has_target and (not info.cpu or info.cpu != target.cpu):
@ -489,9 +482,9 @@ def check_compiler(configure_cache, compiler, language, target, android_version)
elif (info.cpu, target.cpu) in same_arch:
flags.append("-m64")
elif info.type == "clang-cl" and target.cpu == "aarch64":
flags.append("--target=%s" % toolchain)
flags.append("--target=%s" % target.toolchain)
elif info.type == "clang":
flags.append("--target=%s" % toolchain)
flags.append("--target=%s" % target.toolchain)
return namespace(
type=info.type,
@ -1206,7 +1199,6 @@ def compiler(
host_or_target,
sysroot,
macos_target,
android_version,
multiarch_dir,
winsysroot,
host,
@ -1222,7 +1214,6 @@ def compiler(
host_or_target,
sysroot,
macos_target,
android_version,
multiarch_dir,
winsysroot,
host,
@ -1244,11 +1235,7 @@ def compiler(
flags.extend(provided_compiler.flags)
info = check_compiler(
configure_cache,
wrapper + [compiler] + flags,
language,
host_or_target,
android_version,
configure_cache, wrapper + [compiler] + flags, language, host_or_target
)
if info.type == "clang" and language == "C++" and host_or_target.os == "OSX":
@ -1271,7 +1258,6 @@ def compiler(
wrapper + [compiler] + flags,
language,
host_or_target,
android_version,
)
except FatalCheckError:
pass
@ -1397,15 +1383,6 @@ def compiler(
% (host_or_target.alias, info.version)
)
if host_or_target.os == "Android":
# Need at least clang 8 for support for __ANDROID_API__ and versioned
# library directories from the NDK.
if info.type == "clang" and info.version < "8.0":
raise FatalCheckError(
"Only clang/llvm 8.0 or newer is supported for %s (found version %s)."
% (host_or_target.alias, info.version)
)
if info.flags:
raise FatalCheckError("Unknown compiler or compiler not supported.")
@ -1838,8 +1815,7 @@ def linker_ldflags_tmpl(host_or_target):
target,
target_sysroot,
target_multiarch_dir,
android_sysroot,
android_version,
android_platform,
c_compiler,
developer_options,
)
@ -1850,7 +1826,6 @@ def linker_ldflags_tmpl(host_or_target):
host_sysroot,
host_multiarch_dir,
dependable(None),
dependable(None),
host_c_compiler,
developer_options,
)
@ -1862,8 +1837,7 @@ def linker_ldflags_tmpl(host_or_target):
target,
sysroot,
multiarch_dir,
android_sysroot,
android_version,
android_platform,
c_compiler,
developer_options,
):
@ -1889,17 +1863,11 @@ def linker_ldflags_tmpl(host_or_target):
sysroot.path, multiarch_dir, sysroot.stdcxx_version
)
)
if android_sysroot:
# BFD/gold linkers need a manual --rpath-link for indirect
# dependencies.
flags += [
"-Wl,--rpath-link={}/usr/lib/{}".format(
android_sysroot, target.toolchain
),
"-Wl,--rpath-link={}/usr/lib/{}/{}".format(
android_sysroot, target.toolchain, android_version
),
]
if android_platform:
flags.append("-L{}/usr/lib".format(android_platform))
flags.append("-Wl,--rpath-link={}/usr/lib".format(android_platform))
flags.append("--sysroot")
flags.append(android_platform)
if (
developer_options
and linker

Просмотреть файл

@ -29,7 +29,7 @@ for v in ("OS_CPPFLAGS", "OS_CFLAGS", "DEBUG", "CLANG_PLUGIN", "OPTIMIZE", "FRAM
for flag in COMPILE_FLAGS[v]:
if flag == "-isystem":
flags.append("".join(COMPILE_FLAGS[v][idx : idx + 2]))
elif flag.startswith(("-m", "-I", "-isystem", "--sysroot=")) or flag == "-fPIC":
elif flag.startswith(("-m", "-I", "-isystem")) or flag == "-fPIC":
flags.append(flag)
idx += 1
COMPILE_FLAGS[v] = flags

Просмотреть файл

@ -56,6 +56,10 @@ class BaseCompileChecks(unittest.TestCase):
def extra_toolchain_flags():
return []
@depends(when=True)
def stlport_cppflags():
return []
@depends(when=True)
def linker_ldflags():
return []

Просмотреть файл

@ -29,11 +29,29 @@ x86_64-apple-darwin)
arch=x86_64
export MACOSX_DEPLOYMENT_TARGET=10.12
;;
armv7-linux-android|i686-linux-android)
armv7-linux-android)
api_level=16
ndk_target=arm-linux-androideabi
ndk_prefix=arm-linux-androideabi
ndk_arch=arm
;;
aarch64-linux-android|x86_64-linux-android)
aarch64-linux-android)
api_level=21
ndk_target=aarch64-linux-android
ndk_prefix=aarch64-linux-android
ndk_arch=arm64
;;
i686-linux-android)
api_level=16
ndk_target=i686-linux-android
ndk_prefix=x86
ndk_arch=x86
;;
x86_64-linux-android)
api_level=21
ndk_target=x86_64-linux-android
ndk_prefix=x86_64
ndk_arch=x86_64
;;
esac
@ -67,18 +85,25 @@ case "$target" in
PATH="$PATH:$PWD"
;;
*-linux-android)
target=$target$api_level
# These flags are only necessary to pass the cmake tests. They don't end up
# actually using libgcc, so use an empty library instead of trying to find
# where it is in the NDK.
if [ "$what" = "compiler-rt" ]; then
exe_linker_flags="--rtlib=libgcc -L$PWD"
touch libgcc.a
fi
cflags="
--gcc-toolchain=$MOZ_FETCHES_DIR/android-ndk/toolchains/$ndk_prefix-4.9/prebuilt/linux-x86_64
-isystem $MOZ_FETCHES_DIR/android-ndk/sysroot/usr/include/$ndk_target
-isystem $MOZ_FETCHES_DIR/android-ndk/sysroot/usr/include
-D__ANDROID_API__=$api_level
"
# These flags are only necessary to pass the cmake tests.
exe_linker_flags="
--rtlib=libgcc
-L$MOZ_FETCHES_DIR/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$ndk_target/$api_level
-L$MOZ_FETCHES_DIR/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/$ndk_target
"
EXTRA_CMAKE_FLAGS="
$EXTRA_CMAKE_FLAGS
-DCMAKE_SYSROOT=$MOZ_FETCHES_DIR/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot
-DCMAKE_SYSROOT=$MOZ_FETCHES_DIR/android-ndk/platforms/android-$api_level/arch-$ndk_arch
-DCMAKE_LINKER=$MOZ_FETCHES_DIR/clang/bin/ld.lld
-DCMAKE_C_FLAGS='-fPIC $cflags'
-DCMAKE_ASM_FLAGS='$cflags'
-DCMAKE_CXX_FLAGS='-fPIC -Qunused-arguments $cflags'
-DCMAKE_EXE_LINKER_FLAGS='-fuse-ld=lld $exe_linker_flags'
-DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld
-DANDROID=1