[PATCH] Verify source files for a module only once during the build

Dmitri Gribenko gribozavr at gmail.com
Fri Feb 7 06:07:27 PST 2014


Hello,

When Clang loads the module, it verifies the user source files that
the module was built from.  If any file was changed, the module is
rebuilt.  There are two problems with this:
1. correctness: we don't verify system files (there are too many of
them, and stat'ing all of them would take a lot of time);
2. performance: the same module file is verified again and again
during a single build.

The attached patch allows the build system to optimize source file
verification.  The idea is based on the fact that while the project is
being built, the source files don't change.  This allows us to verify
the module only once during a single build session.  The build system
passes a flag, fmodules-skip-verify-if-validated-after=, to inform
Clang of the time when the build started (if this flag is not passed,
the behavior is not changed).  When Clang verifies the module the
first time, it writes out a timestamp file.  Then, when Clang loads
the module the second time, it finds a timestamp file, so it can
compare the verification timestamp of the module with the time when
the build started.  If the verification timestamp is too old, the
module is verified again, and the timestamp file is updated.

Please review.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: optimize-module-verification-v1.patch
Type: application/octet-stream
Size: 16553 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140207/43073c19/attachment.obj>


More information about the cfe-commits mailing list