Skip to content

Commit 03f2b2f

Browse files
vlaskywardviaene
andcommitted
Fix Linux linking by moving -lm to LDLIBS
Move the -lm flag from CFLAGS to a new LDLIBS variable and place it at the end of the linker command. This ensures libm is properly linked on Linux systems. The linker processes arguments left-to-right, so library flags must come after source files that reference their symbols. Previously, -lm appeared before the source file, causing "undefined symbol: sqrtf" errors on some Linux distributions. Cherry-picked from upstream PR asg017#252 Co-Authored-By: wardviaene <[email protected]>
1 parent 042d093 commit 03f2b2f

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Makefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ endif
3131

3232
ifdef CONFIG_LINUX
3333
LOADABLE_EXTENSION=so
34-
CFLAGS += -lm
34+
LDLIBS += -lm
3535
endif
3636

3737
ifdef CONFIG_WINDOWS
@@ -102,7 +102,8 @@ $(TARGET_LOADABLE): sqlite-vec.c sqlite-vec.h $(prefix)
102102
-Ivendor/ \
103103
-O3 \
104104
$(CFLAGS) \
105-
$< -o $@
105+
$< -o $@ \
106+
$(LDLIBS)
106107

107108
$(TARGET_STATIC): sqlite-vec.c sqlite-vec.h $(prefix) $(OBJS_DIR)
108109
$(CC) -Ivendor/ $(CFLAGS) -DSQLITE_CORE -DSQLITE_VEC_STATIC \

0 commit comments

Comments
 (0)