Кирилл Лейфер
2017-12-20 10:18:13 UTC
Hi everyone,
My Android project generates native executables as part of the build, and
also it should support all devices starting from API 14 (Android 4.0).
As you know, Android 4.0 supports only non-PIE executables, while Android >
5.0 does support only PIE ones.So I should generate both PIE and non-PIE
executables, and I can't find any suitable way to achieve that on my
current setup (Android Studio 3.0, NDK r16, llvm-5.0).
I was using the following hack for Android Studio 2.3 and NDK r15 in my
CMakeLists.txt file:
add_executable(hello
src/main/cpp/main.cpp
)
add_executable(hello-nonpie
src/main/cpp/main.cpp
)
target_compile_definitions(hello
PRIVATE
-DANDROID_PIE=ON
)
target_compile_definitions(hello-nonpie
PRIVATE
-DANDROID_PIE=OFF
)
This hack does not work anymore on AS 3.0 and NDK r16 - it produces non-PIE
binaries only as my `minSdkVersion` is set to 14, or PIE binaries only if I
explicitly pass `-DANDROID_PIE=ON` argument to CMake.
The only way I found to embed both PIE and non-PIE versions in one build is
to create two identical Android library modules. They build same binaries,
but one of them passes `-DANDROID_PIE=ON` argument to CMake. Then I include
those project as my app dependencies. It does work, but slows down
configure & build time more than twice as now I have not one but three
projects (app itself and two modules, each of them configuring builds for
multiple architectures).
Any thoughts on solving this problem more nicely?
My Android project generates native executables as part of the build, and
also it should support all devices starting from API 14 (Android 4.0).
As you know, Android 4.0 supports only non-PIE executables, while Android >
5.0 does support only PIE ones.So I should generate both PIE and non-PIE
executables, and I can't find any suitable way to achieve that on my
current setup (Android Studio 3.0, NDK r16, llvm-5.0).
I was using the following hack for Android Studio 2.3 and NDK r15 in my
CMakeLists.txt file:
add_executable(hello
src/main/cpp/main.cpp
)
add_executable(hello-nonpie
src/main/cpp/main.cpp
)
target_compile_definitions(hello
PRIVATE
-DANDROID_PIE=ON
)
target_compile_definitions(hello-nonpie
PRIVATE
-DANDROID_PIE=OFF
)
This hack does not work anymore on AS 3.0 and NDK r16 - it produces non-PIE
binaries only as my `minSdkVersion` is set to 14, or PIE binaries only if I
explicitly pass `-DANDROID_PIE=ON` argument to CMake.
The only way I found to embed both PIE and non-PIE versions in one build is
to create two identical Android library modules. They build same binaries,
but one of them passes `-DANDROID_PIE=ON` argument to CMake. Then I include
those project as my app dependencies. It does work, but slows down
configure & build time more than twice as now I have not one but three
projects (app itself and two modules, each of them configuring builds for
multiple architectures).
Any thoughts on solving this problem more nicely?
--
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/6f423175-2cf5-4a56-9cc2-03c0bdd89c07%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/6f423175-2cf5-4a56-9cc2-03c0bdd89c07%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.