Open
Description
Description
The toolchain file provided for CMake (found in build/cmake/android.toolchain.cmake
) enables the debug flags -g
in Release mode.
Excerpt of the toolchain file:
# Generic flags.
list(APPEND ANDROID_COMPILER_FLAGS
-g
...)
# ...
# Debug and release flags.
list(APPEND ANDROID_COMPILER_FLAGS_DEBUG
-O0)
It seems that the -g
should be set for ANDROID_COMPILER_FLAGS_DEBUG
, not ANDROID_COMPILER_FLAGS
.
A workaround is to set CMAKE_CXX_FLAGS_RELEASE
to -g0
when configuring the build directory.
Environment Details
Not all of these will be relevant to every bug, but please provide as much
information as you can.
- NDK Version: Pkg.Revision = 13.0.3315539
- Build sytem: CMake
- Host OS: Linux Debian Jessie
- Compiler: Clang
- ABI: arm64-v8a
Metadata
Metadata
Assignees
Labels
No labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
DanAlbert commentedon Nov 29, 2016
I'm guessing this was done for the same reason we do this in ndk-build: we always build a debugable binary but strip the debug info for the APK. I've sent an email to the Studio folks to find out if this is something that we can just fix, or if that's going to break Studio's debugging features (I don't know if they actually use Debug/Release modes).
DanAlbert commentedon Nov 29, 2016
Yeah, sounds like Studio is expecting this. If you're using cmake via gradle, gradle will strip the debug info when you package the app. If you're not using gradle, you'll need to add that logic to your packaging tools.
DanAlbert commentedon Nov 29, 2016
Closed for now, but if there's enough demand for this (I assume the case here is people using cmake and custom packaging tools rather than gradle), it should probably be re-opened and we can look in to getting Studio to do something different.
piwinux commentedon Dec 1, 2016
Thanks for the reply! I understand that Studio is expecting compilation with debug flags even in release mode, but this is counter-intuitive in general, and goes against the default behavior one expects when using CMake in particular. This is actually why I filed this bug.
By default, CMake provides four build types:
Debug
,MinSizeRel
,Release
, andRelWithDebInfo
. The behavior you describe (a release crafted with debug information) pertains with theRelWithDebInfo
build type. I understand the specific needs for Studio, and I definitely understand the need/desires to change the default flags set by CMake, but I believe that the build flags set by the toolchain file should be aligned with the meaning of the build type.The Gradle behavior (stripping the debug symbols afterward) is a specific case, as is how Studio uses CMake. I fail to understand why I would need to do extra work to address a behavior that should not even happen when compiling a release.
DanAlbert commentedon Dec 2, 2016
I've followed up on the email I sent earlier. All makes sense to me, but unfortunately it isn't my decision.
DanAlbert commentedon Dec 2, 2016
Alright, looks like Studio is going to start using
RelWithDebInfo
in a future release (I think it's too late for 2.3 at this point). They've opened a bug for their side of things: https://code.google.com/p/android/issues/detail?id=229391Reopening this for tracking the toolchain file fix. I think we can't actually change anything until their fix lands or we'll end up breaking their debugging, so this is going in the unplanned bucket for now.
piwinux commentedon Dec 5, 2016
Hi, thanks a lot for the feedback. Nice to know it will be considered.
tallytalwar commentedon Feb 8, 2017
Perfect.
On our project, we recently moved to native build setup via gradle using externalnativebuild and cmake and noticed bloated native library sizes in our aar's. But the final apk had stripped out minified native library.
In full agreement with the description of the issue here, and appreciate the android studio team considering the request. 👍
Add release buildType for tangram lib
26 remaining items