Skip to content

[cxx-interop] Extract libstdc++ installation path from Clang #58962

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

Merged
merged 1 commit into from
May 19, 2022

Conversation

egorzhdan
Copy link
Contributor

To inject a modulemap into the libstdc++ directory, Swift needs to know the path of the libstdc++ installation. Previously it was assumed to be /usr/include/c++, however, this might not be the case. For example, on CentOS the stdlib is located at /opt/rh/devtoolset-{version}/root/usr/include/c++/{version}.

This change teaches Swift to extract the libstdc++ include paths from the Clang driver, and fixes C++ stdlib lookup on CentOS.

rdar://93341210

@egorzhdan egorzhdan added the c++ interop Feature: Interoperability with C++ label May 18, 2022
egorzhdan added a commit to swiftlang/llvm-project that referenced this pull request May 18, 2022
To inject a modulemap into the libstdc++ directory, Swift needs to know the path of the libstdc++ installation. Previously it was assumed to be `/usr/include/c++/{version}`, however, this might not be the case. For example, on CentOS the stdlib is located at `/opt/rh/devtoolset-{version}/root/usr/include/c++/{version}`.

This change teaches Swift to extract the libstdc++ include paths from the Clang driver, and fixes C++ stdlib lookup on CentOS.

rdar://93341210
@egorzhdan egorzhdan requested a review from zoecarver May 18, 2022 18:28
@egorzhdan egorzhdan force-pushed the egorzhdan/libstdcxx-path branch from e8d6a67 to abf56bc Compare May 18, 2022 18:39
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

@egorzhdan egorzhdan merged commit 93415f9 into main May 19, 2022
@egorzhdan egorzhdan deleted the egorzhdan/libstdcxx-path branch May 19, 2022 10:18
egorzhdan added a commit to swiftlang/llvm-project that referenced this pull request May 19, 2022
@finagolfin
Copy link
Member

I think this pull broke several tests on the Android CI, as many now report this new warning (13 of those 31 were already failing for unrelated reasons before).

This change will probably need to be modified for the Android NDK, which doesn't use a standard toolchain layout of usr/bin/clang and usr/include/c++/, which the clang Driver function you're calling here expects.

@egorzhdan
Copy link
Contributor Author

Hmm, since Android uses libc++, this logic shouldn't run. Submitted #59156.

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.

2 participants