diff --git a/srcpkgs/ninja/template b/srcpkgs/ninja/template
index 546840b7cb9..42928314029 100644
--- a/srcpkgs/ninja/template
+++ b/srcpkgs/ninja/template
@@ -1,7 +1,7 @@
 # Template file for 'ninja'
 pkgname=ninja
 version=1.11.1
-revision=2
+revision=3
 hostmakedepends="python3 asciidoc"
 short_desc="Small build system with a focus on speed"
 maintainer="Duncaen <duncaen@voidlinux.org>"
@@ -10,6 +10,16 @@ homepage="https://ninja-build.org/"
 distfiles="https://github.com/ninja-build/ninja/archive/v${version}.tar.gz"
 checksum=31747ae633213f1eda3842686f83c2aa1412e0f5691d1c14dbbcc67fe7400cea
 
+if [ "$XBPS_WORDSIZE" = 32 ]; then
+	BUILD_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+	BUILD_CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+fi
+
+if [ "$XBPS_TARGET_WORDSIZE" = 32 ]; then
+	CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+	CXXFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64"
+fi
+
 do_configure() {
 	# Skip rebuild with bootstrapped ninja until build phase:
 	vsed -e "s|subprocess.check_call(rebuild_args)|pass|" -i configure.py