Skip to content

--std=c++20 -fno-modules still sets __has_feature(modules) to 1 #57432

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

Open
pkasting opened this issue Aug 29, 2022 · 11 comments
Open

--std=c++20 -fno-modules still sets __has_feature(modules) to 1 #57432

pkasting opened this issue Aug 29, 2022 · 11 comments
Labels
c++20 clang:modules C++20 modules and Clang Header Modules

Comments

@pkasting
Copy link
Member

pkasting commented Aug 29, 2022

The following code should compile without error with --std=c++20 -fno-modules:

#if __has_feature(modules)
#error Module support found!
#endif

Actual result: error message.

@EugeneZelenko EugeneZelenko added clang:frontend Language frontend issues, e.g. anything involving "Sema" and removed new issue labels Aug 29, 2022
@llvmbot
Copy link
Member

llvmbot commented Aug 29, 2022

@llvm/issue-subscribers-clang-frontend

@ChuanqiXu9
Copy link
Member

The -fmodules and -fno-modules are prepared for clang modules extension instead of the standard c++ modules. This is documented in the preparing document: https://reviews.llvm.org/D131388

@ChuanqiXu9
Copy link
Member

And it looks true currently we lack the ability to disable the standard c++ modules. May I ask the intention?

@ChuanqiXu9 ChuanqiXu9 added c++20 clang:modules C++20 modules and Clang Header Modules and removed clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Aug 30, 2022
@llvmbot
Copy link
Member

llvmbot commented Aug 30, 2022

@llvm/issue-subscribers-c-20

@llvmbot
Copy link
Member

llvmbot commented Aug 30, 2022

@llvm/issue-subscribers-clang-modules

@sdefresne
Copy link

This is in the context of mixing Objective-C++ and Swift.

The Swift compiler generates code that looks like this:

#if __has_feature(modules)
@import Foundation;
#endif

We are currently building a code base that is C++17 and uses some Swift and Objective-C++ code. Our code base does not yet support building with clang modules support enabled. When trying to build with -std=c++20, this @import line is reached and causes compilation failure (since we do not pass -fmodules and passing it is not enough).

@ChuanqiXu9
Copy link
Member

Oh, I understood it roughly. Currently both -std=c++20 and -fmodules will enable modules feature too. And it looks like we need to rename them or find a way to disable the cplusplusmodules specially.

@zmodem
Copy link
Collaborator

zmodem commented Sep 5, 2022

It looks like https://reviews.llvm.org/D106864 addressed the command-line flag problem?

@ChuanqiXu9
Copy link
Member

Yeah, it looks true. Although it requires -Xclang -fno-cxx-modules. @pkasting could you give a try?

@rnk
Copy link
Collaborator

rnk commented Sep 6, 2022

In the long run, we would like to avoid using Xclang flags in the Chromium build. Is there a plan to make this a driver flag?

@ChuanqiXu9
Copy link
Member

Yeah, there is an issue tracking this: #55891. Although we don't have any concrete proposal yet...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++20 clang:modules C++20 modules and Clang Header Modules
Projects
Status: No status
Development

No branches or pull requests

7 participants