Sometimes Android does stuff that is probably a good idea, but is really annoying to the compiler. By compiler, I mean guys or gals like you and I who really want to compile AOSP 7.0, but can’t because all of our old device trees have cflags set. Without warning, AOSP institues the ninja build system, and then declares all cflags to be illegal. Bummer.

Bummer that is, unless we disable the bailout.

Open up ./build/core/config.mk, and scroll down to line 630, where you should see the below.

[CODE]
# ###############################################################
# Set up final options.
# ###############################################################

ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
$(warning COMMON_GLOBAL_C(PP)FLAGS changed)
$(info *** Device configurations are no longer allowed to change the global flags.)
$(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
$(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
$(error bailing…)
endif
[/CODE]

Which I changed to this:

[CODE]
# ###############################################################
# Set up final options.
# ###############################################################
#I disagree with your cflags policy. So there. (Go ahead and tell AOSP how you really feel.)
#ifneq ($(COMMON_GLOBAL_CFLAGS)$(COMMON_GLOBAL_CPPFLAGS),)
#$(warning COMMON_GLOBAL_C(PP)FLAGS changed)
#$(info *** Device configurations are no longer allowed to change the global flags.)
#$(info *** COMMON_GLOBAL_CFLAGS: $(COMMON_GLOBAL_CFLAGS))
#$(info *** COMMON_GLOBAL_CPPFLAGS: $(COMMON_GLOBAL_CPPFLAGS))
#$(error bailing…)
#endif
[/CODE]

Problem solved. you may now use your good ol’ cflags. Carry on.

Linux – keep it simple.

Leave a Reply

Your email address will not be published.