[llvm] [CAS] Fix build for older macOS SDK (before 13.0) (PR #159133)

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 16 10:21:16 PDT 2025


https://github.com/cachemeifyoucan created https://github.com/llvm/llvm-project/pull/159133

Fix a build failure and back-deployment problem for macOS before 13.0.


>From 2d86fea1445ece5c297099575ffa46a0e67f244d Mon Sep 17 00:00:00 2001
From: Steven Wu <stevenwu at apple.com>
Date: Tue, 16 Sep 2025 10:21:05 -0700
Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?=
 =?UTF-8?q?l=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.6
---
 llvm/lib/CAS/OnDiskCommon.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/llvm/lib/CAS/OnDiskCommon.cpp b/llvm/lib/CAS/OnDiskCommon.cpp
index f7765c58944c5..25aa06bfe64da 100644
--- a/llvm/lib/CAS/OnDiskCommon.cpp
+++ b/llvm/lib/CAS/OnDiskCommon.cpp
@@ -105,7 +105,13 @@ Expected<size_t> cas::ondisk::preallocateFileTail(int FD, size_t CurrentSize,
   return NewSize;
 #elif defined(__APPLE__)
   fstore_t FAlloc;
-  FAlloc.fst_flags = F_ALLOCATEALL | F_ALLOCATEPERSIST;
+  FAlloc.fst_flags = F_ALLOCATEALL;
+#if defined(F_ALLOCATEPERSIST) &&                                              \
+    defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&                  \
+    __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 130000
+  // F_ALLOCATEPERSIST is introduced in macOS 13.
+  FAlloc.fst_flags |= F_ALLOCATEPERSIST;
+#endif
   FAlloc.fst_posmode = F_PEOFPOSMODE;
   FAlloc.fst_offset = 0;
   FAlloc.fst_length = NewSize - CurrentSize;



More information about the llvm-commits mailing list