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

LD Failures when building beam as an NDK on Android. #7775

Open
dexmagic opened this issue Oct 24, 2023 · 3 comments
Open

LD Failures when building beam as an NDK on Android. #7775

dexmagic opened this issue Oct 24, 2023 · 3 comments
Labels
bug Issue is reported as a bug help wanted Issue not worked on by OTP; help wanted from the community team:VM Assigned to OTP team VM

Comments

@dexmagic
Copy link

Describe the bug
I'm trying to build OTP on Android. At a mimimum I need to build the BEAM vm so compiled Erlang code can be run.
I've got a setup that will successfully compile BEAM, but the linker fails because these symbols are not defined.

To Reproduce
Build BEAM on Android.

Expected behavior
A successful build with just the VM in a library that can be linked into a native Android application.

Affected versions
OTP 26.

Additional context

Here are the errors:
I can't find these symbols in the code, so what should I do about those? Perhaps there's a workaround?

ld: error: undefined symbol: prim_socket_nif_init
  >>> referenced by driver_tab.c
  >>>               CMakeFiles/otp.dir/erts/emulator/x86_64-pc-linux-android/opt/emu/driver_tab.c.o:(erts_static_nif_tab)
  
  ld: error: undefined symbol: erts_pcre_malloc
  >>> referenced by erl_bif_re.c:96 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/beam/erl_bif_re.c:96)
  >>>               CMakeFiles/otp.dir/erts/emulator/beam/erl_bif_re.c.o:(erts_init_bif_re)
  >>> referenced by pcre_compile.c:9437 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/pcre/pcre_compile.c:9437)
  >>>               CMakeFiles/otp.dir/erts/emulator/pcre/pcre_compile.c.o:(erts_pcre_compile2)
  >>> referenced by pcre_compile.c:933 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/pcre/pcre_compile.c:933)
  >>>               CMakeFiles/otp.dir/erts/emulator/pcre/pcre_compile.c.o:(compile_branch)
  >>> referenced 11 more times
  
  ld: error: undefined symbol: erts_pcre_free
  >>> referenced by erl_bif_re.c:97 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/beam/erl_bif_re.c:97)
  >>>               CMakeFiles/otp.dir/erts/emulator/beam/erl_bif_re.c.o:(erts_init_bif_re)
  >>> referenced by erl_bif_re.c:1207 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/beam/erl_bif_re.c:1207)
  >>>               CMakeFiles/otp.dir/erts/emulator/beam/erl_bif_re.c.o:(re_run)
  >>> referenced by erl_bif_re.c:496 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/beam/erl_bif_re.c:496)
  >>>               CMakeFiles/otp.dir/erts/emulator/beam/erl_bif_re.c.o:(build_compile_result)
  >>> referenced 18 more times
  
  ld: error: undefined symbol: erts_pcre_stack_malloc
  >>> referenced by erl_bif_re.c:98 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/beam/erl_bif_re.c:98)
  >>>               CMakeFiles/otp.dir/erts/emulator/beam/erl_bif_re.c.o:(erts_init_bif_re)
  >>> referenced by pcre_exec.c:5271 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/pcre/pcre_exec.c:5271)
  >>>               CMakeFiles/otp.dir/erts/emulator/pcre/pcre_exec.c.o:(match)
  >>> referenced by pcre_exec.c:3677 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/pcre/pcre_exec.c:3677)
  >>>               CMakeFiles/otp.dir/erts/emulator/pcre/pcre_exec.c.o:(match)
  >>> referenced 66 more times
  
  ld: error: undefined symbol: erts_pcre_stack_free
  >>> referenced by erl_bif_re.c:99 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/beam/erl_bif_re.c:99)
  >>>               CMakeFiles/otp.dir/erts/emulator/beam/erl_bif_re.c.o:(erts_init_bif_re)
  >>> referenced by pcre_exec.c:0 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/pcre/pcre_exec.c:0)
  >>>               CMakeFiles/otp.dir/erts/emulator/pcre/pcre_exec.c.o:(erts_pcre_exec)
  >>> referenced by pcre_exec.c:0 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/pcre/pcre_exec.c:0)
  >>>               CMakeFiles/otp.dir/erts/emulator/pcre/pcre_exec.c.o:(erts_pcre_exec)
  >>> referenced 2 more times
  
  ld: error: undefined symbol: erts_pcre_stack_guard
  >>> referenced by erl_bif_re.c:0 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/beam/erl_bif_re.c:0)
  >>>               CMakeFiles/otp.dir/erts/emulator/beam/erl_bif_re.c.o:(erts_init_bif_re)
  >>> referenced by pcre_compile.c:8336 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/pcre/pcre_compile.c:8336)
  >>>               CMakeFiles/otp.dir/erts/emulator/pcre/pcre_compile.c.o:(compile_regex)
  
  ld: error: undefined symbol: esock_atom_name
  >>> referenced by unix_socket_syncio.c:774 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:774)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_info)
  >>> referenced by unix_socket_syncio.c:5108 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:5108)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_ioctl2)
  >>> referenced by prim_net_nif.c:1718 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/common/prim_net_nif.c:1718)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/common/prim_net_nif.c.o:(nif_getifaddrs)
  >>> referenced 1 more times
  
  ld: error: undefined symbol: esock_abort
  >>> referenced by unix_socket_syncio.c:780 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:780)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_info)
  >>> referenced by unix_socket_syncio.c:817 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:817)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:928 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:928)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced 65 more times
  
  ld: error: undefined symbol: esock_open_is_debug
  >>> referenced by unix_socket_syncio.c:802 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:802)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:1037 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1037)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_plain)
  
  ld: error: undefined symbol: esock_open_use_registry
  >>> referenced by unix_socket_syncio.c:803 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:803)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:1038 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1038)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_plain)
  
  ld: error: undefined symbol: esock_dbg_printf
  >>> referenced by unix_socket_syncio.c:819 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:819)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:837 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:837)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:847 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:847)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced 332 more times
  
  ld: error: undefined symbol: esock_getopt_int
  >>> referenced by unix_socket_syncio.c:953 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:953)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:982 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:982)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:953 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:953)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced 2 more times
  
  ld: error: undefined symbol: esock_open_which_protocol
  >>> referenced by unix_socket_syncio.c:855 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:855)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:855 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:855)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:1098 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1098)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_plain)
  
  ld: error: undefined symbol: esock_atom_domain
  >>> referenced by unix_socket_syncio.c:968 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:968)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  
  ld: error: undefined symbol: esock_decode_domain
  >>> referenced by unix_socket_syncio.c:972 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:972)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  
  ld: error: undefined symbol: esock_atom_type
  >>> referenced by unix_socket_syncio.c:997 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:997)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:5642 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:5642)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(decode_cmsghdrs)
  >>> referenced by unix_socket_syncio.c:6060 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:6060)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_recvmsg)
  >>> referenced 1 more times
  
  ld: error: undefined symbol: esock_decode_type
  >>> referenced by unix_socket_syncio.c:1000 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1000)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  
  ld: error: undefined symbol: esock_make_invalid
  >>> referenced by unix_socket_syncio.c:0 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:0)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:0 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:0)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_sendmsg)
  >>> referenced by unix_socket_syncio.c:0 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:0)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_sendmsg)
  >>> referenced 2 more times
  
  ld: error: undefined symbol: esock_atom_protocol
  >>> referenced by unix_socket_syncio.c:1014 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1014)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:1014 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1014)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by prim_net_nif.c:4502 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/common/prim_net_nif.c:4502)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/common/prim_net_nif.c.o:(nif_getaddrinfo)
  
  ld: error: undefined symbol: esock_extract_int_from_map
  >>> referenced by unix_socket_syncio.c:1013 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1013)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  >>> referenced by unix_socket_syncio.c:1013 (/Users/richard/Development/git-dexopruntime/erlang-android/otp-android/app/src/main/cpp/erts/emulator/nifs/unix/unix_socket_syncio.c:1013)
  >>>               CMakeFiles/otp.dir/erts/emulator/nifs/unix/unix_socket_syncio.c.o:(essio_open_with_fd)
  
@dexmagic dexmagic added the bug Issue is reported as a bug label Oct 24, 2023
@garazdawi
Copy link
Contributor

The Android support has been contributed by external contributors, so this is not something that we can help with. I'm putting the label "help wanted" on it to see if anyone else can help you out.

@garazdawi garazdawi added the help wanted Issue not worked on by OTP; help wanted from the community label Oct 24, 2023
@dexmagic
Copy link
Author

O.K. Thank you.
I just now got AtomVM to build in Android Studio from source. So that's great!
But I would still like help to understand why those symbols are missing from the linker and what the workaround might be.

Cheers.

@rickard-green rickard-green added the team:VM Assigned to OTP team VM label Oct 30, 2023
@JeromeDeBretagne
Copy link
Contributor

JeromeDeBretagne commented Nov 11, 2023

Could you describe the steps you are using to cross-compile Erlang / OTP and your setup (NDK versions, etc.)?

I've been able to build OTP 26 for Android successfully following the Android-specific documentation from https://github.com/erlang/otp/blob/master/HOWTO/INSTALL-ANDROID.md

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug help wanted Issue not worked on by OTP; help wanted from the community team:VM Assigned to OTP team VM
Projects
None yet
Development

No branches or pull requests

4 participants