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

[cxx-interop] Disable c++ execution header with libstdcxx versions >= 11 #75662

Merged

Conversation

ADKaster
Copy link
Contributor

@ADKaster ADKaster commented Aug 2, 2024

Workaround for #75661

@ADKaster
Copy link
Contributor Author

ADKaster commented Aug 2, 2024

Ideally this change could make it into release/6.x, but that's assuming the maintainers think it's a worthwhile workaround before someone looks into how to get libstdc++ 11+ and tbb to behave in the module-map realm.

@furby-tm
Copy link
Contributor

furby-tm commented Aug 5, 2024

Hey!

Happy to see this looks to be in the process of getting fixed, I recently ran into this issue myself here, and I posted on the forums about it here.

+1 for anything that can make it into the Swift 6 release, great work!

@@ -1,7 +1,9 @@
#include "version"
Copy link
Contributor

@furby-tm furby-tm Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ADKaster if possible, (if this is a header visible on Microsoft Windows) I believe this include will break on that platform, since the vcruntime.modulemap marks that version header as C++20 language standard REQUIRED. And setting the C++ Language Standard anything past C++17 is an unreasonable expectation at the time of writing for many existing C++ libraries.

With an error that looks something like the following, I posted about it on the forums here:

// SomeApp.swift
import SomeCXXTarget
       ^~~~~~~~~~~~~
vcruntime.modulemap:696:10: error: module 'std.version' requires feature 'cplusplus20'

Perhaps this whole file can be guarded via #if !defined(_WIN32), if this header is even visible on windows in the first place.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't realize the libstdc++ overlay might be built on all platforms. I suppose features.h with a __has_include should be good enough to get the libstdc++ version check I'm trying to use.

Fwiw, when I was testing some swift things on Linux with 5.x last year when I first saw this, downgrading to libstdc++-10-dev did "workaround" this issue assuming you don't need STL features from 11+.

Copy link
Contributor

@furby-tm furby-tm Aug 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, I didn't realize the libstdc++ overlay might be built on all platforms. I suppose features.h with a __has_include should be good enough to get the libstdc++ version check I'm trying to use.

That should work out nicely, though I'm not entirely sure if its relevant or not (consider this Windows <version> header PTSD 😅), just trying to limit this issue from propping up over on Windows if it can be helped (I've yet to explore the relationship between much of the Swift source code and the respective platforms in which they are built on).

Fwiw, when I was testing some swift things on Linux with 5.x last year when I first saw this, downgrading to libstdc++-10-dev did "workaround" this issue assuming you don't need STL features from 11+.

Good to note! Thank you for your findings.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This header isn't used on Windows. We currently only support the platform-default C++ stdlib on each platform (there is an effort to change that in #75589). On Windows that would be the Microsoft STL.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks @egorzhdan for the clarification!

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label Aug 5, 2024
@egorzhdan
Copy link
Contributor

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor

@swift-ci please build toolchain UBI9

@egorzhdan
Copy link
Contributor

@swift-ci please build toolchain CentOS 7

@egorzhdan
Copy link
Contributor

Looks like this is failing on CentOS 7:

/home/build-user/build/buildbot_linux/swift-linux-x86_64/lib/swift/linux/libstdcxx.h:1:10: error: 'version' file not found
 1 | #include "version"
   |          `- error: 'version' file not found

@ADKaster
Copy link
Contributor Author

ADKaster commented Aug 5, 2024

Looks like this is failing on CentOS 7

Lovely. I pushed a fix that should not trip up on that version, or a libstdc++ version before _GLIBCXX_RELEASE started being defined. I'm not sure if there's any overlap between "execution header exists" and "_GLIBCXX_RELEASE not defined", but i'd rather not find out in a CI run or bug report.

@egorzhdan
Copy link
Contributor

@swift-ci please smoke test

@egorzhdan
Copy link
Contributor

@swift-ci please build toolchain CentOS 7

@egorzhdan
Copy link
Contributor

@swift-ci please build toolchain UBI9

@ADKaster
Copy link
Contributor Author

ADKaster commented Aug 9, 2024

It looks like the CI error here is due to some compiler flags issues, rather than my change

Copy link
Contributor

@egorzhdan egorzhdan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@egorzhdan egorzhdan merged commit 915b531 into swiftlang:main Aug 14, 2024
4 of 5 checks passed
@ADKaster ADKaster deleted the disable-tbb-execution-on-newer-libstdcxx branch August 17, 2024 01:33
@furby-tm
Copy link
Contributor

Great work! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ interop Feature: Interoperability with C++
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants