-
Notifications
You must be signed in to change notification settings - Fork 30.6k
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
Building for Android target not working #34115
Comments
After looking at the sijtech/build-nodejs-for-android repo I found some ideas what might be causing the issue. I think down the toolchain some host/target exports were missing, especially for ld and ar. |
Update: I've compiled now pretty much all constellations of flags I can think of. Every single variant segfaults on an AOSP Android 9 and another device with OmniROM head / Android 10. I think nothing's actually compiling correctly, what am I missing? |
https://github.com/PixelShiftAI/node-shared-build/actions/runs/169326880 FYI we've built node 14.2.0/14.5.0 successful into shared libraries on Android arm64. There was some attempts on ia32/arm/x86_64, but not much progress so far. |
@wsxiaoys Could you compile only against API level 23 and node v14.2.0? Did you have to change any of the $CONFIGURE_OPTIONS via environment variable? |
This is the 14.2 build on API 23: CONFIGURATION_OPTIONS is set to |
@wsxiaoys: When using your script, I got all kinds of linker problems, because LD_host and LD_target were not set. Which linker are you using? When I'm setting (for reference) /opt/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android28-clang++ -rdynamic -fPIC -Wl,-rpath=\$ORIGIN/lib.target/ -Wl,-rpath-link=\/home/cookiengineer/Software/nodejs/out/Release/lib.target/ -o /home/cookiengineer/Software/nodejs/out/Release/embedtest -Wl,--start-group /home/cookiengineer/Software/nodejs/out/Release/obj.target/embedtest/src/node_snapshot_stub.o /home/cookiengineer/Software/nodejs/out/Release/obj.target/embedtest/src/node_code_cache_stub.o /home/cookiengineer/Software/nodejs/out/Release/obj.target/embedtest/test/embedding/embedtest.o /home/cookiengineer/Software/nodejs/out/Release/obj.target/libnode.so /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/histogram/libhistogram.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/uvwasi/libuvwasi.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_snapshot.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/icu/libicui18n.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/zlib/libzlib.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/llhttp/libllhttp.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/cares/libcares.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/uv/libuv.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/nghttp2/libnghttp2.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/brotli/libbrotli.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/deps/openssl/libopenssl.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/icu/libicuucx.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/icu/libicudata.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/icu/libicustubdata.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_libbase.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_libsampler.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_zlib.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_compiler.a /home/cookiengineer/Software/nodejs/out/Release/obj.target/tools/v8_gypfiles/libv8_initializers.a -Wl,--end-group -lm -ldl -llog
/home/cookiengineer/Software/nodejs/out/Release/obj.target/libnode.so: undefined reference to `uv__random_getentropy'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [embedtest.target.mk:184: /home/cookiengineer/Software/nodejs/out/Release/embedtest] Error 1
make[1]: *** Waiting for unfinished jobs.... |
Yes it just use the default Guessing you could just pull the official github action image and try the script inside and compare the environment difference? |
@wsxiaoys The issue is that a build with only "LD= Did you verify on Android that the binary actually works without a segfault? It seems, when using
I tried copying the The resulting binary doesn't even try to read any file, it just segfaults immediately. When using |
@cookiengineer Hi, our use case is to embed node as a shared library (thus only libnode.so is used). So I'm not really familiar with the shell use case presented in your screenshot. |
@cookiengineer It's maybe the ANDROID_SDK_VERSION=28 not support on your device. is your device android sdk version >= 28 ? |
The |
@stormagain The device I used for testing was Android 10 at the time (Android 9 is SDK level 28 iirc), so it should've worked. Gonna try to take a look at the nodejs-mobile repo to figure out what they do differently than upstream. Last time I took a look at it, they were using a heavily outdated nodejs LTS variant which was not reproducible in terms of compiling it yourself. |
Just would like to know: Is the android-configure from the root path of node project (https://github.com/nodejs/node/blob/main/android-configure) just for building nodejs for android? Seems no any document telling this? Thanks a lot. |
I'm not sure how to start, the last couple days I've been trying to build node.js as an Android target, but I've gotten not very far with it.
I was first trying out the
android-configure
script in this repository which seems heavily outdated, as compiling node--without-snapshot
isn't possible since a while now.Afterwards I was trying to figure out how Termux does it, while trying to build node as static as possible, because their packaging system uses all of the libraries in a shared manner.
Side note: The nodejs-mobile hardfork is totally outdated and uses the abandoned chakra fork, so I guess that cannot be relied on anyhow. Tried that out, nothing works, segfault pretty much everywhere. Still they had the same build issues, and their reasons for the hardfork with all kinds of weird gyp file and
#ifdef
replacements in the codebase, though it's impossible to say whether these patches still are necessary for upstream node or not.Currently, I've gotten this far, but I still get a segfault on every Android API level. I've got no clue what the issue is (hence the reason for this Bug Report). I cannot build a working node binary and/or libnode.so for Android that works correctly without a segfault.
The current build script looks like this (based on the
android-configure
script, but modified a bit to be failsafe, because some stuff was missing)... currently I am building for AOSP / OmniROM and Android API Level 28 (aka Android 9.0+).My questions are now as following:
libnode.so
so that it can be used inside Android Apps, too (using the Android NDK)?libicu
problems arise and thereforeIntl
support has to be disabled? If not, how to fix all the build errors?--parallel
is disabled, so basically everything is compiled with-j 1
- why is that?Thanks in advice.
The text was updated successfully, but these errors were encountered: