View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0014020CMakeCMakepublic2013-03-16 14:482013-11-04 09:33
ReporterModestas Vainius 
Assigned ToBrad King 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
Platformamd64OSDebian GNU/LinuxOS Versionsid
Product VersionCMake 2.8.10.2 
Target VersionCMake 2.8.12Fixed in VersionCMake 2.8.12 
Summary0014020: cmake -E touch truncates time to seconds
DescriptionWhen using "cmake -E touch" on an existing file, the modification time
is truncated at the precision of a second. This can be seen e.g. on an
ext4 filesystem.

Steps To ReproduceHow to reproduce (file1 is used with "touch", and file2 is used with
"cmake -E touch"):

# In an empty directory...
$ ls -l
total 0

# Create the two files: file1 and file2
$ touch file1 ; cmake -E touch file2 ; ls -l --full-time
-rw-r----- 1 xxxx xxxx 0 2013-02-03 02:00:57.827669619 +0100 file1
-rw-r----- 1 xxxx xxxx 0 2013-02-03 02:00:57.831669779 +0100 file2

# Note that the times look good here (file1 < file2)

# Touch the two files again
$ touch file1 ; cmake -E touch file2 ; ls -l --full-time
-rw-r----- 1 xxxx xxxx 0 2013-02-03 02:01:01.595819478 +0100 file1
-rw-r----- 1 xxxx xxxx 0 2013-02-03 02:01:01.000000000 +0100 file2


Now, the modification time of file2 is *before* that of file1, but file2
was touched *after* file1.
Additional InformationRelayed from Debian bug report at http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=699657 [^]

What is more, I have easily reproduced it with 2.8.11-rc1.
TagsNo tags attached.
Attached Filespatch file icon 0001-Touch-with-better-than-1s-resolution-if-possible.patch [^] (3,420 bytes) 2013-03-18 11:22 [Show Content]

 Relationships
related to 0014023closedBrad King cmake -E touch / touch_nocreate of a directory fails on Windows yet succeeds on Linux 

  Notes
(0032649)
Brad King (manager)
2013-03-16 19:36

Discussion on developer list:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/5994/focus=5997 [^]
(0032651)
Brad King (manager)
2013-03-16 20:56

It looks like we already have the necessary checks to construct a platform-specific implementation over in the libarchive sources:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c;hb=v2.8.10.2#l1966 [^]
 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c;hb=v2.8.10.2#l2285 [^]

There are two places we currently use utime that will need to be fixed:

* cmsys::SystemTools::Touch:

  http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/kwsys/SystemTools.cxx;hb=v2.8.10.2#l1134 [^]

* cmSystemTools::CopyFileTime

  http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmSystemTools.cxx;hb=v2.8.10.2#l2152 [^]
(0032659)
Brad King (manager)
2013-03-18 11:23

More work will be needed to make this work cross-platform and to fix everything mentioned in 0014020:0032651, but try "0001-Touch-with-better-than-1s-resolution-if-possible.patch". It should be good enough to apply during Debian packaging.
(0033156)
irwin (reporter)
2013-05-30 15:44

Glad to see you have at least a Unix patch for this issue which uses
utimensat if it is available. I would suggest changing that patch so
that utimensat, utimes, or utime are used in that order depending on
availability. utimensat (nanosecond time resolution) obsoletes utimes
(microsecond time resolution) which obsoletes utime (one-second time
resolution which is what CMake currently uses, ugh).

Using high-resolution (microsecond if not nanosec) time is an
important build-system issue and especially important for
ExternalProject_Add and friends since they rely exclusively on time
stamps generated by cmake -E touch. So I hope finishing up this bug
fix (the remaining issues are summarized in the bug report, but I
would also add utimes into the mix as suggested above since some Unix
systems and Microsoft don't have access to utimensat yet) soon gets
back on your high priority list rather than being backlogged (the
current status).
(0033207)
Brad King (manager)
2013-06-03 10:48

SystemTools::Touch fixed in upstream KWSys here:

 http://public.kitware.com/gitweb?p=KWSys.git;a=commitdiff;h=dccf7725 [^]

and integrated into CMake here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d66f6f36 [^]
(0033208)
Brad King (manager)
2013-06-03 10:52

Resolving this issue as the originally reported problem is now fixed.

The cmSystemTools::CopyFileTime mentioned in 0014020:0032651 is a separate issue. I think 1s may be sufficient for that in current use cases, and it is more complicated because it could deal with two filesystems supporting different resolutions.
(0034354)
Robert Maynard (manager)
2013-11-04 09:33

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2013-03-16 14:48 Modestas Vainius New Issue
2013-03-16 19:36 Brad King Note Added: 0032649
2013-03-16 20:56 Brad King Note Added: 0032651
2013-03-18 11:22 Brad King File Added: 0001-Touch-with-better-than-1s-resolution-if-possible.patch
2013-03-18 11:23 Brad King Note Added: 0032659
2013-03-18 11:23 Brad King Status new => backlog
2013-03-18 13:38 Brad King Relationship added related to 0014023
2013-05-30 15:44 irwin Note Added: 0033156
2013-05-31 16:38 Brad King Assigned To => Brad King
2013-05-31 16:38 Brad King Status backlog => assigned
2013-05-31 16:38 Brad King Target Version => CMake 2.8.12
2013-06-03 10:48 Brad King Note Added: 0033207
2013-06-03 10:52 Brad King Note Added: 0033208
2013-06-03 10:52 Brad King Status assigned => resolved
2013-06-03 10:52 Brad King Resolution open => fixed
2013-06-03 10:52 Brad King Fixed in Version => CMake 2.8.12
2013-11-04 09:33 Robert Maynard Note Added: 0034354
2013-11-04 09:33 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team