This is an archive of the discontinued LLVM Phabricator instance.

[libc++] Work around dynamic linking of stringbuf::str() on Windows
ClosedPublic

Authored by pfusik on Jul 13 2023, 4:51 AM.

Details

Summary

https://github.com/llvm/llvm-project/issues/40363 caused the C++20
str() const & and str() && to be dllimport'ed despite _LIBCPP_HIDE_FROM_ABI.
This is a temporary solution until #40363 is fixed.

Diff Detail

Event Timeline

pfusik created this revision.Jul 13 2023, 4:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 4:51 AM
pfusik requested review of this revision.Jul 13 2023, 4:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2023, 4:51 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
hans added inline comments.Jul 13 2023, 5:15 AM
libcxx/include/sstream
413

Moving this one seems unrelated?

pfusik marked an inline comment as done.Jul 13 2023, 6:05 AM
pfusik added inline comments.
libcxx/include/sstream
413

It is related. This overload does not conflict with the pre-C++20 one, so it shouldn't depend on _LIBCPP_BUILDING_LIBRARY.

hans added inline comments.Jul 13 2023, 6:13 AM
libcxx/include/sstream
413

I mean it doesn't seem related to the problem we're working around with _LIBCPP_HIDE_FROM_ABI_SSTREAM, so perhaps it would be better to do it in a separate patch?

pfusik marked 2 inline comments as done.Jul 13 2023, 6:22 AM
pfusik added inline comments.
libcxx/include/sstream
413

It's the same problem: overload missing with _LIBCPP_BUILDING_LIBRARY, just a different solution.
I don't have a strong opinion on whether this should be one patch or two.

hans added inline comments.Jul 13 2023, 6:30 AM
libcxx/include/sstream
413

I think because it's a template, this one does not have the linking issues that the others do.

I also don't feel strongly about this change, just want to make sure I understand it.

pfusik marked 2 inline comments as done.Jul 13 2023, 6:39 AM
pfusik added inline comments.
libcxx/include/sstream
413

Oh, you are right!

hans accepted this revision.Jul 14 2023, 12:38 AM

I wasn't sure if you were planning to update the patch to not move the str(const _SAlloc& __sa) const template, but either way is fine by me really.

pfusik marked an inline comment as done.EditedJul 14 2023, 12:49 AM

I think it's better as-is.

Mordante added inline comments.
libcxx/include/sstream
286

This is our typical pattern.

286

Note this feels a bit of a hack, however since it's temporary I've no objection.

287

Please add a this link in the commit message too. We've changed bug trackers before so having an explicit link makes it easier to find in the future.

395

Why move this hunk?

pfusik marked 2 inline comments as done.Jul 14 2023, 9:29 AM
pfusik added inline comments.
libcxx/include/sstream
286

It was suggested by @ldionne in https://reviews.llvm.org/D153709 as a short-term solution.
BTW. can I link to inline comments in Differential?

395

It was an error to have this overload conditional on _LIBCPP_BUILDING_LIBRARY in the first place.
It shouldn't depend on _LIBCPP_BUILDING_LIBRARY because it doesn't conflict with the pre-C++20 str() const overload.
In this patch I change decorations of members under this condition, but this template method isn't problematic at all.

I put it here originally just to follow the order in the spec.

pfusik updated this revision to Diff 540460.Jul 14 2023, 9:42 AM
pfusik marked 4 inline comments as done.

Fix TODO pattern.
Add full issue link in the commit message.

pfusik added inline comments.Jul 14 2023, 9:44 AM
libcxx/include/sstream
287

Why don't I see the updated commit message here? I used arc diff.

pfusik updated this revision to Diff 540465.Jul 14 2023, 9:52 AM
pfusik retitled this revision from [libc++] Work around #40363 for stringbuf::str() to [libc++] Work around dynamic linking of stringbuf::str() on Windows.
pfusik edited the summary of this revision. (Show Details)

Update the commit message with arc diff --edit.

pfusik added inline comments.Jul 14 2023, 9:54 AM
libcxx/include/sstream
287
h-vetinari added inline comments.
libcxx/include/sstream
287

So clang>=17 doesn't have this bug anymore? I ask because https://github.com/llvm/llvm-project/issues/40363 is still open.

pfusik marked an inline comment as done.Jul 15 2023, 2:27 AM
pfusik added inline comments.
libcxx/include/sstream
287

The plan is to fix this bug before the clang 17 release.

Mordante accepted this revision as: Mordante.Jul 15 2023, 6:01 AM

Thanks LGTM. I leave the final approval to @ldionne.

libcxx/include/sstream
286

Not sure you can link to them, you can when clicking on the link in the generic overview.

I found Louis' suggestion without a hypen.

287

Nevermind, I found https://secure.phabricator.com/T2386 :)

Typically I just edit the commit message on Phab after I submitted a review. This will be applied to the patch when landing.

395

Thanks for the information.

ldionne accepted this revision.Jul 19 2023, 8:08 AM

LGTM. Note that this might be fixed by D155713 in Clang, but this patch is still needed in the meantime.

This revision is now accepted and ready to land.Jul 19 2023, 8:08 AM
This revision was automatically updated to reflect the committed changes.
pfusik marked an inline comment as done.