1
1
mirror of https://github.com/rui314/mold.git synced 2024-09-11 21:17:28 +03:00

Suppress OpenSSL 3.0's deprecation warnings

OpenSSL deprecates the low-level crypto APIs in OpenSSL 3.0. I guess
there's a reason to do that for them, but for us, the low-level APIs
such as SHA256_CTX, SHA256_Update or SHA256_Final are exactly what we
want to use. After all, we just want to compute SHA256 checksums.

The high-level API that OpenSSL provides requires users to allocate a
context object using new_ctx(). That has some performance hit as it
requires heap allocation. And it's just complicated too.

So, I decided to stick with the deprecated functions at least for now
and just suppresss the warning message by defining
OPENSSL_SUPPRESS_DEPRECATED macro. If OpenSSL deletes these functions,
we need to do something, but it's too early to worry about it.

Fixes https://github.com/rui314/mold/issues/246
This commit is contained in:
Rui Ueyama 2022-01-28 08:54:04 +09:00
parent 379ee22af3
commit 32a7e7cb17
5 changed files with 12 additions and 30 deletions

View File

@ -53,6 +53,7 @@
// thread and even better with multiple threads.
#include "mold.h"
#include "../sha.h"
#include <array>
#include <tbb/concurrent_unordered_map.h>
@ -62,13 +63,6 @@
#include <tbb/parallel_for_each.h>
#include <tbb/parallel_sort.h>
#ifdef __APPLE__
# define COMMON_DIGEST_FOR_OPENSSL
# include <CommonCrypto/CommonDigest.h>
#else
# include <openssl/sha.h>
#endif
static constexpr int64_t HASH_SIZE = 16;
typedef std::array<uint8_t, HASH_SIZE> Digest;

View File

@ -1,18 +1,11 @@
#include "mold.h"
#include "../sha.h"
#include <shared_mutex>
#include <sys/mman.h>
#include <tbb/parallel_for_each.h>
#include <tbb/parallel_sort.h>
#ifdef __APPLE__
# define COMMON_DIGEST_FOR_OPENSSL
# include <CommonCrypto/CommonDigest.h>
# define SHA256(data, len, md) CC_SHA256(data, len, md)
#else
# include <openssl/sha.h>
#endif
namespace mold::elf {
template <typename E>

View File

@ -1,4 +1,5 @@
#include "mold.h"
#include "../sha.h"
#include <filesystem>
#include <signal.h>
@ -11,13 +12,6 @@
#include <sys/wait.h>
#include <unistd.h>
#ifdef __APPLE__
# define COMMON_DIGEST_FOR_OPENSSL
# include <CommonCrypto/CommonDigest.h>
#else
# include <openssl/sha.h>
#endif
#define DAEMON_TIMEOUT 30
namespace mold::elf {

View File

@ -1,16 +1,9 @@
#include "mold.h"
#include "../sha.h"
#include <shared_mutex>
#include <sys/mman.h>
#ifdef __APPLE__
# define COMMON_DIGEST_FOR_OPENSSL
# include <CommonCrypto/CommonDigest.h>
# define SHA256(data, len, md) CC_SHA256(data, len, md)
#else
# include <openssl/sha.h>
#endif
namespace mold::macho {
template <typename E>

8
sha.h Normal file
View File

@ -0,0 +1,8 @@
#ifdef __APPLE__
# define COMMON_DIGEST_FOR_OPENSSL
# include <CommonCrypto/CommonDigest.h>
# define SHA256(data, len, md) CC_SHA256(data, len, md)
#else
# define OPENSSL_SUPPRESS_DEPRECATED 1
# include <openssl/sha.h>
#endif