-
Notifications
You must be signed in to change notification settings - Fork 250
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
[BUG]My compiled .so file depends on other shared object files, but has path prefixes included. #1865
Comments
i haven't looked, but i'd guess ndk-pkg is broken. did you use readelf to check the SONAME in the libbz2.so file? i also notice that you have two references to libbz2.so; there's this one too:
|
I check the SONAME of libbz2.so, have nothing to show:
Is this the reason that cause this bug? (Sorry, the second |
heh, yeah, that's your problem then --- having no SONAME will have the same effect. the linker will use the full pathname to the .so file in that case. you (or rather ndk-pkg) need to use |
Great. Thanks very much for your help. |
It seems that https://android.googlesource.com/platform/bionic/+/master/android-changes-for-ndk-developers.md need to be updated. This document says:
Anyway, I fixed this problem at ndk-pkg side, I use patchelf to add https://github.com/leleliu008/ndk-pkg/blob/master/bin/ndk-pkg#L6691-L6705 |
i doubt that, since no-one else is having trouble. unless proven otherwise, i think ndk-pkg is either providing incorrect arguments to the compiler/linker, or changing the ELF file afterwards (since you mention post-processing with "patchelf"). |
It can be easily proved. step1: create a C source file named test.c int test() {
return 0;
} step2: create a shared library ~/Downloads/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android21-clang --shared -o libtest.so test.c step3: display the dynamic section ~/Downloads/android-ndk-r25c/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-readelf -d libtest.so There is no |
yeah, i think the intention here was to say build system. it looks like ndk-build does add
i'm guessing cmake does it by default, so we don't need to explicitly say it? i've sent out https://android-review.googlesource.com/c/platform/bionic/+/2535080 for the bionic dynamic linker docs, and i'll let the NDK folks decide what to do with https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md which doesn't currently mention sonames at all... |
Yes, I guess |
cmake build system automatically add Reference: https://cmake.org/cmake/help/latest/prop_tgt/SOVERSION.html |
yeah, i've argued in the past that the linker default (of no soname, rather than soname == basename(output filename)) is an unfortunate historical accident that we should fix there instead, but i don't think anyone has the stomach to try to change that. not even @MaskRay! |
It's the build systems, not the toolchain itself. Bug: android/ndk#1865 Test: treehugger Change-Id: I74b35498e32c798683fd39e7369f87ff6cc2de38
I strongly recommend that gradle or ndk should provide us some warning or errors to indicate this case(like: there is no I have checked the gradle log with |
well, i don't think gradle has any idea that this is even happening. cmake already does the right thing. i suspect the problem with ndk-build is that (a) it's hard to know whether you're specifying folks who actually work on ndk-build will know better, but i fear this might be something we either need to change lld's default behavior for, or go back in time and make the ndk-build syntax and behavior more like cmake's. (because there's a risk of breaking existing builds if we change it now.) |
That's #220.
What problem with ndk-build? All I see in the thread says that ndk-build's behavior matches CMake's. ndk-build definitely sets SONAME, otherwise nothing it built would load correctly. |
yeah, sorry, we confirmed that last week. in which case, yeah, i don't think there's anything else to do here. |
Description
When I use readelf to check the dependencies of my .so file, I found that the
libbz2.so
file it depends on has a specific path prefix.(The other .so file is ok)
I’m using the latest NDK version:
25.2.9519653
, and the problem still exists.Reproduce: (taking arm64-v8a as an example):
https://github.com/leleliu008/ndk-pkg
1.1 Run
“ndk-pkg update”
and“ndk-pkg install bzip2 –min-sdk-api-level=21”
to compile1.2 You can find
libbz2.so
in.ndk-pkg/install.d/android/21/bzip2/arm64-v8a
With the above steps, the problem can be reproduced.
Affected versions
r23
Canary version
No response
Host OS
Mac
Host OS version
macOS 13.2.1
Affected ABIs
arm64-v8a
Build system
CMake
Other build system
No response
minSdkVersion
21
Device API level
30
The text was updated successfully, but these errors were encountered: