Tsvetan Bogoev
2018-06-15 06:47:18 UTC
Hi, I have a problem while linking a release version of a shared library
using cmake (gradle/Android studio)
While using Android.mk everything is working as expected - I am compiling a
couple of static libraries using optimization level -Oz and LTO (-flto) and
the it links fine.
But when I switched to cmake I use the same compilation options the code
compiles but it can't be linked. Currently I can not find exact ld but it
gives the following error:
arm-linux-androideabi/bin/ld: fatal error: Optimization level must be
between 0 and 3
clang++: error: linker command failed with exit code 1 (use -v to see
invocation)
ninja: build stopped: subcommand failed.
I did not managed how to pass this "-v" options
here are some gradle arguments and global flags from gradle
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=Release",
"-DANDROID_CPP_FEATURES=rtti exceptions",
"-DANDROID_STL=c++_static",
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
cppFlags "-v -ffunction-sections -fdata-sections
-fvisibility=hidden -fvisibility-inlines-hidden -flto"
cFlags "-v -ffunction-sections -fdata-sections
-fvisibility=hidden -fvisibility-inlines-hidden -flto"
}
}
Also I am not sure how to pass some options to linker only (like
-Wl,--exclude-libs=ALL -Wl,--gc-sections) - I tried this
list(APPEND ANDROID_LINKER_FLAGS "-Wl,--exclude-libs=ALL -Wl,--gc-sections
--verbose -flto")
I believe that there is something wrong with exact call to ld but since the
build does not print it I can not compare it with the some call while using
ndk-build/Andorid.mk
using cmake (gradle/Android studio)
While using Android.mk everything is working as expected - I am compiling a
couple of static libraries using optimization level -Oz and LTO (-flto) and
the it links fine.
But when I switched to cmake I use the same compilation options the code
compiles but it can't be linked. Currently I can not find exact ld but it
gives the following error:
arm-linux-androideabi/bin/ld: fatal error: Optimization level must be
between 0 and 3
clang++: error: linker command failed with exit code 1 (use -v to see
invocation)
ninja: build stopped: subcommand failed.
I did not managed how to pass this "-v" options
here are some gradle arguments and global flags from gradle
externalNativeBuild {
cmake {
arguments "-DCMAKE_BUILD_TYPE=Release",
"-DANDROID_CPP_FEATURES=rtti exceptions",
"-DANDROID_STL=c++_static",
"-DCMAKE_VERBOSE_MAKEFILE:BOOL=ON"
cppFlags "-v -ffunction-sections -fdata-sections
-fvisibility=hidden -fvisibility-inlines-hidden -flto"
cFlags "-v -ffunction-sections -fdata-sections
-fvisibility=hidden -fvisibility-inlines-hidden -flto"
}
}
Also I am not sure how to pass some options to linker only (like
-Wl,--exclude-libs=ALL -Wl,--gc-sections) - I tried this
list(APPEND ANDROID_LINKER_FLAGS "-Wl,--exclude-libs=ALL -Wl,--gc-sections
--verbose -flto")
I believe that there is something wrong with exact call to ld but since the
build does not print it I can not compare it with the some call while using
ndk-build/Andorid.mk
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/6f9f1631-f5de-40aa-8e66-cf8f8acbcb3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-ndk+***@googlegroups.com.
To post to this group, send email to android-***@googlegroups.com.
Visit this group at https://groups.google.com/group/android-ndk.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-ndk/6f9f1631-f5de-40aa-8e66-cf8f8acbcb3f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.