From 644c8be78af1eae7c138fa4093fb87f0f4f8db85 Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Mon, 12 Feb 2024 13:58:37 -0800 Subject: [PATCH] Removing API usage not applicable on iOS (stat and fstat) in libhermes Summary: This diff just removes references to functions that use (either directly or transitively) those functions, and relies on linker DCE to clean up the rest. Trying to extricate all uses of these functions would otherwise result in very significant changes. This diff makes two changes: 1. In raw_fd_ostream, fall back to a default buffer size when building for iOS. 2. Update a function in LLVM that was marked as "used" to suppress warnings, to instead use the new `[[maybe_unused]]` attribute. This allows the function, and the calls to stat it retains, to be stripped. Reviewed By: tmikov, TheSavior Differential Revision: D53133166 fbshipit-source-id: f425762bc6b7072cbd8235c65e9cf652cecb981c --- external/llvh/lib/Support/Signals.cpp | 2 +- external/llvh/lib/Support/raw_ostream.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/llvh/lib/Support/Signals.cpp b/external/llvh/lib/Support/Signals.cpp index 0e1a32ca006..afe5470f1aa 100644 --- a/external/llvh/lib/Support/Signals.cpp +++ b/external/llvh/lib/Support/Signals.cpp @@ -103,7 +103,7 @@ static FormattedNumber format_ptr(void *PC) { } /// Helper that launches llvm-symbolizer and symbolizes a backtrace. -LLVM_ATTRIBUTE_USED +[[maybe_unused]] static bool printSymbolizedStackTrace(StringRef Argv0, void **StackTrace, int Depth, llvh::raw_ostream &OS) { if (DisableSymbolicationFlag) diff --git a/external/llvh/lib/Support/raw_ostream.cpp b/external/llvh/lib/Support/raw_ostream.cpp index 1406fd97ad9..509150ed82b 100644 --- a/external/llvh/lib/Support/raw_ostream.cpp +++ b/external/llvh/lib/Support/raw_ostream.cpp @@ -764,7 +764,7 @@ size_t raw_fd_ostream::preferred_buffer_size() const { if (IsWindowsConsole) return 0; return raw_ostream::preferred_buffer_size(); -#elif !defined(__minix) +#elif !defined(__minix) && !(defined(__APPLE__) && defined(HERMES_IS_MOBILE_BUILD)) // Minix has no st_blksize. assert(FD >= 0 && "File not yet open!"); struct stat statbuf;