summaryrefslogtreecommitdiffstats
path: root/libcxx/src/experimental/filesystem
diff options
context:
space:
mode:
authorNico Weber <nicolasweber@gmx.de>2018-02-06 19:17:41 +0000
committerNico Weber <nicolasweber@gmx.de>2018-02-06 19:17:41 +0000
commit6ef990e9ce9ab7d3a2b055e53ff83236d01f43fa (patch)
treeaccdfd255946dabfedd6e57f097c0c7c088c1deb /libcxx/src/experimental/filesystem
parenta894201313cddd1102189db97eb2673e726b67bf (diff)
downloadbcm5719-llvm-6ef990e9ce9ab7d3a2b055e53ff83236d01f43fa.tar.gz
bcm5719-llvm-6ef990e9ce9ab7d3a2b055e53ff83236d01f43fa.zip
Fix building libc++ with the macOS 10.13 SDK with -mmacosx-version-min=10.12 or lower.
The 10.13 SDK always defines utimensat() (with an availability(macosx=10.13) annotation) and unconditionally defines UTIME_OMIT, so use the compile-time availability macros on Apple platforms instead. For people statically linking libc++, it might make sense to also provide an opt-in option for using __builtin_available() to dynamically check for the OS version, but for now let's do the smallest thing needed to unbreak the build. Based on a patch by Eric Fiselier <eric@efcs.ca>: https://reviews.llvm.org/D34249 Fixes PR33469. llvm-svn: 324385
Diffstat (limited to 'libcxx/src/experimental/filesystem')
-rw-r--r--libcxx/src/experimental/filesystem/operations.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/libcxx/src/experimental/filesystem/operations.cpp b/libcxx/src/experimental/filesystem/operations.cpp
index 2bc28c21dcf..bd173893ca4 100644
--- a/libcxx/src/experimental/filesystem/operations.cpp
+++ b/libcxx/src/experimental/filesystem/operations.cpp
@@ -21,7 +21,34 @@
#include <sys/stat.h>
#include <sys/statvfs.h>
#include <fcntl.h> /* values for fchmodat */
-#if !defined(UTIME_OMIT)
+
+#if (__APPLE__)
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101300
+#define _LIBCXX_USE_UTIMENSAT
+#endif
+#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 110000
+#define _LIBCXX_USE_UTIMENSAT
+#endif
+#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 110000
+#define _LIBCXX_USE_UTIMENSAT
+#endif
+#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 40000
+#define _LIBCXX_USE_UTIMENSAT
+#endif
+#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
+#else
+// We can use the presence of UTIME_OMIT to detect platforms that provide
+// utimensat.
+#if defined(UTIME_OMIT)
+#define _LIBCXX_USE_UTIMENSAT
+#endif
+#endif // __APPLE__
+
+#if !defined(_LIBCXX_USE_UTIMENSAT)
#include <sys/time.h> // for ::utimes as used in __last_write_time
#endif
@@ -560,9 +587,7 @@ void __last_write_time(const path& p, file_time_type new_time,
using namespace std::chrono;
std::error_code m_ec;
- // We can use the presence of UTIME_OMIT to detect platforms that do not
- // provide utimensat.
-#if !defined(UTIME_OMIT)
+#if !defined(_LIBCXX_USE_UTIMENSAT)
// This implementation has a race condition between determining the
// last access time and attempting to set it to the same value using
// ::utimes
OpenPOWER on IntegriCloud