Skip to content

Commit 7cd296a

Browse files
fix: Windows library name and macOS bindgen sysroot
Two fixes for cross-compilation: 1. Windows (mingw): Changed library name from grovedb_ffi.lib to libgrovedb_ffi.a. The GNU toolchain produces .a files, not .lib (which is MSVC style). 2. macOS: Added BINDGEN_EXTRA_CLANG_ARGS to pass --target and CFLAGS to bindgen. This ensures bindgen uses the correct sysroot for cross-compilation instead of Linux system headers. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 5fdfa29 commit 7cd296a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/Makefile.grovedb.include

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ GROVEDB_LDFLAGS = -framework Security -framework CoreFoundation -lpthread -licon
3434
endif
3535

3636
if TARGET_WINDOWS
37-
GROVEDB_LIB = $(GROVEDB_TARGET_DIR)/grovedb_ffi.lib
37+
# Note: Using GNU toolchain (mingw), so library is libXXX.a, not XXX.lib (MSVC style)
38+
GROVEDB_LIB = $(GROVEDB_TARGET_DIR)/libgrovedb_ffi.a
3839
GROVEDB_LDFLAGS = -lbcrypt -lntdll -lws2_32 -luserenv -lcrypt32
3940
endif
4041

@@ -53,7 +54,12 @@ if HAVE_RUST_TARGET
5354
# We use awk to extract the actual compiler: if first word contains "ccache", use second word.
5455
GROVEDB_CARGO_CONFIG_SETUP = mkdir -p $(GROVEDB_DIST_DIR)/.cargo && linker=$$(echo "$(CC)" | awk '{if ($$1 ~ /ccache/) print $$2; else print $$1}') && printf '[target.%s]\nlinker = "%s"\n' "$(RUST_TARGET)" "$$linker" > $(GROVEDB_DIST_DIR)/.cargo/config.toml
5556

57+
# Base environment for cc crate
5658
GROVEDB_CARGO_ENV = CC_$(RUST_TARGET_UNDERSCORED)="$(CC)" CXX_$(RUST_TARGET_UNDERSCORED)="$(CXX)" AR_$(RUST_TARGET_UNDERSCORED)="$(AR)" CFLAGS_$(RUST_TARGET_UNDERSCORED)="$(CFLAGS)" CXXFLAGS_$(RUST_TARGET_UNDERSCORED)="$(CXXFLAGS)"
59+
60+
# Bindgen needs extra clang args for cross-compilation (esp. for macOS sysroot)
61+
# Pass target and any sysroot/include flags from CFLAGS to bindgen
62+
GROVEDB_CARGO_ENV += BINDGEN_EXTRA_CLANG_ARGS_$(RUST_TARGET_UNDERSCORED)="--target=$(RUST_TARGET) $(CFLAGS)"
5763
else
5864
GROVEDB_CARGO_CONFIG_SETUP = true
5965
GROVEDB_CARGO_ENV =

0 commit comments

Comments
 (0)