summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-07-15 23:05:39 +0800
committerruki <[email protected]>2022-07-15 23:05:39 +0800
commit88d14766f002553702706e11a0670dfb36a16809 (patch)
treee85710c4b4c96522991ec70a9769964916b6cc1e
parentf9c2f5820ea91900d7b5d5fe739dec5532bc215a (diff)
fix object file depend
-rw-r--r--xmake/modules/private/action/build/object.lua9
1 files changed, 7 insertions, 2 deletions
diff --git a/xmake/modules/private/action/build/object.lua b/xmake/modules/private/action/build/object.lua
index b8816f446..c906ea8de 100644
--- a/xmake/modules/private/action/build/object.lua
+++ b/xmake/modules/private/action/build/object.lua
@@ -49,10 +49,15 @@ function _do_build_file(target, sourcefile, opt)
local dryrun = option.get("dry-run")
-- need build this object?
- -- @note we use mtime(dependfile) instead of mtime(objectfile) to ensure the object file is is fully compiled.
+ --
+ -- we need use `os.mtime(dependfile)` to determine the mtime of the dependfile to avoid objectfile corruption due to compilation interruptions
-- @see https://github.com/xmake-io/xmake/issues/748
+ --
+ -- we also need avoid the problem of not being able to recompile after the objectfile has been deleted
+ -- @see https://github.com/xmake-io/xmake/issues/2551#issuecomment-1183922208
local depvalues = {compinst:program(), compflags}
- if not dryrun and not depend.is_changed(dependinfo, {lastmtime = os.mtime(dependfile), values = depvalues}) then
+ local lastmtime = os.isfile(objectfile) and os.mtime(dependfile) or 0
+ if not dryrun and not depend.is_changed(dependinfo, {lastmtime = lastmtime, values = depvalues}) then
return
end