Skip to content

Commit

Permalink
Merge "Update to NDK r26C" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
primiano authored and Gerrit Code Review committed Feb 26, 2024
2 parents 20f1b36 + 60571c2 commit dbf6cd4
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 69 deletions.
1 change: 1 addition & 0 deletions buildtools/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,7 @@ source_set("libunwindstack") {
cflags += [
"-Wno-deprecated-declarations",
"-Wno-vla-cxx-extension",
"-Wno-c99-designator",
]
}
public_configs = [ ":libunwindstack_config" ]
Expand Down
47 changes: 8 additions & 39 deletions gn/standalone/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -352,57 +352,26 @@ config("default") {
"-D__ANDROID_API__=${android_api_level}",
"--target=$android_abi_target",
]
cflags_cc += [
"-isystem$android_ndk_root/sources/cxx-stl/llvm-libc++/include",
"-isystem$android_ndk_root/sources/android/support/include",
"-isystem$android_ndk_root/sources/cxx-stl/llvm-libc++abi/include",
]

# Keep these include paths *after* the above to prevent the wrong include
# being used for some headers (e.g. math.h).
# We need to add to each language (cflags_c, cflags_cc etc.) separately as
# we added to cflags directly, these inludes would end up before the
# languge and thus the above includes.
sysroot_cflags = [
"-isystem$android_compile_sysroot/$android_compile_sysroot_subdir",
"-isystem$android_compile_sysroot",
]
cflags_c += sysroot_cflags
cflags_cc += sysroot_cflags
cflags_cc += [ "-isystem$android_compile_sysroot/c++/v1" ]

android_lib_dir = "$android_compile_sysroot/usr/lib/$android_abi_target/$android_api_level"
ldflags += [
"-Wl,-z,nocopyreloc",
"-gcc-toolchain",
"$android_toolchain_root",
"--sysroot=$android_ndk_root/$android_link_sysroot_subdir",
"--sysroot=$android_compile_sysroot",
"-B${android_lib_dir}",
"--target=$android_abi_target",
"-Wl,--exclude-libs,libunwind.a",
"-Wl,--exclude-libs,libgcc.a",
"-Wl,--exclude-libs,libc++_static.a",
"-Wl,--no-undefined",
"-Wl,-z,noexecstack",
"-Wl,-z,relro",
"-Wl,-z,now",
"-Wl,--warn-shared-textrel",
"-Wl,--fatal-warnings",

# New NDKs need setting this to not give "unable to find library -lc++".
# See https://github.com/android/ndk/issues/951#issuecomment-501017894.
"-nostdlib++",
]
lib_dirs = [
"$android_ndk_root/sources/cxx-stl/llvm-libc++/libs/$android_app_abi",
# From NDK docs: "although the option uses the name "libstdc++" for
# historical reasons, this is correct for libc++ as well.
"-static-libstdc++",
]
libs += [
"gcc",
"c++_static",
"c++abi",
]

if (current_cpu == "arm") {
# New NDKs don't have libandroid_support for arm64.
libs += [ "android_support" ]
}
lib_dirs = [ android_lib_dir ]
}
}

Expand Down
24 changes: 2 additions & 22 deletions gn/standalone/android.gni
Original file line number Diff line number Diff line change
Expand Up @@ -28,40 +28,20 @@ declare_args() {

declare_args() {
android_llvm_dir = "$android_ndk_root/toolchains/llvm/prebuilt/$android_host"
android_clangrt_dir = "$android_llvm_dir/lib64/clang/9.0.9/lib/linux"
android_compile_sysroot = "$android_ndk_root/sysroot/usr/include"
android_clangrt_dir = "$android_llvm_dir/lib/clang/17/lib/linux"
android_compile_sysroot = "$android_llvm_dir/sysroot"

if (current_cpu == "x86") {
android_abi_target = "i686-linux-android"
android_compile_sysroot_subdir = "i686-linux-android"
android_link_sysroot_subdir =
"platforms/android-${android_api_level}/arch-x86"
android_prebuilt_arch = "android-x86"
android_toolchain_root = "$android_ndk_root/toolchains/x86-${_android_toolchain_version}/prebuilt/$android_host"
android_llvm_arch = "i686"
} else if (current_cpu == "arm") {
android_abi_target = "arm-linux-androideabi"
android_compile_sysroot_subdir = "arm-linux-androideabi"
android_link_sysroot_subdir =
"platforms/android-${android_api_level}/arch-arm"
android_prebuilt_arch = "android-arm"
android_toolchain_root = "$android_ndk_root/toolchains/arm-linux-androideabi-${_android_toolchain_version}/prebuilt/$android_host"
android_llvm_arch = "arm"
} else if (current_cpu == "x64") {
android_abi_target = "x86_64-linux-android"
android_compile_sysroot_subdir = "x86_64-linux-android"
android_link_sysroot_subdir =
"platforms/android-${android_api_level}/arch-x86_64"
android_prebuilt_arch = "android-x86_64"
android_toolchain_root = "$android_ndk_root/toolchains/x86_64-${_android_toolchain_version}/prebuilt/$android_host"
android_llvm_arch = "x86_64"
} else if (current_cpu == "arm64") {
android_abi_target = "aarch64-linux-android"
android_compile_sysroot_subdir = "aarch64-linux-android"
android_link_sysroot_subdir =
"platforms/android-${android_api_level}/arch-arm64"
android_prebuilt_arch = "android-arm64"
android_toolchain_root = "$android_ndk_root/toolchains/aarch64-linux-android-${_android_toolchain_version}/prebuilt/$android_host"
android_llvm_arch = "aarch64"
} else {
assert(false, "Need android libgcc support for this arch.")
Expand Down
4 changes: 2 additions & 2 deletions gn/standalone/toolchain/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -185,11 +185,11 @@ declare_args() {
} else {
target_ar = "ar"
if (is_android) {
target_ar = "$android_toolchain_root/bin/$android_abi_target-ar"
target_ar = "$android_llvm_dir/bin/llvm-ar"
target_cc = "$android_llvm_dir/bin/clang"
target_cxx = "$android_llvm_dir/bin/clang++"
target_linker = "$android_llvm_dir/bin/ld.lld"
target_strip = "$android_toolchain_root/bin/$android_abi_target-strip"
target_strip = "$android_llvm_dir/bin/llvm-strip"
} else {
assert(_target_triplet != "",
"target_triplet must be non-empty when cross-compiling")
Expand Down
18 changes: 12 additions & 6 deletions tools/install-build-deps
Original file line number Diff line number Diff line change
Expand Up @@ -320,13 +320,13 @@ BUILD_DEPS_ANDROID = [
# Android NDK
Dependency(
'buildtools/ndk.zip',
'https://dl.google.com/android/repository/android-ndk-r21e-darwin-x86_64.zip',
'437278103a3db12632c05b1be5c41bbb8522791a67e415cc54411a65366f499d',
'https://dl.google.com/android/repository/android-ndk-r26c-darwin.zip',
'312756dfcbdbf389d35d651e17ca98683bd36cb83cc7bf7ad51cac5c06bd064b',
'darwin', 'all'),
Dependency(
'buildtools/ndk.zip',
'https://dl.google.com/android/repository/android-ndk-r21e-linux-x86_64.zip',
'ad7ce5467e18d40050dc51b8e7affc3e635c85bd8c59be62de32352328ed467e',
'https://dl.google.com/android/repository/android-ndk-r26c-linux.zip',
'6d6e659834d28bb24ba7ae66148ad05115ebbad7dabed1af9b3265674774fcf6',
'linux', 'x64'),
]

Expand Down Expand Up @@ -509,10 +509,16 @@ def HashLocalFile(path):


def ExtractZipfilePreservePermissions(zf, info, path):
zf.extract(info.filename, path=path)
target_path = os.path.join(path, info.filename)
mode = info.external_attr >> 16
S_IFLNK = 0o120000 # symbolic link
if (mode & S_IFLNK) == S_IFLNK:
dst = zf.read(info).decode()
os.symlink(dst, target_path)
return
zf.extract(info.filename, path=path)
min_acls = 0o755 if info.filename.endswith('/') else 0o644
os.chmod(target_path, (info.external_attr >> 16) | min_acls)
os.chmod(target_path, mode | min_acls)


def IsGitRepoCheckoutOutAtRevision(path, revision):
Expand Down

0 comments on commit dbf6cd4

Please sign in to comment.