make-w32
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

directory caching anomalies in win32


From: Aaron Shatters
Subject: directory caching anomalies in win32
Date: Fri, 20 Apr 2007 12:06:57 -0700 (PDT)

Consider the following makefile:
###############################################
SHELL = C:\WINNT\system32\cmd.exe

DELETE_FILE = $(shell if exist $(1) del /q $(1) >nul)
CHECK_FILE_NOT_EXISTS = $(if $(wildcard $(1)),$(error Cannot delete "$(realpath 
$(1))"))

DUMP := $(call DELETE_FILE,common.incs)
DUMP := $(call CHECK_FILE_NOT_EXISTS,common.incs)

all:
    @echo Success.
###############################################

If "common.incs" exists before running this makefile, it will fail.  This is 
because make caches the directory contents, and it doesn't consider rehashing 
the directory contents until it is looking for a file that doesn't exist in 
it's cache.  Which leads me to the next problem...  consider the following 
makefile:

###############################################
SHELL = C:\WINNT\system32\cmd.exe

CREATE_FILE = $(shell copy nul $(1) >nul)
CHECK_FILE_EXISTS = $(if $(wildcard $(1)),,$(error Cannot create "$(realpath 
$(1))"))

DUMP := $(call CREATE_FILE,common.incs)
DUMP := $(call CHECK_FILE_EXISTS,common.incs)

all:
    @echo Success.
###############################################

If "common.incs" doesn't exist before running this makefile, it will 
<sometimes> fail.  This is because make will not find this file in its 
directory contents cache hash, so it will consider rehashing the directory 
contents into its cache.  On NTFS file systems, it compares the mtime of the 
current directory contents cache with the mtime of the actual directory 
contents cache.  If the actual directory contents cache is newer than the 
cached contents, then it will rehash the directory contents.  The problem seems 
to be that mtime for the directory is not updated by the file system fast 
enough before make is checking it.  The file is created, the directory stat() 
mtime is checked, then the file system updates the directory mtime.  The timing 
is all messed up.

Furthermore, even if the file system updated the mtime on the directory 
immediately, you can actually mess make up by using $(shell copy nul somefile), 
then $(wildcard somefile), then $(shell copy nul somefile2), then $(wildcard 
somefile2)... as long as somefile and somefile2 didn't exist when make was 
called.  This is because mtime only has a resolution of seconds, so any file 
you create within a 0-1 seconds of the last cache will be invisible to make.  
This is the third problem that I faced.

I am finding all of this on:
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
I haven't tried XP yet.

I can actually get around this problem by using $(shell if exist somefile echo 
somefile) because this totally bypasses makes directory contents cache and goes 
directly to the shell, however I thought that this was kind of a big problem 
that could effect other things.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]