diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2018-11-19 15:33:25 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2018-11-19 15:33:25 +0200 |
commit | e5566763f7f3ec3463305056786bc96f208426f7 (patch) | |
tree | dc6eac6f168f8a918f75d8a11c27ec84aa913784 | |
parent | ac5ef35b5fa8b938ed427df4b0ad44e5b6b52cff (diff) |
Workaround Apple ar fractional second truncation bug on APFS
-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 |