mirror of
https://github.com/rui314/mold.git
synced 2024-11-11 05:46:58 +03:00
Fix a build issue on macOS
This commit is contained in:
parent
e7537116b3
commit
4678fcee52
8
icf.cc
8
icf.cc
@ -55,7 +55,6 @@
|
||||
#include "mold.h"
|
||||
|
||||
#include <array>
|
||||
#include <openssl/sha.h>
|
||||
#include <tbb/concurrent_unordered_map.h>
|
||||
#include <tbb/concurrent_vector.h>
|
||||
#include <tbb/enumerable_thread_specific.h>
|
||||
@ -63,6 +62,13 @@
|
||||
#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 i64 HASH_SIZE = 16;
|
||||
|
||||
typedef std::array<u8, HASH_SIZE> Digest;
|
||||
|
@ -14,7 +14,13 @@ MemoryMappedFile<E>::open(Context<E> &ctx, std::string path) {
|
||||
struct stat st;
|
||||
if (stat(path.c_str(), &st) == -1)
|
||||
return nullptr;
|
||||
u64 mtime = (u64)st.st_mtim.tv_sec * 1000000000 + st.st_mtim.tv_nsec;
|
||||
|
||||
u64 mtime;
|
||||
#ifdef __APPLE__
|
||||
mtime = (u64)st.st_mtimespec.tv_sec * 1000000000 + st.st_mtimespec.tv_nsec;
|
||||
#else
|
||||
mtime = (u64)st.st_mtim.tv_sec * 1000000000 + st.st_mtim.tv_nsec;
|
||||
#endif
|
||||
|
||||
u8 *data = nullptr;
|
||||
if (st.st_size == 0) {
|
||||
|
@ -49,6 +49,21 @@ static bool is_ld(const char *path) {
|
||||
!strcmp(ptr, "ld.gold");
|
||||
}
|
||||
|
||||
int execvpe(const char *file, char *const *argv, char *const *envp) {
|
||||
debug_print("execvpe %s\n", file);
|
||||
|
||||
if (!strcmp(file, "ld") || is_ld(file)) {
|
||||
file = get_mold_path();
|
||||
((const char **)argv)[0] = file;
|
||||
}
|
||||
|
||||
for (int i = 0; envp[i]; i++)
|
||||
putenv(envp[i]);
|
||||
|
||||
typeof(execvpe) *real = dlsym(RTLD_NEXT, "execvp");
|
||||
return real(file, argv, environ);
|
||||
}
|
||||
|
||||
int execve(const char *path, char *const *argv, char *const *envp) {
|
||||
debug_print("execve %s\n", path);
|
||||
|
||||
@ -94,18 +109,6 @@ int execvp(const char *file, char *const *argv) {
|
||||
return execvpe(file, argv, environ);
|
||||
}
|
||||
|
||||
int execvpe(const char *file, char *const *argv, char *const *envp) {
|
||||
debug_print("execvpe %s\n", file);
|
||||
|
||||
if (!strcmp(file, "ld") || is_ld(file)) {
|
||||
file = get_mold_path();
|
||||
((const char **)argv)[0] = file;
|
||||
}
|
||||
|
||||
typeof(execvpe) *real = dlsym(RTLD_NEXT, "execvpe");
|
||||
return real(file, argv, environ);
|
||||
}
|
||||
|
||||
int posix_spawn(pid_t *pid, const char *path,
|
||||
const posix_spawn_file_actions_t *file_actions,
|
||||
const posix_spawnattr_t *attrp,
|
||||
|
@ -1,11 +1,18 @@
|
||||
#include "mold.h"
|
||||
|
||||
#include <openssl/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
|
||||
|
||||
template <typename E>
|
||||
void OutputChunk<E>::write_to(Context<E> &ctx, u8 *buf) {
|
||||
Fatal(ctx) << name << ": write_to is called on an invalid section";
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "mold.h"
|
||||
|
||||
#include <openssl/sha.h>
|
||||
#include <signal.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
@ -9,6 +8,13 @@
|
||||
#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
|
||||
|
||||
// Exiting from a program with large memory usage is slow --
|
||||
|
Loading…
Reference in New Issue
Block a user