Re: [cmake-developers] [CMake 0015769]: OS X: Filesystem timestamp checks use only 1s resolution

2015-10-09 Thread Ruslan Baratov via cmake-developers

On 10-Oct-15 01:00, Ruslan Baratov via cmake-developers wrote:

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=157

Re: [cmake-developers] [CMake 0015769]: OS X: Filesystem timestamp checks use only 1s resolution

2015-10-09 Thread Ruslan Baratov via cmake-developers

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