Author: zturner Date: Fri Mar 18 17:33:59 2016 New Revision: 263844 URL: http://llvm.org/viewvc/llvm-project?rev=263844&view=rev Log: Fix a build issue where the python module could become stale.
We are using hardlinks instead of symlinks, and we attempted to have some logic where we don't re-create the link if the target file already exists. This logic is faulty, however, when you manually delete the source file (e.g. liblldb.dll) and then rebuild lldb so that a brand new liblldb.dll gets written. Now the two files have different inodes, but the target exists, so we would not remake the link and the target would become stale. We fix this by only doing the optimization if they are really the exact same file (by comparing inode numbers), and if they are not the same file but the target exists, we delete it and re-create the link. Modified: lldb/trunk/scripts/Python/finishSwigPythonLLDB.py Modified: lldb/trunk/scripts/Python/finishSwigPythonLLDB.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/scripts/Python/finishSwigPythonLLDB.py?rev=263844&r1=263843&r2=263844&view=diff ============================================================================== --- lldb/trunk/scripts/Python/finishSwigPythonLLDB.py (original) +++ lldb/trunk/scripts/Python/finishSwigPythonLLDB.py Fri Mar 18 17:33:59 2016 @@ -229,6 +229,23 @@ def make_symlink_windows(vstrSrcPath, vs dbg = utilsDebug.CDebugFnVerbose("Python script make_symlink_windows()") bOk = True strErrMsg = "" + # If the src file doesn't exist, this is an error and we should throw. + src_stat = os.stat(vstrSrcPath) + + try: + target_stat = os.stat(vstrTargetPath) + # If the target file exists but refers to a different file, delete it so that we can + # re-create the link. This can happen if you run this script once (creating a link) + # and then delete the source file (so that a brand new file gets created the next time + # you compile and link), and then re-run this script, so that both the target hardlink + # and the source file exist, but the target refers to an old copy of the source. + if (target_stat.st_ino == src_stat.st_ino) and (target_stat.st_dev == src_stat.st_dev): + return (bOk, strErrMsg) + + os.remove(vstrTargetPath) + except: + # If the target file don't exist, ignore this exception, we will link it shortly. + pass try: csl = ctypes.windll.kernel32.CreateHardLinkW @@ -280,10 +297,6 @@ def make_symlink_native(vDictArgs, strSr bOk = False strErrMsg = strErrMsgOsTypeUnknown elif eOSType == utilsOsType.EnumOsType.Windows: - if os.path.isfile(strTarget): - if bDbg: - print((strMsgSymlinkExists % target_filename)) - return (bOk, strErrMsg) if bDbg: print((strMsgSymlinkMk % (target_filename, strSrc, strTarget))) bOk, strErrMsg = make_symlink_windows(strSrc, _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits