Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ BOLTVERSION := $(DEFAULT_BOLTVERSION)

-include config.vars

# Use Homebrew LLVM toolchain for fuzzing support on macOS
ifeq ($(OS),Darwin)
export PATH := /opt/homebrew/opt/llvm/bin:$(PATH)
export DYLD_LIBRARY_PATH := /opt/homebrew/opt/llvm/lib:$(DYLD_LIBRARY_PATH)
# Disable -Werror on macOS because Homebrew LLVM is stricter than system clang
# and catches pre-existing bugs (like uninitialized variables) that cause build failures
CWARNFLAGS := $(subst -Werror,,$(CWARNFLAGS))
endif

# Define EXTERNAL_LDLIBS for linking external libraries
EXTERNAL_LDLIBS=$(SODIUM_LDLIBS) $(SQLITE3_LDLIBS) $(POSTGRES_LDLIBS)

SORT=LC_ALL=C sort


Expand Down Expand Up @@ -698,11 +710,15 @@ endif

# We special case the fuzzing target binaries, as they need to link against libfuzzer,
# which brings its own main().
ifeq ($(OS),Darwin)
FUZZ_LDFLAGS = /opt/homebrew/Cellar/llvm/21.1.2/lib/clang/21/lib/darwin/libclang_rt.fuzzer_osx.a -L/opt/homebrew/opt/llvm/lib/c++ -lc++ -L/opt/homebrew/opt/openssl@3/lib -lcrypto -lssl
$(ALL_FUZZ_TARGETS):
@$(call VERBOSE, "ld $@", $(CXX) $(filter-out %.a,$^) $(LOADLIBES) $(EXTERNAL_LDLIBS) $(LDLIBS) libccan.a $(FUZZ_LDFLAGS) -o $@)
@$(call VERBOSE, "dsymutil $@", dsymutil $@)
else
FUZZ_LDFLAGS = -fsanitize=fuzzer
$(ALL_FUZZ_TARGETS):
@$(call VERBOSE, "ld $@", $(LINK.o) $(filter-out %.a,$^) $(LOADLIBES) $(EXTERNAL_LDLIBS) $(LDLIBS) libccan.a $(FUZZ_LDFLAGS) -o $@)
ifeq ($(OS),Darwin)
@$(call VERBOSE, "dsymutil $@", dsymutil $@)
endif


Expand Down
5 changes: 5 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ set_defaults()
if [ "$(uname -s)" = "Darwin" ]; then
# Always override to avoid DWARF 5
CDEBUGFLAGS="-std=gnu11 -g -gdwarf-4 -fno-standalone-debug -fstack-protector-strong"
# Set SDKROOT for macOS
SDKROOT="$(xcrun --sdk macosx --show-sdk-path)"

# Optional: confirm dsymutil is available
if ! command -v dsymutil >/dev/null 2>&1; then
Expand Down Expand Up @@ -531,6 +533,9 @@ add_var CONFIGURATOR_CC "$CONFIGURATOR_CC"
add_var CWARNFLAGS "$CWARNFLAGS"
add_var CDEBUGFLAGS "$CDEBUGFLAGS"
add_var COPTFLAGS "$COPTFLAGS"
if [ -n "${SDKROOT:-}" ]; then
add_var SDKROOT "$SDKROOT"
fi
add_var CSANFLAGS "$CSANFLAGS"
add_var FUZZFLAGS "$FUZZFLAGS"
add_var SQLITE3_CFLAGS "$SQLITE3_CFLAGS"
Expand Down
7 changes: 6 additions & 1 deletion tests/fuzz/check-fuzz.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
# Runs each fuzz target on its seed corpus and prints any failures.
FUZZ_DIR=$(dirname "$0")
readonly FUZZ_DIR
TARGETS=$(find "${FUZZ_DIR}" -type f -name "fuzz-*" ! -name "*.*")
# On macOS, exclude debug symbol files from fuzzer target discovery
if [[ "$OSTYPE" == "darwin"* ]]; then
TARGETS=$(find "${FUZZ_DIR}" -type f -name "fuzz-*" ! -name "*.*" ! -path "*.dSYM/*")
else
TARGETS=$(find "${FUZZ_DIR}" -type f -name "fuzz-*" ! -name "*.*")
fi
readonly TARGETS

export UBSAN_OPTIONS="halt_on_error=1:print_stacktrace=1"
Expand Down
Loading