[cmake-developers] [CMake 0015769]: OS X: Filesystem timestamp checks use only 1s resolution
Ruslan Baratov
ruslan_baratov at yahoo.com
Fri Oct 9 18:00:09 EDT 2015
On 08-Oct-15 21:03, Mantis Bug Tracker wrote:
> The following issue has been ASSIGNED.
> ======================================================================
> https://cmake.org/Bug/view.php?id=15769
> ======================================================================
> Reported By: Ruslan Baratov
> Assigned To: Brad King
> ======================================================================
> Project: CMake
> Issue ID: 15769
> Category: CMake
> Reproducibility: always
> Severity: minor
> Priority: normal
> Status: resolved
> Target Version: CMake 3.5
> Resolution: fixed
> Fixed in Version: CMake 3.5
> ======================================================================
> Date Submitted: 2015-10-05 10:37 EDT
> Last Modified: 2015-10-08 14:03 EDT
> ======================================================================
> Summary: OS X: Filesystem timestamp checks use only 1s
> resolution
> Description:
> `cmake --build` command doesn't trigger reconfiguration of the project on OS X
> when CMakeLists.txt changed.
>
> Example:
>
> add_executable(foo foo.cpp) # file foo.cpp exists
>
> cmake -H. -B_builds
> cmake --build _builds
> # OK
>
> change:
> add_executable(foo foo.cpp boo.cpp) # file boo.cpp not exists
> cmake --build _builds
> # expected error, but no error reported
>
> Ready-to-run example can be found:
> https://github.com/forexample/cmake-osx-no-reconfigure-bug
>
> Log from OS X machine:
> * https://travis-ci.org/forexample/cmake-osx-no-reconfigure-bug/builds/83701171
>
> Log for similar test on Linux machine:
> * https://travis-ci.org/forexample/cmake-osx-no-reconfigure-bug/builds/83702953
>
> CMake on Linux machine run reconfigure command and report an error:
> cmake -H. -B_builds --check-build-system CMakeFiles/Makefile.cmake 0
> -- Configuring done
> CMake Error at CMakeLists.txt:4 (add_executable):
> Cannot find source file:
> boo.cpp
>
> same error expected on OS X machine
> ======================================================================
>
> ----------------------------------------------------------------------
> (0039511) Brad King (manager) - 2015-10-05 14:45
> https://cmake.org/Bug/view.php?id=15769#c39511
> ----------------------------------------------------------------------
> I can reproduce this when running 'make' directly without 'cmake --build':
>
> -cmake --build _builds
> +(cd _builds; make)
>
> The problem is that the filesystem and/or make tool seem to have 1s timestamp
> resolution. If I change the script to do "sleep 1" before the last "cp
> CMakeBad.txt CMakeLists.txt" then it works.
>
> ----------------------------------------------------------------------
> (0039512) Brad King (manager) - 2015-10-05 14:52
> https://cmake.org/Bug/view.php?id=15769#c39512
> ----------------------------------------------------------------------
> The issue may be where CMake decides whether it needs to re-run:
>
> https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmFileTimeComparison.cxx;hb=v3.3.2#l147
>
> The STAT_HAS_ST_MTIM code path may not be taken on this platform.
>
> ----------------------------------------------------------------------
> (0039513) Brad King (manager) - 2015-10-05 14:54
> https://cmake.org/Bug/view.php?id=15769#c39513
> ----------------------------------------------------------------------
> Indeed, on OS X "struct stat" has:
>
> struct timespec st_mtimespec;
>
> instead of
>
> struct timespec st_mtim;
>
> ----------------------------------------------------------------------
> (0039518) Brad King (manager) - 2015-10-06 13:27
> https://cmake.org/Bug/view.php?id=15769#c39518
> ----------------------------------------------------------------------
> For reference, I've started a fix for this on the KWSys side here:
>
> http://review.source.kitware.com/20258/
>
> ----------------------------------------------------------------------
> (0039519) Brad King (manager) - 2015-10-06 14:04
> https://cmake.org/Bug/view.php?id=15769#c39519
> ----------------------------------------------------------------------
> It looks like the underlying HFS filesystem only has 1s resolution:
>
> https://en.wikipedia.org/wiki/HFS_Plus
>
> This may not be possible to fix without a "sleep 1" in the test script.
>
> ----------------------------------------------------------------------
> (0039548) Brad King (manager) - 2015-10-08 14:01
> https://cmake.org/Bug/view.php?id=15769#c39548
> ----------------------------------------------------------------------
> After the KWSys side learned to use st_mtimespec I've updated CMake too:
>
> cmFileTimeComparison: Port to OS X nanosecond times
> https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8d27b407
>
> ----------------------------------------------------------------------
> (0039549) Brad King (manager) - 2015-10-08 14:03
> https://cmake.org/Bug/view.php?id=15769#c39549
> ----------------------------------------------------------------------
> Marking as resolved because the proper API for ns resolution is now used.
> However in practice the underlying filesystem may limit the resolution anyway.
>
>
> Issue History
> Date Modified Username Field Change
> ======================================================================
> 2015-10-05 10:37 Ruslan Baratov New Issue
> 2015-10-05 14:45 Brad King Note Added: 0039511
> 2015-10-05 14:52 Brad King Note Added: 0039512
> 2015-10-05 14:53 Brad King Summary Change of
> CMakeLists.txt doesn't trigger reconfigure => OS X: Filesystem timestamp checks
> use only 1s resolution
> 2015-10-05 14:54 Brad King Note Added: 0039513
> 2015-10-06 13:27 Brad King Note Added: 0039518
> 2015-10-06 14:04 Brad King Note Added: 0039519
> 2015-10-08 14:01 Brad King Note Added: 0039548
> 2015-10-08 14:03 Brad King Note Added: 0039549
> 2015-10-08 14:03 Brad King Assigned To => Brad King
> 2015-10-08 14:03 Brad King Status new => resolved
> 2015-10-08 14:03 Brad King Resolution open => fixed
> 2015-10-08 14:03 Brad King Fixed in Version => CMake 3.5
> 2015-10-08 14:03 Brad King Target Version => CMake 3.5
> ======================================================================
>
Hi,
While viewing changes you've made I found an "interesting" behaviour of
CMake's install procedure. Since it's not about this bug exactly I'm
moving it to 'cmake-developers' list. Function
cmFileTimeComparisonInternal::TimesDiffer use only limited number of
digits of timestamp and used in install step. This may lead to the
similar bugs.
Here is the result of my white-box testing skills:
script:
https://github.com/forexample/cmake-header-install-bug/blob/master/run-test.sh
log:
https://travis-ci.org/forexample/cmake-header-install-bug/builds/84592318
-- Up-to-date:
/Users/travis/build/forexample/cmake-header-install-bug/_install/include/foo.hpp
1c1
< Bad
---
> Good
Error: file not installed!
So installed foo.hpp file is not updated. This may be quite surprising
in automated tools like git-bisect. Also I've found
`CMAKE_INSTALL_ALWAYS` environment variable but it's not documented.
Thanks, Ruslo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20151010/95c0f40c/attachment.html>
More information about the cmake-developers
mailing list