From e5566763f7f3ec3463305056786bc96f208426f7 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Mon, 19 Nov 2018 15:33:25 +0200 Subject: Workaround Apple ar fractional second truncation bug on APFS --- build2/cc/link-rule.cxx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 (rs["bin.ar.id"]) == "generic") + { + touch (tp, false /* create */, verb_never); + } + rm.cancel (); #ifdef MTIME_SANITY_CHECK -- cgit v1.1