Gradle 2.10 native C++ build up-to-date with #include using macro forces full rebuild

Greetings Gradle developers. Using Gradle 2.10 for a very large C++ project I noticed a significant recompilation of up-to-date source files. I tracked this down to the known issue stated in the release notes for 2.10.

For C++ and related languages, Gradle uses source file parsing to determine the set of included headers for a source file. If Gradle cannot determine the set of included headers, it will fall back to the old mechanism of including all files in all include directories as inputs. This means that using a macro to define an #include file is not recommended, as it can prevent Gradle from taking advantage of this optimization.

In practice the approach seems to have a logic error which makes any change to one CPP source file to reevaluate all CPP sources against their includes and mark them as out-of-date. As an experiment I changed the logic that marks the dependency as changed when an include is “unknown” to simply ignore the unknown include. It will still hash the include file itself but not declare it out-of-date just because the dependency is not a readable file. I understand that this is a limited application since the conditional include may in fact change by a redefinition but in our case that is simply not true and I prefer not to enforce such handling.

Could we have perhaps a documented “Strategy” option for such issues until a more robust option is implemented? I am thinking of a system property perhaps controlling the flagging of the include as out-of-date or not. I plan to make this change as a temporary patch to solve my immediate problem and produce a pull request for your review.

For reference I have this issue use the Boost library for C++. It has several #include references that are not file names but #define macros that are evaluated at compile time.

This is the output seen in cases of recompilation with my projects pointing squarely to the Boost include files.

Cannot determine changed state of included ‘BOOST_USER_CONFIG’ in source file ‘config.hpp’. Assuming changed.
Cannot determine changed state of included ‘AUX778076_INCLUDE_STRING’ in source file ‘include_preprocessed.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_SLIST_HEADER’ in source file ‘slist_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘abi_prefix.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_SUFFIX’ in source file ‘abi_suffix.hpp’. Assuming changed.
Cannot determine changed state of included ‘AUX778076_INCLUDE_STRING’ in source file ‘include_preprocessed.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_INTRUSIVE_INVARIANT_ASSERT_INCLUDE’ in source file ‘assert.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_REGEX_USER_CONFIG’ in source file ‘config.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_traits_defaults.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘pattern_except.hpp’. Assuming changed.
Cannot determine changed state of included ‘B1’ in source file ‘static_mutex.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘primary_transform.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘cpp_regex_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘c_regex_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘w32_regex_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_raw_buffer.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘char_regex_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘states.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regbase.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘iterator_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘basic_regex.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘basic_regex_creator.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘basic_regex_parser.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘sub_match.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_format.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘match_results.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘protected_call.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘perl_matcher_recursive.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘perl_matcher_non_recursive.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘perl_matcher_common.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘perl_matcher.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘instances.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_match.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_search.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_iterator.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_token_iterator.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_grep.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_replace.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_merge.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_ABI_PREFIX’ in source file ‘regex_split.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_SLIST_HEADER’ in source file ‘slist.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_SLIST_HEADER’ in source file ‘container_traits.hpp’. Assuming changed.
Cannot determine changed state of included ‘BOOST_SLIST_HEADER’ in source file ‘adjacency_list.hpp’. Assuming changed.

Thanks,
Alex Volanis

4 Likes

Hi! Our team encounters the same problem. We had to revert Gradle scripts to use ndk-build command and Android.mk. Please let know if this issue will be considered and when.

Thank you in advance,
Mikhail Pomakhin