Repository navigation
node-v5.0.0-rc.1 can't work on Android L due to error: only position independent executables (PIE) are supported #3581
Description
Activity
Can't you just set the standard
CFLAGSandLDFLAGSenvironment variables before compiling?- addedbuildIssues and PRs related to Node.js builds or CI infrastructure.Issues and PRs related to Node.js builds or CI infrastructure.armIssues and PRs related to the ARM architecture.Issues and PRs related to the ARM architecture.
on Oct 29, 2015 I see flag settings in these file, and it seemed node-v5.0.0-rc.1 already considered PIE, but what's the problem to the end?
'conditions': [ ['OS == "android"', { 'cflags': [ '-fPIE' ], 'ldflags': [ '-fPIE', '-pie' ] }] ]
['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64" or target_arch=="ia32") and component!="shared_library"', { 'cflags': [ '-fPIE', ], 'ldflags': [ '-pie', ], }],
cc @evanlucas and @Gioyik maybe?
I've fixed this issue by modified
<node-v5.0.0-rc.1>\common.gypi.I added -fPIE for cflags and -pie for ldflags on Android.
'target_defaults': { 'default_configuration': 'Release', 'configurations': { 'Debug': { 'variables': { 'v8_enable_handle_zapping': 1, }, 'defines': [ 'DEBUG', '_DEBUG' ], 'cflags': [ '-g', '-O0' ], 'conditions': [ ['target_arch=="x64"', { 'msvs_configuration_platform': 'x64', }], ['OS=="aix"', { 'cflags': [ '-gxcoff' ], 'ldflags': [ '-Wl,-bbigtoc' ], }], ['OS == "android"', { 'cflags': [ '-fPIE' ], 'ldflags': [ '-fPIE', '-pie' ] }] ], 'msvs_settings': { 'VCCLCompilerTool': { 'RuntimeLibrary': 1, # static debug 'Optimization': 0, # /Od, no optimization 'MinimalRebuild': 'false', 'OmitFramePointers': 'false', 'BasicRuntimeChecks': 3, # /RTC1 }, 'VCLinkerTool': { 'LinkIncremental': 2, # enable incremental linking }, }, 'xcode_settings': { 'GCC_OPTIMIZATION_LEVEL': '0', # stop gyp from defaulting to -Os }, }, 'Release': { 'variables': { 'v8_enable_handle_zapping': 0, }, 'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ], 'conditions': [ ['target_arch=="x64"', { 'msvs_configuration_platform': 'x64', }], ['OS=="solaris"', { `# pull in V8's postmortem metadata` 'ldflags': [ '-Wl,-z,allextract' ] }], ['OS!="mac" and OS!="win"', { 'cflags': [ '-fno-omit-frame-pointer' ], }], ['OS == "android"', { 'cflags': [ '-fPIE' ], 'ldflags': [ '-fPIE', '-pie' ] }] ],
A pull request that updates common.gypi would be fine IMO. Please see CONTRIBUTING.md for details.
Hey @kikijhu , I had the same problem with node v4.2.4, and it worked adding PIE flags as you said. Thanks!
@IvanGaravito Glad to help you : )
I modified the solution.
I add a flag cflag-pie in ./android-configure
If you want to compile the code with -fPIE, just set it as true, otherwise just set it as false../configure \ --dest-cpu=arm \ --dest-os=android \ --cflag-pie=trueModify ./configure
def configure_node(o): if options.dest_os == 'android': o['variables']['OS'] = 'android' o['variables']['cflag_pie'] = options.cflag_pie parser.add_option('--cflag-pie', action='store_true', dest='cflag_pie', help='add cflags -fPIE')Modify ./common.gypi
'target_defaults': { 'default_configuration': 'Release', 'configurations': { 'Debug': { 'variables': { 'v8_enable_handle_zapping': 1, }, ... ['cflag_pie == "true"', { 'cflags': [ '-fPIE' ], 'ldflags': [ '-fPIE', '-pie' ] }] ],... }, 'Release': { 'variables': { 'v8_enable_handle_zapping': 0, }, 'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ], ... ['cflag_pie == "true"', { 'cflags': [ '-fPIE' ], 'ldflags': [ '-fPIE', '-pie' ] }] ],./config.gypi will contains the flag
# Do not edit. Generated by the configure script. { 'target_defaults': { 'cflags': [], 'default_configuration': 'Release', 'defines': [], 'include_dirs': [], 'libraries': []}, 'variables': { 'OS': 'android', 'arm_float_abi': 'default', 'arm_fpu': 'vfpv3', 'arm_thumb': 0, 'arm_version': '7', 'asan': 0, 'cflag_pie': 'true', 'gas_version': '2.24', 'host_arch': 'x64', 'icu_small': 'false', 'node_byteorder': 'little', 'node_enable_v8_vtunejit': 'false', 'node_install_npm': 'true', 'node_prefix': '/usr/local', 'node_release_urlbase': '', 'node_shared_http_parser': 'false', 'node_shared_libuv': 'false', 'node_shared_openssl': 'false', 'node_shared_zlib': 'false', 'node_tag': '', 'node_use_dtrace': 'false', 'node_use_etw': 'false', 'node_use_lttng': 'false', 'node_use_openssl': 'true', 'node_use_perfctr': 'false', 'openssl_fips': '', 'openssl_no_asm': 0, 'python': '/home/kiki/node.js/node-v5.4.1/android-toolchain/bin/python', 'target_arch': 'arm', 'v8_enable_gdbjit': 0, 'v8_enable_i18n_support': 0, 'v8_no_strict_aliasing': 1, 'v8_optimized_debug': 0, 'v8_random_seed': 0, 'v8_use_snapshot': 'true', 'want_separate_host_toolset': 1}}Reacted by Bsegault@kikijhu Mind making a Pull Request for this? :D
@bnoordhuis @Fishrock123 I'm behind the firewall in company, so can't pull code from github . Worse still, I can't even access github at home due to the firewall of China
>_<.
I will be glad if someone contribute these changes to developer branch.Is there an Android developer who wants to take this on? @kikijhu's changes look useful but no one on the core team develops on or for Android, as far as I'm aware.
@bnoordhuis @kikijhu I was looking just for your answer. Works fine for me with node v4.4.0. Will test on node 5 & do a pull request as soon as possible. Thanks a lot =D
I'm seeking some feedback about how Node.js is used on Android if anyone watching this thread would like to tell us about it: nodejs/build#359
Closing, we're building with
-fPIE -fpieas of commit 271201f.
issue description
I downloaded the latest node-v5.0.0-rc.1 and make it with Android NDK r10e, but it can’t work on Android L.
compile environment
error log
solution
I searched on Google for solution, found it, to add two flags in Android.mk.
But it seems node-v5.0.0-rc.1 just uses NDK toolchain, not use NDK to compile a executable file.
So how to add these two flags to node-v5.0.0-rc.1?