[lld] 858e8b1 - [lld/mac] On Apple systems, call CC_SHA256 from libSystem
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 21 11:58:15 PDT 2022
Author: Nico Weber
Date: 2022-06-21T14:58:04-04:00
New Revision: 858e8b17f73652f9b79a8fd409b1f873c50ecd53
URL: https://github.com/llvm/llvm-project/commit/858e8b17f73652f9b79a8fd409b1f873c50ecd53
DIFF: https://github.com/llvm/llvm-project/commit/858e8b17f73652f9b79a8fd409b1f873c50ecd53.diff
LOG: [lld/mac] On Apple systems, call CC_SHA256 from libSystem
It's in libSystem, so it doesn't bring in any new deps, and it's
currently much faster than LLVM's current SHA256 implementation.
Makes linking (arm64) Chromium Framework with ld64.lld 17% faster.
See also PR56121.
No behavior change.
Differential Revision: https://reviews.llvm.org/D128290
Added:
Modified:
lld/MachO/SyntheticSections.cpp
Removed:
################################################################################
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 6de4c308a4af..1aa8a4d86185 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -23,10 +23,14 @@
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/LEB128.h"
#include "llvm/Support/Path.h"
-#include "llvm/Support/SHA256.h"
#if defined(__APPLE__)
#include <sys/mman.h>
+
+#define COMMON_DIGEST_FOR_OPENSSL
+#include <CommonCrypto/CommonDigest.h>
+#else
+#include "llvm/Support/SHA256.h"
#endif
#ifdef LLVM_HAVE_LIBXAR
@@ -45,10 +49,16 @@ using namespace lld::macho;
// Reads `len` bytes at data and writes the 32-byte SHA256 checksum to `output`.
static void sha256(const uint8_t *data, size_t len, uint8_t *output) {
+#if defined(__APPLE__)
+ // FIXME: Make LLVM's SHA256 faster and use it unconditionally. See PR56121
+ // for some notes on this.
+ CC_SHA256(data, len, output);
+#else
ArrayRef<uint8_t> block(data, len);
std::array<uint8_t, 32> hash = SHA256::hash(block);
assert(hash.size() == CodeSignatureSection::hashSize);
memcpy(output, hash.data(), hash.size());
+#endif
}
InStruct macho::in;
More information about the llvm-commits
mailing list