Skip to content

libcxx: std::ostream::sentry should be exported #140169

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

Closed
wants to merge 5 commits into from

Conversation

jeremyd2019
Copy link
Contributor

@jeremyd2019 jeremyd2019 commented May 16, 2025

Not for review. Testing another idea for #140145

@jeremyd2019 jeremyd2019 changed the title libcxx: see if clang-cl likes this. libcxx: std::ostream::sentry should be exported May 16, 2025
@jeremyd2019 jeremyd2019 force-pushed the libcxx-inner-class-export branch 3 times, most recently from 41904da to 56b71d9 Compare May 16, 2025 07:20
… template should be instantiated

In-code comment says "explicit instantiation decl of the outer class
doesn't affect the inner class" but this behavior seems MSVC
specific, MinGW-GCC and Cygwin-GCC does not.
Clang should honor gcc's behavior.

This change fixes std::string compatibilty and resolves strange link
error (statically linked), strange crash (dynamically linked) using
libstdc++ on Cygwin.
@jeremyd2019 jeremyd2019 reopened this May 16, 2025
@jeremyd2019 jeremyd2019 force-pushed the libcxx-inner-class-export branch from 56b71d9 to 73c338c Compare May 16, 2025 21:36
Copy link

github-actions bot commented May 16, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@mstorsjo
Copy link
Member

FYI, note that even if you include clang changes here, those won't be used by the libcxx CI build; the CI uses a prebuilt build of llvm-mingw - see .github/workflows/libcxx-build-and-test.yaml.

@jeremyd2019
Copy link
Contributor Author

jeremyd2019 commented May 16, 2025

I know, I just started with #140145 for my testing, this pr is really meant for testing that no other platform is broken. https://github.com/jeremyd2019/llvm-mingw/actions/runs/15075388808 is running the full test of af82a52

and now https://github.com/jeremyd2019/llvm-mingw/actions/runs/15078849158 for 04ef889 (since at least i686 already failed due to istream which was not done as a test to make sure the issue was reproducing)

@jeremyd2019 jeremyd2019 reopened this May 16, 2025
@jeremyd2019 jeremyd2019 reopened this May 16, 2025
@jeremyd2019 jeremyd2019 force-pushed the libcxx-inner-class-export branch 2 times, most recently from 233fc83 to 8ca8bdc Compare May 17, 2025 04:40
@jeremyd2019 jeremyd2019 reopened this May 17, 2025
@jeremyd2019 jeremyd2019 reopened this May 17, 2025
@jeremyd2019 jeremyd2019 deleted the libcxx-inner-class-export branch May 18, 2025 19:28
@jeremyd2019 jeremyd2019 restored the libcxx-inner-class-export branch May 19, 2025 22:59
@jeremyd2019 jeremyd2019 reopened this May 19, 2025
@jeremyd2019 jeremyd2019 force-pushed the libcxx-inner-class-export branch 4 times, most recently from 2dca920 to ce1573e Compare May 20, 2025 00:16
@jeremyd2019 jeremyd2019 force-pushed the libcxx-inner-class-export branch from ce1573e to 5035da0 Compare May 20, 2025 02:16
jeremyd2019 and others added 2 commits May 20, 2025 10:06
…bility with Mingw-GCC

In MinGW environment, Clang handles dllexport attribute of internal
class that defined in class template in different way from GCC.
This incompatibility should be fixed but breaks ABI of libc++, so
introduce a new keyword to keep ABI in MinGW environment with
old and patched Clang and to stay ABI compatible on other platforms.

This attribute is attached only for basic_ostream::sentry::sentry,
basic_ostream::sentry::~sentry and basic_istream::sentry::sentry.
Other entities won't be affected by patching Clang so doesn't need
to be annotate.

At a time to introduce a new class as a non-template inner type of
a class template, all non-inline member functions of that class
also needs to be attached _LIBCPP_HIDE_FROM_ABI_MINGW_OR_AFTER_V1
or _LIBCPP_HIDE_FROM_ABI, not _LIBCPP_HIDE_FROM_ABI_AFTER_V1.
Otherwise, that member functions contained in DLL will be
inaccessible on MinGW environment.

For time to increase ABI version, _LIBCPP_HIDE_FROM_ABI_MINGW_OR_AFTER_V1
can be simply replaced to _LIBCPP_HIDE_FROM_ABI_AFTER_V1.
@jeremyd2019 jeremyd2019 force-pushed the libcxx-inner-class-export branch from 5035da0 to 54221fd Compare May 20, 2025 17:22
Since it seems so hard to get to stages 2 and 3
@jeremyd2019 jeremyd2019 force-pushed the libcxx-inner-class-export branch from 5d1e523 to bffb58e Compare May 20, 2025 20:39
@jeremyd2019 jeremyd2019 deleted the libcxx-inner-class-export branch May 22, 2025 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants