How to do Incremental build with updated compiler flags

295 views
Skip to first unread message

Vijay Ede

unread,
Aug 3, 2023, 9:06:10 AM8/3/23
to Android Building
Hi,
I want to check if we have an option to do incremental build after we change C/C++ compiler flags in the build configuration files like .json, .mk or .bp.

Currently i am seeing if we update the compiler flags in the config file and do incremental build it is not taking the upadated flags. we have to delete the out/ folder and run full build again for updated flags to affect and this takes longer build times.

The context i am looking for this is when we do toolchain version migration we might have some compiler related errors which might need update in compiler flags. So instead of doing clean build, i am looking for a way that rest of the build from the point of error continues with new flags.

Thanks
Vijay

Dan Willemsen

unread,
Aug 3, 2023, 10:42:12 AM8/3/23
to android-...@googlegroups.com
Any changes in .mk / .bp files should be producing correct incremental builds -- in general since the ninja migration in Android N, though there have been some bug fixes over the years since for some specific use cases. Bug reports would be useful for any cases that you can reproduce on AOSP.

change C/C++ compiler flags in the build configuration files like .json

I'm unaware of any places where we load compiler flags from json files. If you've made your own changes to the build system or compiler, that may need more changes in the build system to produce correct incremental builds (marking any additional files read as dependencies to wherever they're read).

One of the special cases is that we don't actually depend on the clang compiler itself for incremental builds, so if you update it in place, that may not trigger rebuilds. Our compiler updates are in version-specific paths, and the path change will trigger a command line change, and thus proper incremental builds.

- Dan

--
--
You received this message because you are subscribed to the "Android Building" mailing list.
To post to this group, send email to android-...@googlegroups.com
To unsubscribe from this group, send email to
android-buildi...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-building?hl=en

---
You received this message because you are subscribed to the Google Groups "Android Building" group.
To unsubscribe from this group and stop receiving emails from it, send an email to android-buildi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/android-building/4f428018-1cd4-4e6f-9897-d29cfe821479n%40googlegroups.com.

Vijay Ede

unread,
Aug 7, 2023, 2:22:33 PM8/7/23
to Android Building

Thanks Dan for the response. Yes we are using a custom json file to maintain compiler flags and this json file is parsed in build/soong/cc/config/global.go file.

I tried adding a Android.bp file to create a module with json file as src file and added this module as dependency in Android.bp file in folder containing global.go file.

This did not work , I got “depends on undefined module test-json” error message in the build.

Is there anyway to add json file as dependency to the go modules?



Also I think that go files are executed only in the clean build not in incremental build. Is it possible to retrigger go files execution in Incremental build to regenerate the build config(  not sure if re running the go files will affect the source file changes timestamps and hashes needed for Incremental build to work).

 

Thanks,

Vijay

Dan Willemsen

unread,
Aug 7, 2023, 2:46:07 PM8/7/23
to android-...@googlegroups.com
We tried to make reading files from Soong difficult to do, since this is very error prone, as shown by this thread. It looks like you may have bypassed these protections by running very early during initialization.

Also I think that go files are executed only in the clean build not in incremental build. Is it possible to retrigger go files execution in Incremental build to regenerate the build config(  not sure if re running the go files will affect the source file changes timestamps and hashes needed for Incremental build to work).

That's what these protections are for, because this happens with upstream Soong -- everything read from Soong (files, environment variables, etc) is tracked, and if any of those changes, the go code is re-executed.

If you manage to read any files in Soong, you must call AddNinjaFileDeps to add those to Soong's dependencies. Any file listing or presence operations must be going through the soong/blueprint Glob methods, and any reading of environment variables must go through the soong's Config environment functions (Getenv / GetenvWithDefault / IsEnvTrue / etc).

- Dan

Reply all
Reply to author
Forward
0 new messages