# Copyright (c) 2023 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("$build_root/config/aosp/config.gni") import("$build_root/config/clang/clang.gni") import("$build_root/config/compiler/compiler.gni") assert(is_android) config("compiler") { if (current_cpu == "arm64") { abi_target = "aarch64-linux-android" compile_api_level = aosp64_ndk_api_level } else { assert(false, "Architecture not supported") } cflags = [ "--target=$abi_target", "-isystem" + rebase_path("$aosp_ndk_root/sysroot/usr/include/$abi_target", root_build_dir), "-D__ANDROID_API__=$compile_api_level", ] if (compile_api_level < 20) { cflags += [ "-DHAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC=1" ] } asmflags = cflags ldflags = [ "--target=$abi_target", "-Wl,--no-undefined", "-Wl,--exclude-libs=libgcc.a", "-Wl,--exclude-libs=libc++_static.a", "-Wl,--exclude-libs=libvpx_assembly_arm.a", ] } config("runtime_config") { cflags_cc = [] cflags_cc = [] if (aosp_ndk_major_version >= 13) { libcxx_include_path = rebase_path("$aosp_libcpp_root/include", root_build_dir) libcxxabi_include_path = rebase_path("$aosp_ndk_root/sources/cxx-stl/llvm-libc++abi/include", root_build_dir) } else { libcxx_include_path = rebase_path("$aosp_libcpp_root/libcxx/include", root_build_dir) libcxxabi_include_path = rebase_path( "$aosp_ndk_root/sources/cxx-stl/llvm-libc++abi/libcxxabi/include", root_build_dir) } cflags_cc += [ "-isystem" + libcxx_include_path, "-isystem" + libcxxabi_include_path, ] defines = [ "__GNU_SOURCE=1", # Necessary for clone(). ] ldflags = [ "-nostdlib" ] lib_dirs = [ aosp_libcpp_lib_dir ] libs = [] libs += [ "c++_static" ] libs += [ "c++abi" ] # Manually link the libgcc.a that the cross compiler uses. This is # absolute because the linker will look inside the sysroot if it's not. libs += [ rebase_path(aosp_libgcc_file), "c", ] ldflags += [ "-Wl,--warn-shared-textrel" ] } config("executable_config") { cflags = [ "-fPIE" ] asmflags = [ "-fPIE" ] ldflags = [ "-pie" ] }