You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Duplicate compiler flags on first CMake invocation #323
I'm using NDK r14, but have observed this behavior in earlier NDKs as well: When generating the build directory with CMake, the first invocation adds the Android-specific compiler flags twice. E.g. when compiling for armeabiv7-a, I'm seeing two sets of these flags:
While this doesn't make the build fail, a subsequent rerun of CMake (e.g. triggered by a changed CMakeLists.txt file) will rebuild the ninja file to only include one set of these flags. This will in turn trigger a full recompile of all sources, since the compile flags changed. On larger project, this is undesirable since it takes a long time.
The error happens because CMake invokes the toolchain file twice during the first build, but only once during subsequent build system rebuilds.
This can be solved by adding an include guard at the top of the toolchain file:
Possibly related: When a build fails with an error in Android Studio the first time after having changed CMakeLists or its parameters, it immediately starts another gradle sync and wipes out the build log from the Gradle Console window, which is pretty annoying.
Actually, still happens with the snipped fix added, so it's an unrelated issue.
Repro:
Cause a compiler error, for example insert #error hello anywhere in your C++ code
build (click the hammer button). wait for it to error.
Change your CMakelists.txt (say, add message("hello")
build again
After step 4, gradle will immediately wipe the build log when the build error happens and start a sync, as I mentioned above, requiring another click on the build button to see the error text.
Activity
DanAlbert commentedon Mar 13, 2017
Given how temperamental cmake toolchain files seem to be, I'm going to get this into r15 beta 1 to try to flush out any issues early.
hrydgard commentedon Mar 13, 2017
Possibly related: When a build fails with an error in Android Studio the first time after having changed CMakeLists or its parameters, it immediately starts another gradle sync and wipes out the build log from the Gradle Console window, which is pretty annoying.
DanAlbert commentedon Mar 13, 2017
Does that happen even with the snippet to fix this is added? If so it's probably something we should raise with the Studio team.
hrydgard commentedon Mar 13, 2017
Actually, still happens with the snipped fix added, so it's an unrelated issue.
Repro:
#error helloanywhere in your C++ codemessage("hello")After step 4, gradle will immediately wipe the build log when the build error happens and start a sync, as I mentioned above, requiring another click on the build button to see the error text.
Guess I should go file that over at https://code.google.com/p/android/issues/entry?template=Tools%20bug%20report ?
DanAlbert commentedon Mar 15, 2017
@hrydgard: Yeah, they should be able to help you.
https://android-review.googlesource.com/c/353248/ to fix spurious rebuilds in r15 beta 1. Thanks for the fix, @kkaefer!
Add cmake include guard to avoid spurious rebuilds.
cmake: Fix Android build for r25 NDK
cmake: Fix Android build for r25 NDK
cmake: Fix Android build for r25 NDK