Merge changes I549d78ba,I2a3bbe64,Id48dabf8
* changes:
gn2bp: Add linker script to modules
gn2bp: Add missing linker flags
gn2bp: Fix C++ warning showing up as errors when compiling cronet tests
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index bb581d0..b463052 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -1038,6 +1038,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
@@ -2725,6 +2741,21 @@
"-Wl,--gc-sections",
"-Wl,--icf=all",
"-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
stem: "libcronet.108.0.5359.128",
target: {
@@ -4169,6 +4200,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
@@ -4309,6 +4356,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
@@ -4343,6 +4406,7 @@
cflags: [
"-DGOOGLE_PROTOBUF_NO_RTTI",
"-Wno-ambiguous-reversed-operator",
+ "-Wno-c++11-narrowing",
"-Wno-error=return-type",
"-Wno-macro-redefined",
"-Wno-missing-field-initializers",
@@ -5942,6 +6006,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
@@ -6412,6 +6492,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
@@ -6943,6 +7039,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
@@ -7126,6 +7238,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
@@ -12709,6 +12837,22 @@
"-Wl,--as-needed",
"-Wl,--gc-sections",
"-Wl,--icf=all",
+ "-Wl,--script,external/cronet/base/android/library_loader/anchor_functions.lds",
+ "-Wl,-wrap,asprintf",
+ "-Wl,-wrap,calloc",
+ "-Wl,-wrap,free",
+ "-Wl,-wrap,getcwd",
+ "-Wl,-wrap,malloc",
+ "-Wl,-wrap,malloc_usable_size",
+ "-Wl,-wrap,memalign",
+ "-Wl,-wrap,posix_memalign",
+ "-Wl,-wrap,pvalloc",
+ "-Wl,-wrap,realloc",
+ "-Wl,-wrap,realpath",
+ "-Wl,-wrap,strdup",
+ "-Wl,-wrap,strndup",
+ "-Wl,-wrap,valloc",
+ "-Wl,-wrap,vasprintf",
],
target: {
android_arm: {
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index 5122569..9172fb4 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -159,14 +159,6 @@
# Additional arguments to apply to Android.bp rules.
additional_args = {
- # TODO: remove if not needed.
- 'cronet_aml_components_cronet_android_cronet': [
- # linker_scripts property is not available in tm-mainline-prod.
- # So use ldflags to specify linker script.
- ('ldflags',{
- get_linker_script_ldflag('base/android/library_loader/anchor_functions.lds'),
- }),
- ],
'cronet_aml_net_net': [
('export_static_lib_headers', {
'cronet_aml_net_third_party_quiche_quiche',
@@ -1305,10 +1297,17 @@
cflags |= set("-D%s" % define.replace("\"", "\\\"") for define in defines)
return cflags
-def set_module_flags(module, module_type, cflags, defines, ldflags):
+def _set_linker_script(module, libs):
+ for lib in libs:
+ if lib.endswith(".lds"):
+ module.ldflags.add(get_linker_script_ldflag(gn_utils.label_to_path(lib)))
+
+def set_module_flags(module, module_type, cflags, defines, ldflags, libs):
module.cflags.update(_get_cflags(cflags, defines))
if module_type != 'cc_object':
- module.ldflags.update({flag for flag in ldflags if flag in ldflag_allowlist})
+ module.ldflags.update({flag for flag in ldflags
+ if flag in ldflag_allowlist or flag.startswith("-Wl,-wrap,")})
+ _set_linker_script(module, libs)
# TODO: implement proper cflag parsing.
for flag in cflags:
if '-std=' in flag:
@@ -1400,12 +1399,13 @@
module.rtti = target.rtti
if target.type in gn_utils.LINKER_UNIT_TYPES:
- set_module_flags(module, module.type, target.cflags, target.defines, target.ldflags)
+ set_module_flags(module, module.type, target.cflags, target.defines, target.ldflags, target.libs)
set_module_include_dirs(module, target.cflags, target.include_dirs)
# TODO: set_module_xxx is confusing, apply similar function to module and target in better way.
for arch_name, arch in target.arch.items():
+ # TODO(aymanm): Make libs arch-specific.
set_module_flags(module.target[arch_name], module.type,
- arch.cflags, arch.defines, arch.ldflags)
+ arch.cflags, arch.defines, arch.ldflags, [])
# -Xclang -target-feature -Xclang +mte are used to enable MTE (Memory Tagging Extensions).
# Flags which does not start with '-' could not be in the cflags so enabling MTE by
# -march and -mcpu Feature Modifiers. MTE is only available on arm64. This is needed for
@@ -1675,6 +1675,7 @@
'-Wno-ambiguous-reversed-operator', # needed for icui18n
'-Wno-unreachable-code-loop-increment', # needed for icui18n
'-fPIC',
+ '-Wno-c++11-narrowing',
]
# Chromium builds do not add a dependency for headers found inside the
# sysroot, so they are added globally via defaults.