Skip to contentSkip to conversation

kbuild: Enable Large File Support for hostprogs

RFC PATCH In review Ben Hutchings 2 participants 2 messages May 11, 2015 – Jun 29, 2017 Kbuild

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 kbuild: Enable Large File Support for hostprogs

Some programs built on a 32-bit host need Large File Support (LFS). Regardless of whether any of them need to deal with large files, non-LFS *stat() functions don't work at all on an XFS volume with 64-bit inodes.

References: https://bugs.debian.org/778942

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +1 -1
index fbd43bf..a6fb432 100644
@@ -297,7 +297,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 
 HOSTCC       = gcc
 HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 HOSTCXXFLAGS = -O2
 
 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)
Signature · 2 lines
Ben Hutchings
For every action, there is an equal and opposite criticism. - Harrison
#1 lore raw

Hello Ben,

Quoted 16 lines · Ben Hutchings

Some programs built on a 32-bit host need Large File Support (LFS). Regardless of whether any of them need to deal with large files, non-LFS *stat() functions don't work at all on an XFS volume with 64-bit inodes.

References: https://bugs.debian.org/778942

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Makefile +0 -0
index fbd43bf..a6fb432 100644

Makefile CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \ · line 301

Quoted 6 lines
Makefile +1 -1
@@ -297,7 +297,7 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 
 HOSTCC       = gcc
 HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
 HOSTCXXFLAGS = -O2

I think we need the same for HOSTCXXFLAGS?

Also I wonder if this would be a better approach:

Makefile +8 -2
index e40c471abe29..d9dd5db0abce 100644
@@ -301,9 +301,15 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
 	  else if [ -x /bin/bash ]; then echo /bin/bash; \
 	  else echo sh; fi ; fi)
 
+HOST_LFS_CFLAGS := $(getconf LFS_CFLAGS)
+HOST_LFS_LDFLAGS := $(getconf LFS_LDFLAGS)
+HOST_LFS_LIBS := $(getconf LFS_LIBS)
+
 HOSTCC       = gcc
 HOSTCXX      = g++
-HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89
+HOSTCFLAGS   = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 $(HOST_LFS_CFLAGS)
+HOSTLDFLAGS  = $(HOST_LFS_LDFLAGS)
+HOSTLOADLIBES = $(HOST_LFS_LIBS)
-HOSTCXXFLAGS = -O2
+HOSTCXXFLAGS = -O2 $(HOST_LFS_CFLAGS)
 
 ifeq ($(shell $(HOSTCC) -v 2>&1 | grep -c "clang version"), 1)

HOSTCFLAGS += -Wno-unused-value -Wno-unused-parameter \

but note, that HOSTLDFLAGS and HOSTLOADLIBES doesn't seem to be picked up.

Best regards
Uwe