Skip to content

Instantly share code, notes, and snippets.

@Piasy
Created September 11, 2019 09:03
Show Gist options
  • Save Piasy/4effa9057eb0faff8231d34e589478c3 to your computer and use it in GitHub Desktop.
Save Piasy/4effa9057eb0faff8231d34e589478c3 to your computer and use it in GitHub Desktop.

Revisions

  1. Piasy created this gist Sep 11, 2019.
    82 changes: 82 additions & 0 deletions android_use_static_webrtc.diff
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,82 @@
    From 9925be8afd008325875a0b131ac51f4353564ba6 Mon Sep 17 00:00:00 2001
    From: Piasy <[email protected]>
    Date: Wed, 11 Sep 2019 16:37:19 +0800
    Subject: [PATCH] Android: disable in-tree libc++

    ---
    config/android/BUILD.gn | 38 +++++++++++++++++++++++++++++++++++---
    config/c++/c++.gni | 2 +-
    2 files changed, 36 insertions(+), 4 deletions(-)

    diff --git a/config/android/BUILD.gn b/config/android/BUILD.gn
    index 233e8b0e7..63f047697 100644
    --- a/config/android/BUILD.gn
    +++ b/config/android/BUILD.gn
    @@ -105,9 +105,30 @@ config("runtime_library") {
    # arm-linux-androideabi-4.4.3 toolchain (circa Gingerbread) will exhibit
    # strange errors. The include ordering here is important; change with
    # caution.
    - cflags_cc = [ "-isystem" +
    - rebase_path("$android_ndk_root/sources/android/support/include",
    - root_build_dir) ]
    + cflags_cc = []
    + if (!use_custom_libcxx) {
    + if (android_ndk_major_version >= 13) {
    + libcxx_include_path =
    + rebase_path("$android_libcpp_root/include", root_build_dir)
    + libcxxabi_include_path = rebase_path(
    + "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/include",
    + root_build_dir)
    + } else {
    + libcxx_include_path =
    + rebase_path("$android_libcpp_root/libcxx/include", root_build_dir)
    + libcxxabi_include_path = rebase_path(
    + "$android_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/include",
    + root_build_dir)
    + }
    + cflags_cc += [
    + "-nostdinc++",
    + "-isystem" + libcxx_include_path,
    + "-isystem" + libcxxabi_include_path,
    + ]
    + }
    + cflags_cc += [ "-isystem" + rebase_path(
    + "$android_ndk_root/sources/android/support/include",
    + root_build_dir) ]

    defines = [
    "__GNU_SOURCE=1", # Necessary for clone().
    @@ -117,6 +138,17 @@ config("runtime_library") {
    lib_dirs = [ android_libcpp_lib_dir ]

    libs = []
    + if (!use_custom_libcxx) {
    + # The libc++ runtime library (must come first).
    + # ASan needs to dynamically link to libc++ even in static builds so
    + # that it can interpose operator new.
    + if (is_component_build || is_asan) {
    + libs += [ "c++_shared" ]
    + } else {
    + libs += [ "c++_static" ]
    + }
    + libs += [ "c++abi" ]
    + }
    libs += [ "android_support" ]

    # arm builds of libc++ starting in NDK r12 depend on unwind.
    diff --git a/config/c++/c++.gni b/config/c++/c++.gni
    index b639ca779..ffa6c8ac2 100644
    --- a/config/c++/c++.gni
    +++ b/config/c++/c++.gni
    @@ -11,7 +11,7 @@ declare_args() {
    # Don't check in changes that set this to false for more platforms; doing so
    # is not supported.
    use_custom_libcxx =
    - is_fuchsia || is_android || is_mac || (is_ios && !use_xcode_clang) ||
    + is_fuchsia || is_mac || (is_ios && !use_xcode_clang) ||
    (is_win && is_clang) ||
    (is_linux &&
    (!is_chromeos || default_toolchain != "//build/toolchain/cros:target"))
    --
    2.20.1