aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2018-11-19 15:33:25 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2018-11-19 15:33:25 +0200
commite5566763f7f3ec3463305056786bc96f208426f7 (patch)
treedc6eac6f168f8a918f75d8a11c27ec84aa913784
parentac5ef35b5fa8b938ed427df4b0ad44e5b6b52cff (diff)
Workaround Apple ar fractional second truncation bug on APFS
-rw-r--r--build2/cc/link-rule.cxx16
1 files changed, 16 insertions, 0 deletions
diff --git a/build2/cc/link-rule.cxx b/build2/cc/link-rule.cxx
index 77619d1..d8434d8 100644
--- a/build2/cc/link-rule.cxx
+++ b/build2/cc/link-rule.cxx
@@ -2542,6 +2542,22 @@ namespace build2
if (!lk.empty ()) {ln (f->leaf (), lk);}
}
+ // Apple ar (from cctools) for some reason truncates fractional seconds
+ // when running on APFS (HFS has a second resolution so it's not an
+ // issue there). This can lead to object files being newer than the
+ // archive, which is naturally bad news.
+ //
+ // Note that this block is not inside #ifdef __APPLE__ because we could
+ // be cross-compiling, theoretically. We also make sure we use Apple's
+ // ar (which is (un)recognized as 'generic') instead of, say, llvm-ar.
+ //
+ if (lt.static_library () &&
+ tsys == "darwin" &&
+ cast<string> (rs["bin.ar.id"]) == "generic")
+ {
+ touch (tp, false /* create */, verb_never);
+ }
+
rm.cancel ();
#ifdef MTIME_SANITY_CHECK