Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made the package compile in termux on android #198

Closed
wants to merge 3 commits into from
Closed

Made the package compile in termux on android #198

wants to merge 3 commits into from

Conversation

arrkiin
Copy link

@arrkiin arrkiin commented Nov 11, 2017

To compile the package in the termux app on android you have to compile the sources with the compiler flag "-fPIC". I added this in an special condition branch. The compiled package is working properly within the following constellation ijavascript -> jp-kernel -> jmp -> zeromq.js

@n-riesco
Copy link
Contributor

@rolftimmermans Would it make sense to move the -fPIC in this PR into the zmq_external case you introduced recently?

@rolftimmermans
Copy link
Member

Shouldn't node-gyp add -fPIC already? I don't think it should be necessary to add it explicitly.

@n-riesco
Copy link
Contributor

@arrkiin, would you be able to check whether your PR works without -fPIC?

In fact, you may be able to remove -lzmq as well, if you install zeromq with npm install zeromq --zmq-external.

@arrkiin
Copy link
Author

arrkiin commented Nov 15, 2017

@n-riesco, that what you described was my first attemp to resolve the problem. I cloned the ijavacript repository and did an npm install --zmq-external. The effect was as expected:

Requested to use external libzmq. Skipping download of prebuilt binaries.
Requested to use external libzmq. Skipping libzmq build

But during the linking of the libzmq library it produced the following errror message:

/data/data/com.termux/files/usr/bin/ld: Release/obj.target/zmq/binding.o: relocation R_AARCH64_ADR_PREL_PG_HI21 against symbol `_ZN3zmq7Context3NewERKN3Nan20FunctionCallbackInfoIN2v85ValueEEE' which may bind externally can not be used when making a shared object; recompile with -fPIC

So I digged a lot deeper, cloned the zeromq.js project and did some sole experiments with the zeromq build process. In the end I came up with the changes bundled in this PR. To verify the whole build process I cloned the whole dependency chain ijavascript -> jp-kernel -> jmp -> zeromq.js with modified dependenies. In the end I had a nice ijavascript-kernel on my android device termux-app.

@rolftimmermans
Copy link
Member

Well, node-gyp already adds -fPIC in some situations, see https://github.com/nodejs/node-gyp/blob/master/addon.gypi#L140. Maybe a new scenario should be added there?

Deciding which flags need to be added for certain platforms to correctly compile Node.js modules (in general) should be added in the node-gyp project, not in each project separately.

There is nothing specific in ZeroMQ.js which would require -fPIC.

I recommend opening a pull request with node-gyp.

@arrkiin
Copy link
Author

arrkiin commented Nov 15, 2017

Great investigation. Thanks for the hint. I will look into it later this week and do some tests.

@arrkiin
Copy link
Author

arrkiin commented Nov 16, 2017

Looked into https://github.com/nodejs/node-gyp/blob/master/addon.gypi#L140 and did the needed modifications (https://github.com/arrkiin/node-gyp/blob/termux_on_android/addon.gypi#L142).
Now using npm install --zmq-external is giving the proper results. Will create a pull-request for node-gyp, so I close this PR. Thank you for your support.

@arrkiin arrkiin closed this Nov 16, 2017
@arrkiin arrkiin deleted the zmq_on_termux branch November 16, 2017 10:17
@arrkiin
Copy link
Author

arrkiin commented Nov 16, 2017

Fyi. Here is my PR for node-gyp (nodejs/node-gyp#1340). So ijavascript and jp-babel were installed without any problems. I like my new possibility to use jupyter on my android device as a scratchpad and idea-lab for python and now also for javascript stuff. @n-riesco, thanks for that. @rolftimmermans thanks for your help, just learned more about npm and node-gyp now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants