Skip to content
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

[libc++][C++23 std module] Error in <string> when compiling std module on windows #65027

Closed
Arthapz opened this issue Aug 27, 2023 · 3 comments
Closed
Labels
clang:modules C++20 modules and Clang Header Modules libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@Arthapz
Copy link

Arthapz commented Aug 27, 2023

Hello, here an other issue when we compile std module on windows

In module 'std' imported from src\mod.mpp:3:
C:\Dev\llvm\include\c++\v1\string:4319:21: error: no member named '__do_string_hash' in namespace 'std'
 4319 |         return std::__do_string_hash(__val.data(), __val.data() + __val.size());
      |  

here a self contained reproducer with full logs: https://github.com/Arthapz/libcpp-stdmodule-string-errors

> clang --version                                                                                                                                                                                                       
clang version 18.0.0 (https://github.com/llvm/llvm-project.git f6f6f1947da3fd088bd6f8b8d43a31d18ccd750f)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Dev\llvm\bin
@EugeneZelenko EugeneZelenko added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. clang:modules C++20 modules and Clang Header Modules and removed new issue labels Aug 27, 2023
@llvmbot
Copy link
Collaborator

llvmbot commented Aug 27, 2023

@llvm/issue-subscribers-clang-modules

@ChuanqiXu9
Copy link
Member

The root problems is that we don't handle modules well with -fdelayed-template-parsing.

ChuanqiXu9 added a commit to ChuanqiXu9/llvm-project that referenced this issue Oct 23, 2023
… default on windows after c++20

There are already 3 issues about the broken state of
-fdelayed-template-parsing and C++20 modules:
- llvm#61068
- llvm#64810
- llvm#65027

The problem is more complex than I thought. I am not sure how to fix it
properly now. Given the complexities and -fdelayed-template-parsing is
actually an extension to support old MS codes, I think it may make sense
to not enable the -fdelayed-template-parsing option by default with
C++20 modules to give more user friendly experience. Users who still want
-fdelayed-template-parsing can specify it explicitly.

Given the discussion in llvm#69551,
we decide to not enable -fdelayed-template-parsing by default on windows
after c++20
ChuanqiXu9 added a commit that referenced this issue Oct 23, 2023
… default on windows with C++20 (#69431)

There are already 3 issues about the broken state of
-fdelayed-template-parsing and C++20 modules:
- #61068
- #64810
- #65027

The problem is more complex than I thought. I am not sure how to fix it
properly now. Given the complexities and -fdelayed-template-parsing is
actually an extension to support old MS codes, I think it may make sense
to not enable the -fdelayed-template-parsing option by default with
C++20 modules to give more user friendly experience. Users who still
want -fdelayed-template-parsing can specify it explicitly.

Also according to https://learn.microsoft.com/en-us/cpp/build/reference/permissive-standards-conformance?view=msvc-170, MSVC actually defaults to -fno-delayed-template-parsing (/Zc:twoPhase-
with MSVC CLI) if using C++20. So we match the behavior with MSVC here to
not enable -fdelayed-template-parsing by default after C++20.
@ChuanqiXu9
Copy link
Member

Originally, I thought #69431 is simply a workaround. But according to the later discussions, I found it may be a proper solution since now we treat -fdelayed-template-parsing as a source of bugs. Then I think we can close the issue now. Feel free to reopen this if any one has different opinions.

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

No branches or pull requests

4 participants