diff options
-rw-r--r-- | build2/cc/link-rule.cxx | 16 |
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 |