[llvm-dev] Cross-compile Android

Wehrli Johan via llvm-dev llvm-dev at lists.llvm.org
Tue Oct 6 02:45:08 PDT 2015


Hi,

I think I found a solution.

I will put it here in case of someone has the same bug as me.

The problem was from one of my custom passes, I created an global variable with a blockaddress.

Some of the function had the following linkage type : LinkOnceODRLinkage or WeakODRLinkage.

During the compilation, each of my function are put into a separate section (for optimisation purpose).

During the link, some of the function are discarded because there a not used.

If the global variable is still there after the function is discarded, the problem will appear.

My solution was to avoid the function with this kind of linkage.

Greetings,

Johan

> On 05 Oct 2015, at 11:13, Wehrli Johan via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> 
> Hi all,
> 
> I have a question about the cross-compilation on an Android application.
> 
> I try to compile the open-source application ChatSecureAndroid (https://github.com/guardianproject/ChatSecureAndroid) with the last clang and the following parameter : --sysroot=/Users/users/Library/Android/ndk/platforms/android-19/arch-arm/ -target armv7-a-none-linux-androideabi
> 
> During the link I get the following error multiple time : 
> 
> `.text._ZN7android12SharedBuffer14bufferFromDataEPv' referenced in section `.data.rel.ro' of /Users/jowehrli/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/String8.o: defined in discarded section `.text._ZN7android12SharedBuffer14bufferFromDataEPv[_ZN7android12SharedBuffer14bufferFromDataEPv]' of /Users/jowehrli/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/String8.o
> 
> It seem that every function is put into a section (in order to optimise the code size) with the argument -ffunction-section.
> 
> When I try to compile without it, the result is the same.
> 
> Does someone have any ideas?
> 
> Greetings,
> 
> Johan
> 
> PS : This is the line used for the linking process :
> 
> /Users/users/Code/build/llvm3.7/bin/clang++ -Wl,-soname,libsqlcipher_android.so -shared --sysroot=/Users/users/Library/Android/ndk/platforms/android-3/arch-arm /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/android-sqlite/android/sqlite3_android.o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/android-sqlite/android/PhonebookIndex.o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/android-sqlite/android/PhoneNumberUtils.o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/android-sqlite/android/OldPhoneNumberUtils.o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/android-sqlite/android/PhoneticStringUtils.o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/String16.o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/objs/sqlcipher_android/String8.o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/libsqlcipher.a /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/libicui18n.a /Users/users/Code/src/original/android-database-sqlcipher/external/android-libs/armeabi/libcrypto.a /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/libicuuc.a -lgcc /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/libstlport_shared.so  -gcc-toolchain /Users/users/Library/Android/ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 -no-canonical-prefixes -target armv5te-none-linux-androideabi -fuse-ld=gold -fuse-ld=bfd -L/Users/users/Code/src/original/android-database-sqlcipher/external/android-libs/armeabi/ -L/Users/users/Code/src/original/android-database-sqlcipher/external/libs/armeabi/ -Wl,--no-undefined -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now -mthumb  -L/Users/users/Library/Android/ndk/platforms/android-3/arch-arm/usr/lib -llog -lutils -lcutils -lc -lm -o /Users/users/Code/src/original/android-database-sqlcipher/obj/local/armeabi/libsqlcipher_android.so
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list