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

type trait builtins __remove_cv[ref] are used unconditionally #99464

Closed
AndreyG opened this issue Jul 18, 2024 · 14 comments
Closed

type trait builtins __remove_cv[ref] are used unconditionally #99464

AndreyG opened this issue Jul 18, 2024 · 14 comments
Labels
invalid Resolved as invalid, i.e. not a bug libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

Comments

@AndreyG
Copy link

AndreyG commented Jul 18, 2024

After the commit 5535716 by @philnik777 the usages of builtin type traits __remove_cv/__remove_cvref are not guarded by #if __has_builtin(__remove_cv[ref]):

using type _LIBCPP_NODEBUG = __remove_cv(_Tp);

using type _LIBCPP_NODEBUG = __remove_cvref(_Tp);

Note that even the remaining comment is wrong now #endif // __has_builtin(__remove_cv).
#endif // __has_builtin(__remove_cv)

Also note that all other type traits builtins are used only after the check, for instance __add_pointer here:
#if !defined(_LIBCPP_WORKAROUND_OBJCXX_COMPILER_INTRINSICS) && __has_builtin(__add_pointer)
.

@philnik777
Copy link
Contributor

What exactly is your point/question/bug report?

Also note that all other type traits builtins are used only after the check

That's simply not true. Lots of type traits don't have guards. Only builtin traits which aren't supported by all supported compilers have guards.

@philnik777 philnik777 added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. and removed new issue labels Jul 18, 2024
@AndreyG
Copy link
Author

AndreyG commented Jul 18, 2024

What exactly is your point/question/bug report?

I'd like to have usages of builtin type traits guarded. The motivation for this is the homegrown language engine which works pretty well with libc++ (and any C++ code in general) but doesn't support these type traits yet.

@philnik777
Copy link
Contributor

I'm not sure what exactly you're referring to, but we can't support arbitrary C++ parsers. From our side the patch simply removed dead code. You can ask for official support for your tool, but without pre-commit testing that most likely won't happen.

@philnik777 philnik777 closed this as not planned Won't fix, can't repro, duplicate, stale Jul 18, 2024
@philnik777 philnik777 added the invalid Resolved as invalid, i.e. not a bug label Jul 18, 2024
@AndreyG
Copy link
Author

AndreyG commented Jul 18, 2024

Sorry, but I don't understand what's the problem with providing the fallback for parsers that don't support the builtin, how it was before the commit 5535716. This is also how a lot of type traits are implemented right now:
add_lvalue_reference
add_rvalue_reference
add_pointer
decay
remove_all_extents
remove_const
remove_extent
remove_pointer
remove_reference
remove_volatile
After all, that's the whole point of having the ability to check __has_builtin(...), right?

@philnik777
Copy link
Contributor

There are also lots of traits which don't check the flag. We don't support any compilers where __has_builtin(__remove_cv) is false, so it's simply dead code. We don't need to check a condition which is always true. We can't keep every workaround forever, that's unmaintainable. The type traits you list all don't have corresponding builtins in GCC currently, so the #else implementation is checked and used with GCC.

@AndreyG
Copy link
Author

AndreyG commented Jul 18, 2024

We don't support any compilers where __has_builtin(__remove_cv) is false

It contradicts the very first statement phrase from the official documentation: "Libc++ aims to support common compilers that implement the C++11 Standard."

@philnik777
Copy link
Contributor

And the second sentence states "In order to strike a good balance between stability for users and maintenance cost, testing coverage and development velocity, libc++ drops support for older compilers as newer ones are released.". Don't cherry-pick your quotes.

@ldionne
Copy link
Member

ldionne commented Jul 18, 2024

We don't support any compilers where __has_builtin(__remove_cv) is false

It contradicts the very first statement phrase from the official documentation: "Libc++ aims to support common compilers that implement the C++11 Standard."

Most importantly, we do in fact support common compilers, but we don't support arbitrary ones. We support GCC, Clang and most Clang-based compilers (AppleClang, IBM's compiler, etc). But no, we don't support arbitrary compilers or arbitrarily old versions of the above compilers because that would not be viable maintenance-wise. We also don't aim to support arbitrary homegrown language engines.

I don't mean this in a hostile way -- it would be great for your tool to work with libc++, however we unfortunately can't start taking into account these kinds of niche requests for support because that would never end. Libc++ is used extremely widely and you'd be surprised what kind of stuff people want to do with it, and what kind of requests we get. In order for the project to stay relevant, it has to stay focused, and that often means saying no.

@Smertig
Copy link
Contributor

Smertig commented Jul 24, 2024

Hey there. For the context: I'm @AndreyG's colleague.

In order to strike a good balance between stability for users and maintenance cost, testing coverage and development velocity, libc++ drops support for older compilers as newer ones are released.

Thanks for pointing out; it makes total sense. I fully understand that supporting custom/old compilers doesn't fit in the libc++ development process (and there's no way to check compatibility with custom tools).

However, may I ask you for the temporary exclusion here and providing fallback implementation for 3-6 more months until tooling is fully ready for those changes? Specifically, I'm talking about language support in CLion IDE / ReSharper C++ / Rider (three JetBrains products).

We are ready with internal implementation, but delivering it to end users might take some time (you know, releasing processes). I'm asking because we already have reports from users who tried fresh libc++ in their projects (i.e. chromium) and got a lot of red code in their editor even with basic stuff:

image

This was indeed our fault that we didn't provide implementation of those type traits in time, but that approach worked fine recently: usually, type traits were guarded, and we had some time to adapt. Now we realize that we should not rely on guards anymore and will support new builtin traits as fast as possible.

I really hope that suggested changes won't affect the development process of libc++ too much. I'm ready to create corresponding PR, if needed.

Thanks!

@philnik777
Copy link
Contributor

@Smertig If you want to revert IMO we should have some sort of test coverage for your tools. That could be as simple as running the parser over all headers and making sure it works. I realize that that's a request which won't be fulfilled in a few days, so I'd be happy with a promise that you'll work with us to set something up. That gives us visibility into any problems your parser has with our code, and you get very early reports when anything breaks.

@ldionne
Copy link
Member

ldionne commented Jul 25, 2024

@philnik777 I would be fine with reverting that commit from release/19.x just to give folks more time as a one-off thing. The patch is small and if we only reverted it from release/19.x, it's as-if we didn't change anything from the maintenance point of view since we don't revert anything in main. WDYT?

@philnik777
Copy link
Contributor

@ldionne sure, we can do that. I'd be against reverting on trunk though. Given that chromium was mentioned it seemed to me like reverting trunk was also requested.

@ldionne
Copy link
Member

ldionne commented Jul 25, 2024

@nico Can you chime in?

FWIW I'd be against reverting on main as well, at least that's my first reaction.

@Smertig
Copy link
Contributor

Smertig commented Jul 26, 2024

If you want to revert IMO we should have some sort of test coverage for your tools

That's a good point. Unfortunately, I don't have a good solution that can be added to libc++'s CI right now, but I'll investigate possible options taking into account all the licensing factors.

As a first step, we'll try to run our tooling over main libc++ branch daily (on our side) and support all the breaking changes ASAP. I believe, this way we would be able to avoid red code for released libc++ version (but not for trunk, unfortunately).

I would be fine with reverting that commit from release/19.x just to give folks more time as a one-off thing. The patch is small and if we only reverted it from release/19.x, it's as-if we didn't change anything from the maintenance point of view since we don't revert anything in main.

It would be really nice, thank you! I also understand that reverting something from main doesn't sound like good idea (commit can be just lost), so I won't insist on doing that. However, this could potentially help a small number of our users who prefer trunk (i.e. chromium developers).

@ldionne ldionne added this to the LLVM 19.X Release milestone Jul 31, 2024
@ldionne ldionne reopened this Jul 31, 2024
@github-project-automation github-project-automation bot moved this to Needs Triage in LLVM Release Status Jul 31, 2024
ldionne added a commit to ldionne/llvm-project that referenced this issue Jul 31, 2024
…e_cvref (llvm#81386)"

This reverts commit 5535716.
This is only being reverted from the LLVM 19 branch as a
convenience to avoid breaking some IDEs which were not ready
for that change.

Fixes llvm#99464
@tru tru moved this from Needs Triage to Done in LLVM Release Status Aug 1, 2024
tru pushed a commit to ldionne/llvm-project that referenced this issue Aug 1, 2024
…e_cvref (llvm#81386)"

This reverts commit 5535716.
This is only being reverted from the LLVM 19 branch as a
convenience to avoid breaking some IDEs which were not ready
for that change.

Fixes llvm#99464
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
invalid Resolved as invalid, i.e. not a bug libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
Development

No branches or pull requests

4 participants