Skip to content

Commit

Permalink
Merge pull request google#486 from devnexen/macos_posix_fix
Browse files Browse the repository at this point in the history
macOs build fix proposal when OS is set to posix.
  • Loading branch information
robertswiecki authored Apr 11, 2023
2 parents 2880d45 + 5a4ec4a commit 3f39135
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ GREP_COLOR ?=
BUILD_OSSFUZZ_STATIC ?= false # for https://github.com/google/oss-fuzz
BUILD_LINUX_NO_BFD ?= false # for users who don't want to use libbfd/binutils

REALOS = $(shell uname -s)
OS ?= $(shell uname -s)
MARCH ?= $(shell uname -m)
KERNEL ?= $(shell uname -r)
Expand Down Expand Up @@ -163,9 +164,11 @@ else
ARCH_CFLAGS += -D_POSIX_C_SOURCE=200809L -D__EXTENSIONS__=1
ARCH_LDFLAGS += -lkstat -lsocket -lnsl
endif
ifneq ($(OS),OpenBSD)
ifneq ($(REALOS),OpenBSD)
ifneq ($(REALOS),Darwin)
ARCH_LDFLAGS += -lrt
endif
endif
# OS Posix
endif

Expand All @@ -180,7 +183,7 @@ ifeq ($(COMPILER),clang)
ARCH_CFLAGS += -mllvm -inline-threshold=2000
CFLAGS_BLOCKS = -fblocks

ifneq ($(OS),Darwin)
ifneq ($(REALOS),Darwin)
ARCH_LDFLAGS += -Wl,-Bstatic -lBlocksRuntime -Wl,-Bdynamic
endif
endif
Expand Down
2 changes: 1 addition & 1 deletion hfuzz_cc/hfuzz-cc.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static bool hasCmdLineFSanitizeFuzzer = false;

/* Embed libhf/.a inside this binary */
__asm__("\n"
#ifndef _HF_ARCH_DARWIN
#if !defined(_HF_ARCH_DARWIN) && !defined(__APPLE__)
" .section .rodata\n"
#endif /* _HF_ARCH_DARWIN */
" .global lhfuzz_start\n"
Expand Down
4 changes: 2 additions & 2 deletions libhfcommon/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <fcntl.h>
#include <inttypes.h>
#include <sys/param.h>
#if !defined(_HF_ARCH_DARWIN) && !defined(__CYGWIN__)
#if !defined(_HF_ARCH_DARWIN) && !defined(__CYGWIN__) && !defined(__APPLE__)
#include <link.h>
#endif /* !defined(_HF_ARCH_DARWIN) && !defined(__CYGWIN__) */
#include <math.h>
Expand Down Expand Up @@ -951,7 +951,7 @@ const char* util_sigName(int signo) {
#define _HF_COMMON_BIN_COLLECT_VALS false
#endif /* !defined(_HF_COMMON_BIN_COLLECT_VALS) */

#if !defined(_HF_ARCH_DARWIN) && !defined(__CYGWIN__)
#if !defined(_HF_ARCH_DARWIN) && !defined(__CYGWIN__) && !defined(__APPLE__)
static int addrStatic_cb(struct dl_phdr_info* info, size_t size HF_ATTR_UNUSED, void* data) {
for (size_t i = 0; i < info->dlpi_phnum; i++) {
if (info->dlpi_phdr[i].p_type != PT_LOAD) {
Expand Down
2 changes: 1 addition & 1 deletion libhfuzz/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ __attribute__((constructor)) static void init(void) {
*/
static void fetchSanPoison(const uint8_t* buf, size_t len) {
/* MacOS X linker doesn't like those */
#if defined(_HF_ARCH_DARWIN)
#if defined(_HF_ARCH_DARWIN) || defined(__APPLE__)
return;
#endif /* defined(_HF_ARCH_DARWIN) */
__attribute__((weak)) extern void __asan_unpoison_memory_region(const void* addr, size_t sz);
Expand Down

0 comments on commit 3f39135

Please sign in to comment.