11# sqlite-diskann Makefile
22# Cross-platform SQLite extension for DiskANN vector search
33
4- .PHONY : all clean test test-native test-all check asan valgrind bear lint clang-tidy fmt help
4+ .PHONY : all clean test test-native test-all test-stress check asan valgrind bear lint clang-tidy fmt help
55
66# Compiler and flags
77CC ?= gcc
@@ -22,10 +22,11 @@ BUILD_DIR = build
2222# Output
2323EXTENSION = diskann.so
2424TEST_BIN = test_diskann
25+ STRESS_BIN = test_stress
2526
2627# Source files
2728SOURCES = $(SRC_DIR ) /diskann_api.c $(SRC_DIR ) /diskann_blob.c $(SRC_DIR ) /diskann_insert.c $(SRC_DIR ) /diskann_node.c $(SRC_DIR ) /diskann_search.c
28- TEST_C_SOURCES = $(filter-out % /test_runner.c, $(wildcard $(TEST_DIR ) /c/test_* .c) )
29+ TEST_C_SOURCES = $(filter-out % /test_runner.c % /test_stress.c , $(wildcard $(TEST_DIR ) /c/test_* .c) )
2930TEST_RUNNER = $(TEST_DIR ) /c/test_runner.c
3031UNITY_SOURCES = $(TEST_DIR ) /c/unity/unity.c
3132SQLITE_SOURCE = vendor/sqlite/sqlite3.c
@@ -34,10 +35,14 @@ SQLITE_SOURCE = vendor/sqlite/sqlite3.c
3435UNAME_S := $(shell uname -s)
3536ifeq ($(UNAME_S ) ,Darwin)
3637 EXTENSION = diskann.dylib
38+ # Allow undefined symbols (resolved at runtime when loaded into SQLite)
3739 LDFLAGS += -dynamiclib -undefined dynamic_lookup
3840endif
3941ifeq ($(UNAME_S ) ,Linux)
4042 EXTENSION = diskann.so
43+ # Allow undefined symbols (resolved at runtime when loaded into SQLite)
44+ # Equivalent to macOS's -undefined dynamic_lookup
45+ LDFLAGS += -Wl,--allow-shlib-undefined
4146endif
4247
4348# Default target
@@ -70,6 +75,17 @@ test-all: test-native
7075 @command -v npm > /dev/null 2>&1 || { echo " Error: npm not installed" >&2 ; exit 1; }
7176 npm run test:ts
7277
78+ # Build and run stress tests (separate from regular tests due to long runtime)
79+ test-stress : $(BUILD_DIR ) /$(STRESS_BIN )
80+ @echo " Running stress tests (this may take several minutes)..."
81+ $(BUILD_DIR ) /$(STRESS_BIN )
82+ @echo " Cleaning up stress test database files..."
83+ @rm -f /tmp/diskann_stress_* .db*
84+
85+ $(BUILD_DIR ) /$(STRESS_BIN ) : $(SOURCES ) $(TEST_DIR ) /c/test_stress.c $(UNITY_SOURCES ) $(BUILD_DIR ) /sqlite3.o | $(BUILD_DIR )
86+ $(CC ) $(CFLAGS ) $(EXTRA_CFLAGS ) -I$(SRC_DIR ) -I$(TEST_DIR ) /c -o $@ $^ $(LIBS )
87+ @echo " Built stress test suite: $@ "
88+
7389$(BUILD_DIR ) /$(TEST_BIN ) : $(SOURCES ) $(TEST_C_SOURCES ) $(TEST_RUNNER ) $(UNITY_SOURCES ) $(BUILD_DIR ) /sqlite3.o | $(BUILD_DIR )
7490 $(CC ) $(CFLAGS ) $(EXTRA_CFLAGS ) -I$(SRC_DIR ) -I$(TEST_DIR ) /c -o $@ $^ $(LIBS )
7591 @echo " Built test suite: $@ "
@@ -125,6 +141,7 @@ help:
125141 @echo " test Build and run native C tests (alias for test-native)"
126142 @echo " test-native Build and run native C tests only"
127143 @echo " test-all Build and run both native C and TypeScript tests"
144+ @echo " test-stress Build and run stress tests (300k/100k vectors, takes ~5-10min)"
128145 @echo " check Alias for test"
129146 @echo " asan Build and run with AddressSanitizer (fast memory checks)"
130147 @echo " valgrind Build and run with Valgrind (thorough memory checks)"
0 commit comments