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

Cross-arch rebuild #378

Closed
artus9033 opened this issue Jul 28, 2020 · 4 comments
Closed

Cross-arch rebuild #378

artus9033 opened this issue Jul 28, 2020 · 4 comments
Labels

Comments

@artus9033
Copy link

artus9033 commented Jul 28, 2020

I am using this library via electron-forge, but also tried it standalone, for armv7l cross-platform rebuild of native modules. Either way (electron-forge with armv7 arch configuration running on WSL, or through manual CLI execution with -a armv7l), the resulting .node of the native modules that are being logged as rebuild targets, are compiled for x64, as readelf -a shows (Class: ELF64), both in the original node_modules, or in the copied .asar archive. Rebuild finishes without any errors. Am I doing something wrong or is cross-platform, cross-arch compilation not really supported?

@malept
Copy link
Member

malept commented Jul 28, 2020

Cross compilation support is not currently supported, as node-gyp doesn't currently support it. If you need this functionality, please add it to node-gyp first.

@malept malept closed this as completed Jul 28, 2020
@artus9033
Copy link
Author

artus9033 commented Jul 28, 2020

Actually, while they claim it is not supported, after a while of experimenting, I got it working and successfully cross-compiled a bunch of native modules on WSL (v1) x64 by installing arm-linux-gnueabihf-gcc & arm-linux-gnueabihf-g++, and then specifying --arch=armv7 and setting the environmental variables for the compilers: CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ CC_host="gcc -m32" CXX_host="g++ -m32" ..., ensuring that the host compiler uses only 32-bit headers, so that even with more advanced modules there shouldn't be a problem.
Moreover, I actually got this working inline with invoking electron-forge, so this solution isn't invasive in any way and the overhead to get this working is minimal. Maybe it should be possible for you to add simple config parameters, dependant on which the proper env variables would be set inline with the node-gyp invokation (can easily be done host-platform-agnostically e.g. with cross-env)

@malept
Copy link
Member

malept commented Jul 29, 2020

I'd much rather have this sort of functionality inside node-gyp rather than this module - it would help out so many more developers. Then we can hook into that inside this module.

@artus9033
Copy link
Author

Alright, I'll try to merge with them

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

No branches or pull requests

2 participants