Skip to content

[libcxx] Fix compiling for macOS versions before 10.13 #126669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

BenjaminSchaaf
Copy link

utimensat was introduced in macOS 10.13. UTIME_OMIT is still defined even when targeting 10.9 from newer versions of macOS, so this can't be used as a signal for utimensat availability.

utimensat was introduced in macOS 10.13. UTIME_OMIT is still defined
even when targeting 10.9 from newer versions of macOS, so this can't be
used as a signal for utimensat availability.
@BenjaminSchaaf BenjaminSchaaf requested a review from a team as a code owner February 11, 2025 05:35
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Feb 11, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 11, 2025

@llvm/pr-subscribers-libcxx

Author: Benjamin Schaaf (BenjaminSchaaf)

Changes

utimensat was introduced in macOS 10.13. UTIME_OMIT is still defined even when targeting 10.9 from newer versions of macOS, so this can't be used as a signal for utimensat availability.


Full diff: https://github.com/llvm/llvm-project/pull/126669.diff

1 Files Affected:

  • (modified) libcxx/src/filesystem/time_utils.h (+7-1)
diff --git a/libcxx/src/filesystem/time_utils.h b/libcxx/src/filesystem/time_utils.h
index 89352e5bd6abbbb..e82738eb7036372 100644
--- a/libcxx/src/filesystem/time_utils.h
+++ b/libcxx/src/filesystem/time_utils.h
@@ -32,8 +32,14 @@
 #  include <sys/time.h> // for ::utimes as used in __last_write_time
 #endif
 
+// MacOS version 10.13 introduces utimensat
+#if defined(__APPLE__)
+#  if (defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&                                                       \
+       __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101300)
+#    define _LIBCPP_USE_UTIMENSAT
+#  endif
 // We can use the presence of UTIME_OMIT to detect platforms that provide utimensat.
-#if defined(UTIME_OMIT)
+#elif defined(UTIME_OMIT)
 #  define _LIBCPP_USE_UTIMENSAT
 #endif
 

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As documented on our support page, we officially support back to macOS 10.13, but we dropped support for older versions: https://libcxx.llvm.org/#platform-and-compiler-support

@BenjaminSchaaf
Copy link
Author

Does that mean patches won't be accepted for fixing older versions?

@philnik777
Copy link
Contributor

Does that mean patches won't be accepted for fixing older versions?

Yes. You can of course ask for older versions being supported, but that requires CI support and some reasoning why it's still required. We can't support old systems forever.

@ldionne
Copy link
Member

ldionne commented Feb 12, 2025

In the case of macOS versions older than 10.13, we don't support it because even recent Xcode versions have dropped support for back-deploying that far back.

@ldionne
Copy link
Member

ldionne commented Feb 12, 2025

Closing since that platform is intentionally not supported anymore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants