Hi termux experts,
I am facing an installation issue when doing my experiments: npm i bufferutil --save
node-gyp 3.3.1 was installed successfully by npm install -g node-gyp
$uname -a
Linux localhost 3.4.0-g09a22c6 #1 SMP PREEMPT Wed Apr 20 00:06:25 UTC 2016 armv7l Android
app: termux , linux 3.4.0-g1680ab8 in android 6.0.1
gcc: 6.1.0
make: 4.2
node v6.2.1
npm v3.9.5
node-gyp v3.3.1
Command to reproduce:
npm i bufferutil --save
Is it lacking of kerberos lib: libkrb5-dev ?
The formatting got messed up here. Could you:
apt update && apt upgrade first, so that you are running with updated packages)?uname -a here?I ran into this when trying to npm install node-sass. You should try running your install with verbose options, to see the full command behind SOLINK. If you see both -shared -rdynamic and -pie in the linker flags, have a look at the commit discussion here.
Workaround (if this is the issue): find your ~/.node-gyp/<version>/include/node/common.gypi, remove -pie from ldflags for android builds (for a better approach, see discussion). That should allow addon linking to proceed again..
@clausreinke Thank you for your solution, I am able to build bufferutil module on my Nexus 7 2013 Android 6 now. Have you commit your fix ? so that we don't need to change the flags manually.
Btw, I was caught a bad cold for recent days, sorry for my late response.
I've asked the original committer to test and apply a fix, as it is his code, and i've got no experience with node-gyp. I suggest to follow that commit discussion to see when this issue is fixed.
@clausreinke What is the best way forward here? Should we try using a patch in the node package in termux, and then trying to get it upstream?
No, no. After I've created simple JavaScript script to test:
var sqlite = require('sqlite3');
And it throws an error:
module.js:568
return process.dlopen(module, path._makeLong(filename));
^
Error: dlopen failed: cannot locate symbol "uv_close" referenced by "/data/data/com.termux/files/home/project/node_modules/sqlite3/lib/binding/node-v48-android-arm64/node_sqlite3.node"...
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/data/data/com.termux/files/home/project/www/node_modules/sqlite3/lib/sqlite3.js:4:15)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
@fornwall It is a pity that the original committer has gone quiet - the problem is in his commit. It would be simple enough to make a pull request based on my suggested fix, but (1) the nodejs repo has rules which includes testing requirements and (2) might include android-only patches on a best-effort basis, giving no guarantees that a patch might not make things worse for someone else.
I do not currently have a setup for building and testing nodejs itself (or can we do that in termux?-) for/on android and on a supported platform.
@clausreinke Does this look like the correct patch?
diff -u -r ../node-v6.5.0/common.gypi ./common.gypi
--- ../node-v6.5.0/common.gypi> 2016-08-26 11:27:16.000000000 -0400
+++ ./common.gypi> 2016-09-14 06:35:35.551380791 -0400
@@ -78,7 +78,12 @@
}],
['OS == "android"', {
'cflags': [ '-fPIE' ],
- 'ldflags': [ '-fPIE', '-pie' ]
+ 'ldflags': [ '-fPIE' ],
+ 'target_conditions': [
+ ['_type == "executable"', {
+ 'ldflags': [ '-pie' ]
+ }]
+ ]
}],
['node_shared=="true"', {
'msvs_settings': {
We could add it to the nodejs package in Termux, and propose it for inclusion upstream later.
@fornwall Looks about right, but there used to be two occurrences (a normal and a debug configuration?).
I tried to guess the syntax from similar stuff elsewhere in the file, and tested it for building packages on termux (on android). If it also works for you building node for termux (android), that would be two good points in favour of this change. If there was a way to run node's testsuite on android, a pull-request should be pretty obvious, as that includes building packages, which is what this issue is all about..
@clausreinke I realized that patching common.gypi in the nodejs source folder before building, does not affect the file that ends up in ~/.node-gyp/6.5.0/include/node/common.gypi, right? Do you know where that file comes from?
@fornwall That connection happens when the patch enters the newest release. See this comment, or the gist it links to. Node-gyp fetches those files from https://nodejs.org/download/release/vX.Y.Z/node-vX.Y.Z-headers.tar.gz.
Until then, you need to patch both copies, it seems.
@rafis Note that the process.dlopen issue was another problem (https://github.com/termux/termux-packages/issues/462) that has now been fixed.
@fornwall, thank you very much! Now everyhthing works. Only need to fix this issue (I had to mangle _common.gypi_ manually, I havent tried 'target_conditions', I just remove '-pie' from 'ldflags').
I don't think this is an urgent issue anymore after switching to clang, as clang only emits a warning when -pie is added needlessly. So I'm closing this issue as the problem is upstream!
@fornwall, thank you very much! Now everyhthing works. Only need to fix this issue (I had to mangle _common.gypi_ manually, I havent tried 'target_conditions', I just remove '-pie' from 'ldflags').
I have remove -pie flag, but still error cannot linker
@fornwall
@ardyfeb see #737.