diff options
author | Elliott Sales de Andrade <quantum.analyst@gmail.com> | 2017-11-05 16:33:27 -0500 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-11-06 20:56:53 +0200 |
commit | 671508759821f56a5bc1b4c2d7bb2f71e9d36033 (patch) | |
tree | 05c8d8e9e63edb9756c456a9dc5c6df7baecb8bd /mesonbuild/mesonmain.py | |
parent | c647db96d5fc57fdcd856c629dd3de341eecec42 (diff) | |
download | meson-671508759821f56a5bc1b4c2d7bb2f71e9d36033.zip meson-671508759821f56a5bc1b4c2d7bb2f71e9d36033.tar.gz meson-671508759821f56a5bc1b4c2d7bb2f71e9d36033.tar.bz2 |
Dump coredata earlier.
Unfortunately, `time.time` and file timestamps are not guaranteed to be
in sync and due to various kernel caches may be different enough to
cause rebuilds to fail [1]. This was masked by older ninja versions that
could not read sub-second timestamps.
[1] https://travis-ci.org/mesonbuild/meson/jobs/296797872
Diffstat (limited to 'mesonbuild/mesonmain.py')
-rw-r--r-- | mesonbuild/mesonmain.py | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/mesonbuild/mesonmain.py b/mesonbuild/mesonmain.py index 45e6026..8ecfacd 100644 --- a/mesonbuild/mesonmain.py +++ b/mesonbuild/mesonmain.py @@ -193,23 +193,19 @@ class MesonApp: mlog.log('Build machine cpu family:', mlog.bold(intr.builtin['build_machine'].cpu_family_method([], {}))) mlog.log('Build machine cpu:', mlog.bold(intr.builtin['build_machine'].cpu_method([], {}))) intr.run() - coredata_mtime = time.time() - g.generate(intr) - dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat') - with open(dumpfile, 'wb') as f: - pickle.dump(b, f) - # Write this as late as possible since we use the existence of this - # file to check if we generated the build file successfully, so we - # don't want an error that pops up during generation, etc to cause us to - # incorrectly signal a successful meson run which will cause an error - # about an already-configured build directory when the user tries again. - # - # However, we set the mtime to an earlier value to ensure that doing an - # mtime comparison between the coredata dump and other build files - # shows the build files to be newer, not older. - cdf = env.dump_coredata(coredata_mtime) - # Post-conf scripts must be run after writing coredata or else introspection fails. try: + # We would like to write coredata as late as possible since we use the existence of + # this file to check if we generated the build file successfully. Since coredata + # includes settings, the build files must depend on it and appear newer. However, due + # to various kernel caches, we cannot guarantee that any time in Python is exactly in + # sync with the time that gets applied to any files. Thus, we dump this file as late as + # possible, but before build files, and if any error occurs, delete it. + cdf = env.dump_coredata() + g.generate(intr) + dumpfile = os.path.join(env.get_scratch_dir(), 'build.dat') + with open(dumpfile, 'wb') as f: + pickle.dump(b, f) + # Post-conf scripts must be run after writing coredata or else introspection fails. g.run_postconf_scripts() except: os.unlink(cdf) |