From 77c2273e9240cad01a1a2d75ee9b499c1db1af61 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sun, 24 Sep 2017 16:11:48 -0700 Subject: [PATCH 1/2] build: fix library version and compile flags on Android Compiling a library with -fPIE won't do, and on Android libraries are not versioned. --- common.gypi | 8 ++++---- configure.py | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/common.gypi b/common.gypi index 78a57d929198be..a934b4e626ec51 100644 --- a/common.gypi +++ b/common.gypi @@ -156,8 +156,8 @@ 'ldflags': [ '-Wl,-bbigtoc' ], }], ['OS == "android"', { - 'cflags': [ '-fPIE' ], - 'ldflags': [ '-fPIE', '-pie' ] + 'cflags': [ '-fPIC' ], + 'ldflags': [ '-fPIC' ] }], ], 'msvs_settings': { @@ -216,8 +216,8 @@ ], },], ['OS == "android"', { - 'cflags': [ '-fPIE' ], - 'ldflags': [ '-fPIE', '-pie' ] + 'cflags': [ '-fPIC' ], + 'ldflags': [ '-fPIC' ] }], ], 'msvs_settings': { diff --git a/configure.py b/configure.py index f1badfdb932bb9..d8e27a2231f1fd 100755 --- a/configure.py +++ b/configure.py @@ -1103,14 +1103,17 @@ def configure_node(o): o['variables']['node_shared'] = b(options.shared) node_module_version = getmoduleversion.get_version() - if sys.platform == 'darwin': + if options.dest_os == 'android': + shlib_suffix = 'so' + elif sys.platform == 'darwin': shlib_suffix = '%s.dylib' elif sys.platform.startswith('aix'): shlib_suffix = '%s.a' else: shlib_suffix = 'so.%s' + if '%s' in shlib_suffix: + shlib_suffix %= node_module_version - shlib_suffix %= node_module_version o['variables']['node_module_version'] = int(node_module_version) o['variables']['shlib_suffix'] = shlib_suffix From f18b9dafbcc37110c3ed9c0a6da71f1fbd9129b1 Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Sun, 24 Sep 2017 16:13:45 -0700 Subject: [PATCH 2/2] build: on Android, use android log library to print stack traces And other errors like lost promises --- src/node_errors.cc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/node_errors.cc b/src/node_errors.cc index d3a409b1ab455a..4fe7edea8a8886 100644 --- a/src/node_errors.cc +++ b/src/node_errors.cc @@ -10,6 +10,10 @@ #include "node_v8_platform-inl.h" #include "util-inl.h" +#ifdef __ANDROID__ +#include +#endif + namespace node { using errors::TryCatchScope; @@ -413,6 +417,8 @@ void PrintErrorString(const char* format, ...) { // Don't include the null character in the output CHECK_GT(n, 0); WriteConsoleW(stderr_handle, wbuf.data(), n - 1, nullptr, nullptr); +#elif defined(__ANDROID__) + __android_log_vprint(ANDROID_LOG_ERROR, "nodejs", format, ap); #else vfprintf(stderr, format, ap); #endif