From 8e4c8096940c83c49c3ac07acc96b0133f65ec8e Mon Sep 17 00:00:00 2001 From: Damien George Date: Mon, 16 Dec 2024 11:56:03 +1100 Subject: [PATCH] unix,windows: Force _FILE_OFFSET_BITS=64 to fix 32-bit file ABI. On 64-bit systems this should have no effect. On 32-bit systems it will force 64-bit file sizes and fixes directory listing on certain 32-bit ports. This option should work on pretty much all 32-bit systems these days. Signed-off-by: Damien George --- ports/unix/Makefile | 4 ++++ ports/windows/Makefile | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/ports/unix/Makefile b/ports/unix/Makefile index f02e6c635..88fa1af04 100644 --- a/ports/unix/Makefile +++ b/ports/unix/Makefile @@ -48,6 +48,10 @@ CWARN = -Wall -Werror CWARN += -Wextra -Wno-unused-parameter -Wpointer-arith -Wdouble-promotion -Wfloat-conversion CFLAGS += $(INC) $(CWARN) -std=gnu99 -DUNIX $(COPT) -I$(VARIANT_DIR) $(CFLAGS_EXTRA) +# Force the use of 64-bits for file sizes in C library functions on 32-bit platforms. +# This option has no effect on 64-bit builds. +CFLAGS += -D_FILE_OFFSET_BITS=64 + # Debugging/Optimization ifdef DEBUG COPT ?= -Og diff --git a/ports/windows/Makefile b/ports/windows/Makefile index cf0a92701..115d1a61e 100644 --- a/ports/windows/Makefile +++ b/ports/windows/Makefile @@ -42,6 +42,10 @@ INC += -I$(VARIANT_DIR) CFLAGS += $(INC) -Wall -Wpointer-arith -Wdouble-promotion -Werror -std=gnu99 -DUNIX -D__USE_MINGW_ANSI_STDIO=1 $(COPT) $(CFLAGS_EXTRA) LDFLAGS += -lm -lbcrypt $(LDFLAGS_EXTRA) +# Force the use of 64-bits for file sizes in C library functions on 32-bit platforms. +# This option has no effect on 64-bit builds. +CFLAGS += -D_FILE_OFFSET_BITS=64 + # Debugging/Optimization ifdef DEBUG CFLAGS += -g