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

libc++_shared.so is included in the APK with NDK 24.0.8215888, not with 21.4.7075529 or 23.1.7779620 #13

Open
torokati44 opened this issue Mar 27, 2022 · 8 comments

Comments

@torokati44
Copy link

torokati44 commented Mar 27, 2022

This has caused my app to work when built locally, but not when built by GitHub Actions, as that still defaults to 21.4.7075529.
See: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#environment-variables-3

See the last 8-10 lines of the "Build native libs" section of the output in this build: https://github.com/torokati44/ruffle-android/runs/5707487779?check_suite_focus=true
Under 882 lib/arm64-v8a/libruffle_android.so (OK - compressed) there should be another line about libc++_shared.so, because in build.rs I ask rustc to link to it.

Relevant PR: rust-mobile/ndk#20

Switching to NDK 23.1.7779620 by setting $ANDROID_NDK_ROOT to $ANDROID_NDK_LATEST_HOME still doesn't solve it, see the same lines of output here: https://github.com/torokati44/ruffle-android/runs/5712219430?check_suite_focus=true

@torokati44
Copy link
Author

torokati44 commented Mar 27, 2022

On my local machine, libc++_shared.so is included in the APK when I point $ANDROID_NDK_ROOT to a 24.0.8215888 NDK, but not when to a 21.4.7075529 version, that's how I know this is likely the critical difference.

@torokati44
Copy link
Author

In fact, even if I manually copy libc++_shared.so into the APK, there are still unresolved references to symbols in it. Even if I System.loadLibrary it before the other shared library that would use it.
Is my request in build.rs to link to it simply ignored somehow?

@torokati44
Copy link
Author

I was able to switch over to NDK r24 using https://github.com/nttld/setup-ndk, and now libc++_shared.so is correctly put in the APK on GitHub Actions as well.

It was not immediately obvious however, that the correct environment variable to set (the one that is checked first) was ANDROID_NDK_ROOT, and not ANDROID_NDK_HOME, or something like that.
At least there was a helpful message about ANDROID_HOME being used, so I unset that. 👍

So even though my problem is now fixed, it would be nice if this still worked with NDK < r24, so that this extra step wouldn't be needed, and some more headache could be spared for others in the future.

@MarijnS95
Copy link
Member

MarijnS95 commented Mar 28, 2022

Note that you can link to lines in build steps directly: https://github.com/torokati44/ruffle-android/runs/5707487779?check_suite_focus=true#step:5:810

As you pointed to rust-mobile/ndk#20, ndk-build only bundles this library (or any library in general) when the linker puts it in the dynamic library section. As such it doesn't seem like this is emitted at all for NDK <24, specifically because it also doesn't seem fixed when manually adding libc++_shared.so to the APK.

Please be more specific (logs...) about any linker errors that appear. Include readelf -d path/to/your/libruffle_android.so for the dynamic sections and readelf -s path/to/your/libruffle_android.so (filtered on UND imports) for the symbols that it sources externally.

EDIT: Since your project seems to be using cpal which surfaced similar issues before, try looking at rust-mobile/ndk#167 (comment) and other issues regarding c++_shared/c++_static on these repositories.

@torokati44
Copy link
Author

Note that you can link to lines in build steps directly: https://github.com/torokati44/ruffle-android/runs/5707487779?check_suite_focus=true#step:5:810

Right, thanks for the tip!

I have set up a tiny repo with a bunch of crates to reproduce a similar situation easier: https://github.com/torokati44/cargo-apk-cpp-test
Not sure if it helps at all, but it might. The apk-crate similarly works with NDK 24, not with 21.

The linker error in this case is, at runtime:

2022-03-30 02:28:32.240 25442-25442/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: rust.cargo_apk_cpp_test, PID: 25442
    java.lang.UnsatisfiedLinkError: Unable to load native library "/data/app/~~kzrL05MN7dThuGIfZyoi4A==/rust.cargo_apk_cpp_test-JUMKIM2wWobn-aRWR1E4Fw==/lib/arm64/libcargo_apk_cpp_test.so": dlopen failed: cannot locate symbol "__gxx_personality_v0" referenced by "/data/app/~~kzrL05MN7dThuGIfZyoi4A==/rust.cargo_apk_cpp_test-JUMKIM2wWobn-aRWR1E4Fw==/lib/arm64/libcargo_apk_cpp_test.so"...
        at android.app.NativeActivity.onCreate(NativeActivity.java:178)
        at android.app.Activity.performCreate(Activity.java:8054)
        at android.app.Activity.performCreate(Activity.java:8034)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1341)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3688)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3864)
        at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:103)
        at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2253)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.app.ActivityThread.main(ActivityThread.java:7870)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)

The output of readelf -d target/debug/apk/lib/arm64-v8a/libcargo_apk_cpp_test.so is:
With NDK 21:


Dynamic section at offset 0xc6ab0 contains 26 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [liblog.so]
 0x0000000000000001 (NEEDED)             Shared library: [libandroid.so]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x0000000000000001 (NEEDED)             Shared library: [libm.so]
 0x000000000000001a (FINI_ARRAY)         0xc21b8
 0x000000000000001c (FINI_ARRAYSZ)       16 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0x1c8
 0x0000000000000005 (STRTAB)             0xa30
 0x0000000000000006 (SYMTAB)             0x1f0
 0x000000000000000a (STRSZ)              1329 (bytes)
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000003 (PLTGOT)             0xc7c90
 0x0000000000000002 (PLTRELSZ)           1896 (bytes)
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000017 (JMPREL)             0x7a30
 0x0000000000000007 (RELA)               0x1058
 0x0000000000000008 (RELASZ)             27096 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW
 0x000000006ffffffe (VERNEED)            0x1018
 0x000000006fffffff (VERNEEDNUM)         2
 0x000000006ffffff0 (VERSYM)             0xf62
 0x000000006ffffff9 (RELACOUNT)          1123
 0x0000000000000000 (NULL)               0x0

And with NDK 24:

Dynamic section at offset 0xd1820 contains 26 entries:
  Tag        Type                         Name/Value
 0x0000000000000001 (NEEDED)             Shared library: [libc++_shared.so]
 0x0000000000000001 (NEEDED)             Shared library: [liblog.so]
 0x0000000000000001 (NEEDED)             Shared library: [libandroid.so]
 0x0000000000000001 (NEEDED)             Shared library: [libdl.so]
 0x0000000000000001 (NEEDED)             Shared library: [libc.so]
 0x000000000000001e (FLAGS)              BIND_NOW
 0x000000006ffffffb (FLAGS_1)            Flags: NOW
 0x0000000000000007 (RELA)               0x11d0
 0x0000000000000008 (RELASZ)             27528 (bytes)
 0x0000000000000009 (RELAENT)            24 (bytes)
 0x000000006ffffff9 (RELACOUNT)          1141
 0x0000000000000017 (JMPREL)             0x7d58
 0x0000000000000002 (PLTRELSZ)           1944 (bytes)
 0x0000000000000003 (PLTGOT)             0xd3a98
 0x0000000000000014 (PLTREL)             RELA
 0x0000000000000006 (SYMTAB)             0x308
 0x000000000000000b (SYMENT)             24 (bytes)
 0x0000000000000005 (STRTAB)             0xc7c
 0x000000000000000a (STRSZ)              1363 (bytes)
 0x000000006ffffef5 (GNU_HASH)           0xc58
 0x000000000000001a (FINI_ARRAY)         0xd3810
 0x000000000000001c (FINI_ARRAYSZ)       16 (bytes)
 0x000000006ffffff0 (VERSYM)             0xb60
 0x000000006ffffffe (VERNEED)            0xc14
 0x000000006fffffff (VERNEEDNUM)         2
 0x0000000000000000 (NULL)               0x0

The output of readelf -s target/debug/apk/lib/arm64-v8a/libcargo_apk_cpp_test.so | grep UND is:

With NDK 21:

     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mmap@LIBC (2)
     5: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dl_iter[...]@LIBC (3)
     6: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_free_exception
     7: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSt11logic_err[...]
     8: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_begin_catch
     9: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    10: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    11: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pipe@LIBC (2)
    12: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit@LIBC (2)
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat@LIBC (2)
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcmp@LIBC (2)
    16: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    17: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Znwm
    18: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_endSection
    19: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc@LIBC (2)
    20: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_atta[...]
    21: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_once@LIBC (2)
    22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memalign@LIBC (2)
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND calloc@LIBC (2)
    24: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZdlPv
    25: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read@LIBC (2)
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close@LIBC (2)
    28: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getcwd@LIBC (2)
    29: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_addFd
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    31: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_deta[...]
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    33: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    34: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free@LIBC (2)
    35: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZTISt12length_error
    36: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    37: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_acquire
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND setenv@LIBC (2)
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_prepare
    40: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_allocate_e[...]
    41: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    42: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __errno@LIBC (2)
    43: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __gxx_personality_v0
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open@LIBC (2)
    45: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sysconf@LIBC (2)
    46: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    47: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv@LIBC (2)
    48: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dup2@LIBC (2)
    49: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    50: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_throw
    51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memmove@LIBC (2)
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset@LIBC (2)
    54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_f[...]@LIBC (2)
    55: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZTVSt12length_error
    56: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_isEnabled
    57: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    58: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    59: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND munmap@LIBC (2)
    60: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort@LIBC (2)
    61: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    62: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND write@LIBC (2)
    63: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSt12length_er[...]
    64: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    65: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    66: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND prctl@LIBC (2)
    67: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fstat@LIBC (2)
    68: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    69: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNKSt6__ndk120_[...]
    70: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_beginSection
    71: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND writev@LIBC (2)
    72: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realloc@LIBC (2)
    73: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    74: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@LIBC (2)
    75: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_release
    76: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror_r@LIBC (2)
    77: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syscall@LIBC (2)
    78: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __regis[...]@LIBC (2)
    79: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memchr@LIBC (2)
    80: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen@LIBC (2)
    81: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_write
    82: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    83: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realpath@LIBC (2)
    84: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    85: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZSt9terminatev
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
 12055: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_w[...]
 12056: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mmap@@LIBC
 12057: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dl_iterate_phdr@@LIBC
 12058: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_free_exception
 12059: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSt11logic_err[...]
 12060: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_begin_catch
 12061: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_d[...]
 12062: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_getspeci[...]
 12063: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pipe@@LIBC
 12064: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_r[...]
 12065: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit@@LIBC
 12066: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat@@LIBC
 12067: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcmp@@LIBC
 12068: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_create@@LIBC
 12069: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _Znwm
 12070: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_endSection
 12071: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc@@LIBC
 12072: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_atta[...]
 12073: 0000000000000000     0 FUNC    WEAK   DEFAULT  UND pthread_once@@LIBC
 12074: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memalign@@LIBC
 12075: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND calloc@@LIBC
 12076: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZdlPv
 12077: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_wai[...]
 12078: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read@@LIBC
 12079: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close@@LIBC
 12080: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getcwd@@LIBC
 12081: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_addFd
 12082: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_sig[...]
 12083: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_deta[...]
 12084: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutexatt[...]
 12085: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutexatt[...]
 12086: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free@@LIBC
 12087: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZTISt12length_error
 12088: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_des[...]
 12089: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_acquire
 12090: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND setenv@@LIBC
 12091: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_prepare
 12092: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_allocate_e[...]
 12093: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_u[...]
 12094: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __errno@@LIBC
 12095: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __gxx_personality_v0
 12096: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open@@LIBC
 12097: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sysconf@@LIBC
 12098: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_ini[...]
 12099: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv@@LIBC
 12100: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dup2@@LIBC
 12101: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_setspeci[...]
 12102: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND __cxa_throw
 12103: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_un[...]
 12104: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memmove@@LIBC
 12105: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset@@LIBC
 12107: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_finalize@@LIBC
 12108: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZTVSt12length_error
 12109: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_isEnabled
 12110: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_in[...]
 12111: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_des[...]
 12112: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND munmap@@LIBC
 12113: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort@@LIBC
 12114: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_set[...]
 12115: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND write@@LIBC
 12116: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNSt12length_er[...]
 12117: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_lo[...]
 12118: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_de[...]
 12119: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND prctl@@LIBC
 12120: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fstat@@LIBC
 12121: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutexatt[...]
 12122: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZNKSt6__ndk120_[...]
 12123: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_beginSection
 12124: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND writev@@LIBC
 12125: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realloc@@LIBC
 12126: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_dele[...]
 12128: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@@LIBC
 12129: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_release
 12130: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror_r@@LIBC
 12131: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syscall@@LIBC
 12132: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __register_atfor[...]
 12133: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memchr@@LIBC
 12134: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen@@LIBC
 12135: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_write
 12136: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_crea[...]
 12137: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realpath@@LIBC
 12138: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_detach@@LIBC
 12139: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND _ZSt9terminatev

With NDK 24:

     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_f[...]@LIBC (2)
     2: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit@LIBC (2)
     3: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __regis[...]@LIBC (2)
     4: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy@LIBC (2)
     5: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __gxx_personality_v0
     6: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _ZTVSt12length_error
     7: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZSt9terminatev
     8: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_throw
     9: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _ZTISt12length_error
    10: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZNSt11logic_err[...]
    11: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZNKSt6__ndk120_[...]
    12: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZdlPv
    13: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _Znwm
    14: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_allocate_e[...]
    15: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZNSt12length_er[...]
    16: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_free_exception
    17: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_begin_catch
    18: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_write
    19: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read@LIBC (2)
    20: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND write@LIBC (2)
    21: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset@LIBC (2)
    22: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pipe@LIBC (2)
    23: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dup2@LIBC (2)
    24: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close@LIBC (2)
    25: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    26: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    27: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    28: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    29: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    30: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    31: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen@LIBC (2)
    32: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    33: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    34: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memmove@LIBC (2)
    35: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcmp@LIBC (2)
    36: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_atta[...]
    37: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_deta[...]
    38: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_isEnabled
    39: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_beginSection
    40: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_endSection
    41: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_prepare
    42: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_release
    43: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_acquire
    44: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_addFd
    45: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND munmap@LIBC (2)
    46: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __errno@LIBC (2)
    47: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syscall@LIBC (2)
    48: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sysconf@LIBC (2)
    49: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getcwd@LIBC (2)
    50: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memchr@LIBC (2)
    51: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv@LIBC (2)
    52: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND setenv@LIBC (2)
    53: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fstat@LIBC (2)
    54: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND writev@LIBC (2)
    55: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    56: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    57: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort@LIBC (2)
    58: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open@LIBC (2)
    59: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc@LIBC (2)
    60: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memalign@LIBC (2)
    61: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free@LIBC (2)
    62: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    63: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    64: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    65: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    66: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    67: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    68: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    69: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    70: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realloc@LIBC (2)
    71: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND calloc@LIBC (2)
    72: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat@LIBC (2)
    73: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realpath@LIBC (2)
    74: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror_r@LIBC (2)
    75: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    76: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    77: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    78: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    79: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND prctl@LIBC (2)
    80: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread[...]@LIBC (2)
    81: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mmap@LIBC (2)
    82: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dl_iter[...]@LIBC (3)
    83: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND __sF@LIBC (2)
    84: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fprintf@LIBC (2)
    85: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fflush@LIBC (2)
    86: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fwrite@LIBC (2)
     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND 
 14988: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_finalize
 14989: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_atexit
 14990: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __register_atfork
 14993: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcpy
 14994: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __gxx_personality_v0
 14995: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _ZTVSt12length_error
 14996: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZSt9terminatev
 14997: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_throw
 14998: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND _ZTISt12length_error
 14999: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZNSt11logic_err[...]
 15000: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZNKSt6__ndk120_[...]
 15001: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZdlPv
 15002: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _Znwm
 15003: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_allocate_e[...]
 15004: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND _ZNSt12length_er[...]
 15005: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_free_exception
 15006: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __cxa_begin_catch
 15007: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __android_log_write
 15008: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND read
 15009: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND write
 15010: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memset
 15011: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pipe
 15012: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dup2
 15013: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND close
 15014: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_lock
 15015: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_unlock
 15016: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_rdlock
 15017: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_wrlock
 15018: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_unlock
 15019: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_wait
 15020: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strlen
 15021: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_setspecific
 15022: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_getspecific
 15023: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memmove
 15024: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memcmp
 15025: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_atta[...]
 15026: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND AInputQueue_deta[...]
 15027: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_isEnabled
 15028: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_beginSection
 15029: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ATrace_endSection
 15030: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_prepare
 15031: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_release
 15032: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_acquire
 15033: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND ALooper_addFd
 15034: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND munmap
 15035: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND __errno
 15036: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND syscall
 15037: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND sysconf
 15038: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getcwd
 15039: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memchr
 15040: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND getenv
 15041: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND setenv
 15042: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fstat
 15043: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND writev
 15044: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_destroy
 15045: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_signal
 15046: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND abort
 15047: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND open
 15048: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND malloc
 15049: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND memalign
 15050: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND free
 15051: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_cond_destroy
 15052: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutexatt[...]
 15053: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutexatt[...]
 15054: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutex_init
 15055: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_mutexatt[...]
 15056: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_rwlock_d[...]
 15057: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_create
 15058: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_key_delete
 15059: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realloc
 15060: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND calloc
 15061: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND stat
 15062: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND realpath
 15063: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND strerror_r
 15064: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_init
 15065: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_set[...]
 15066: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_create
 15067: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_attr_destroy
 15068: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND prctl
 15069: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND pthread_detach
 15070: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND mmap
 15071: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND dl_iterate_phdr
 15072: 0000000000000000     0 OBJECT  GLOBAL DEFAULT  UND __sF
 15073: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fprintf
 15074: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fflush
 15075: 0000000000000000     0 FUNC    GLOBAL DEFAULT  UND fwrite

@MarijnS95
Copy link
Member

I'm surprised. You even added println!("cargo:rustc-link-lib=c++_shared"); to force linking against this lib yet it still doesn't show up. Perhaps the NDK linker is stripping this, but I don't see -nostdc++ anywhere. In fact, running with cargo apk b -vv clearly shows -l c++_shared in the final linker invocation...

@torokati44
Copy link
Author

Yes, without that, it doesn't work even with NDK 24.
And I saw that Oboe has a feature to do this itself, which is neat - however, I am using it only indirecly, through CPAL, so I don't think I can easily enable it.

@dvc94ch dvc94ch transferred this issue from rust-mobile/ndk Dec 22, 2022
@kcking
Copy link

kcking commented Dec 29, 2022

In case this helps, I am using oboe and ran into this error. I was able to solve it by adding the following to my main.rs:

#[cfg_attr(target_os = "android", link(name = "c++_shared"))]
extern "C" {}

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

No branches or pull requests

3 participants