Skip to content

[libc++] Add "using-if-exists" to timespec_get in modules #78686

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

Merged
merged 2 commits into from
Jan 22, 2024

Conversation

domin144
Copy link
Contributor

Picolibc does not provide timespec_get function. Adding "using-if-exists" attribute fixes the modules.

This is a follow up patch for #78580

@domin144 domin144 requested a review from a team as a code owner January 19, 2024 09:21
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jan 19, 2024
@llvmbot
Copy link
Member

llvmbot commented Jan 19, 2024

@llvm/pr-subscribers-libcxx

Author: Dominik Wójt (domin144)

Changes

Picolibc does not provide timespec_get function. Adding "using-if-exists" attribute fixes the modules.

This is a follow up patch for #78580


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

3 Files Affected:

  • (modified) libcxx/modules/std.compat/ctime.inc (+1-1)
  • (modified) libcxx/modules/std/ctime.inc (+1-1)
  • (modified) libcxx/test/std/modules/std.compat.pass.cpp (-4)
diff --git a/libcxx/modules/std.compat/ctime.inc b/libcxx/modules/std.compat/ctime.inc
index 92e3403a5e58e27..6e621f494348d74 100644
--- a/libcxx/modules/std.compat/ctime.inc
+++ b/libcxx/modules/std.compat/ctime.inc
@@ -24,5 +24,5 @@ export {
   using ::mktime;
   using ::strftime;
   using ::time;
-  using ::timespec_get;
+  using ::timespec_get _LIBCPP_USING_IF_EXISTS;
 } // export
diff --git a/libcxx/modules/std/ctime.inc b/libcxx/modules/std/ctime.inc
index c407ffc35e3fe3c..c98cb28e649b85e 100644
--- a/libcxx/modules/std/ctime.inc
+++ b/libcxx/modules/std/ctime.inc
@@ -24,5 +24,5 @@ export namespace std {
   using std::mktime;
   using std::strftime;
   using std::time;
-  using std::timespec_get;
+  using std::timespec_get _LIBCPP_USING_IF_EXISTS;
 } // namespace std
diff --git a/libcxx/test/std/modules/std.compat.pass.cpp b/libcxx/test/std/modules/std.compat.pass.cpp
index 9a2f330d722edde..a33ed3b6b64533a 100644
--- a/libcxx/test/std/modules/std.compat.pass.cpp
+++ b/libcxx/test/std/modules/std.compat.pass.cpp
@@ -11,10 +11,6 @@
 // UNSUPPORTED: libcpp-has-no-std-modules
 // UNSUPPORTED: clang-modules-build
 
-// picolibc does not provide the required timespec_get function, and the
-// "using-if-exists" mechanism apparently did not work here.
-// XFAIL: LIBCXX-PICOLIBC-FIXME
-
 // A minimal test to validate import works.
 
 import std.compat;

@domin144
Copy link
Contributor Author

After rebasing the patch I re-run the tests and realized the test is skipped now. Not sure why, and if this is intentional.
Still, I propose the patch as is, as this fixed the tests when they were run.

@domin144
Copy link
Contributor Author

domin144 commented Jan 19, 2024

Ok, I can see, that now the module tests have to be enabled with set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") in Armv7M-picolibc.cmake.
I tried it, but found, that a more recent version of cmake and ninja is required than those provided with ubuntu 22.04. With those updated, the tests pass.
I checked the logs of the buildkite run and I can see the picolibc tests are run with older versions of cmake and ninja. I am not enabling the module tests in Armv7M-picolibc.cmake for now.

@mordante mordante self-assigned this Jan 19, 2024
@mordante
Copy link
Member

Ok, I can see, that now the module tests have to be enabled with set(LIBCXX_ENABLE_STD_MODULES ON CACHE BOOL "") in Armv7M-picolibc.cmake. I tried it, but found, that a more recent version of cmake and ninja is required than those provided with ubuntu 22.04. With those updated, the tests pass. I checked the logs of the buildkite run and I can see the picolibc tests are run with older versions of cmake and ninja. I am not enabling the module tests in Armv7M-picolibc.cmake for now.

The patches to make modules work with older CMake versions have been reverted. I expect I can reland that patch soon. After that you can rebase this patch on main again and we can test it again.

@mordante
Copy link
Member

I've just relanded the dependencies for this patch. Could you rebase this patch to see whether the CI is green?

Picolibc does not provide timespec_get function. Adding
"using-if-exists" attribute fixes the modules.
@domin144 domin144 force-pushed the libcxx_unxfail_modules branch from e3e526d to 7443ba5 Compare January 22, 2024 08:15
@domin144
Copy link
Contributor Author

Thanks for an update. I rebased and I can see the picolibc tests passed.

Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

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

Thanks! Great to see Picolib working for modules! Since we're getting close the branching I'll directly merge the patch.

@mordante mordante merged commit a859df3 into llvm:main Jan 22, 2024
@domin144 domin144 deleted the libcxx_unxfail_modules branch January 29, 2024 08:35
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.

3 participants