Skip to content

[libc++] change the visibility of libc++ header to public in libcxx module #91240

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
Jun 25, 2024

Conversation

RichardLuo0
Copy link
Contributor

@RichardLuo0 RichardLuo0 commented May 6, 2024

This PR addresses a problem that headers may not be able to be found if #include is used with std modules.

Consider the following file:

#include <boost/json.hpp>
import std;

int main(int, const char **) { }

boost will include something from libc++, but we are using -nostdinc++, so the compiler can not find any default std header.
Therefore the locally built header needs to be public.

@RichardLuo0 RichardLuo0 requested a review from a team as a code owner May 6, 2024 17:07
Copy link

github-actions bot commented May 6, 2024

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label May 6, 2024
@llvmbot
Copy link
Member

llvmbot commented May 6, 2024

@llvm/pr-subscribers-libcxx

Author: RichardLuo (RichardLuo0)

Changes

Same as #91182


Full diff: https://github.com/llvm/llvm-project/pull/91240.diff

1 Files Affected:

  • (modified) libcxx/modules/CMakeLists.txt.in (+1-1)
diff --git a/libcxx/modules/CMakeLists.txt.in b/libcxx/modules/CMakeLists.txt.in
index c35f6fecb1fd76..9fef16e9cefde9 100644
--- a/libcxx/modules/CMakeLists.txt.in
+++ b/libcxx/modules/CMakeLists.txt.in
@@ -41,7 +41,7 @@ target_sources(std
     std.cppm
 )
 
-target_include_directories(std SYSTEM PRIVATE @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
+target_include_directories(std SYSTEM PUBLIC @LIBCXX_CONFIGURED_INCLUDE_DIRS@)
 
 if (NOT @LIBCXX_ENABLE_EXCEPTIONS@)
   target_compile_options(std PUBLIC -fno-exceptions)

Copy link
Member

@mordante mordante left a comment

Choose a reason for hiding this comment

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

Can you add a description why this change would be beneficial?

@RichardLuo0
Copy link
Contributor Author

Can you add a description why this change would be beneficial?

It is for the same reason as #91182

Consider the following file:

#include <boost/json.hpp>
import std;

int main(int, const char **) { }

boost will include something from libc++, but we are using -nostdinc++, so the compiler can not find any default std header.
Therefore the locally built header needs to be public.

Besides, if we are using assert, the <cassert> has to be found because assert is a macro so it can not be exported.

@mordante
Copy link
Member

I see. Typically we first land a commit in main and then backport it to the release branch.

I've updated the commit message to the text of the other PR. Typically when we merge the commit message will be the message stored in git. It's good practice to have a good commit message.

I just started the CI and want to look whether it's happy. (I expect it will be.)

Copy link

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo.
Please turn off Keep my email addresses private setting in your account.
See LLVM Discourse for more information.

@RichardLuo0
Copy link
Contributor Author

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off Keep my email addresses private setting in your account. See LLVM Discourse for more information.

I have set it to non-private now.

@mordante I don't understand why the checks failed on Fetch LLVM sources.

@mordante
Copy link
Member

⚠️ We detected that you are using a GitHub private e-mail address to contribute to the repo. Please turn off Keep my email addresses private setting in your account. See LLVM Discourse for more information.

I have set it to non-private now.

@mordante I don't understand why the checks failed on Fetch LLVM sources.

Can you rebase the patch, I expect that fixes the CI issue.

@RichardLuo0 RichardLuo0 force-pushed the module-expose-header-main branch from 1120aa2 to 2050503 Compare June 12, 2024 09:20
@RichardLuo0 RichardLuo0 force-pushed the module-expose-header-main branch from 2050503 to 4153451 Compare June 12, 2024 09:22
@RichardLuo0
Copy link
Contributor Author

I rebased the PR, can you try the CI again?

@ldionne
Copy link
Member

ldionne commented Jun 12, 2024

I suspect the Windows CI is failing because a newer LLVM was somehow installed on the machines, which could be due to #95228 being tested. If that's the case, then I think we just learned that the state of CI machines on Windows is shared across all PRs, which is a bit concerning.

For the scope of this change I think we can just ignore the failures on Windows.

@ldionne
Copy link
Member

ldionne commented Jun 12, 2024

Also rebasing onto main again should solve this issue.

@mordante
Copy link
Member

There were other CI jobs failing too, our "typical cancellation issue".

@mstorsjo
Copy link
Member

I suspect the Windows CI is failing because a newer LLVM was somehow installed on the machines, which could be due to #95228 being tested. If that's the case, then I think we just learned that the state of CI machines on Windows is shared across all PRs, which is a bit concerning.

For the scope of this change I think we can just ignore the failures on Windows.

It’s not that the other jobs caused a new version to be installed; the jobs don’t cross contaminate the environment (that’d be concerning).

The base images used for the runners are continuously updated. Today, it seems like they’ve rolled out a new image that contained a newer version of LLVM out of the box. The command we used for installing the version of LLVM we wanted failed, when the installation turned out to be a downgrade.

As part of #95228 I added a flag to tell it that we’re ok with downgrading - to prevent this from becoming an issue in the future, when a newer version appears in the base image again.

@RichardLuo0
Copy link
Contributor Author

@mordante Should I rebase again?
In fact, can you just merge this? This PR doesn't change anything that may break CI, to be honest.

@ldionne
Copy link
Member

ldionne commented Jun 25, 2024

Merging since the CI issues are unrelated.

@ldionne ldionne merged commit ed1273d into llvm:main Jun 25, 2024
25 of 31 checks passed
Copy link

@RichardLuo0 Congratulations on having your first Pull Request (PR) merged into the LLVM Project!

Your changes will be combined with recent changes from other authors, then tested
by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail here.

If your change does cause a problem, it may be reverted, or you can revert it yourself.
This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are working as expected, well done!

AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…odule (llvm#91240)

This PR addresses a problem that headers may not be able to be found if
`#include` is used with std modules.

Consider the following file:

    #include <boost/json.hpp>
    import std;

    int main(int, const char **) { }


Boost will include something from libc++, but we are using -nostdinc++
at [1] so the compiler can not find any default std header. Therefore 
the locally built header needs to be public.

[1]: https://github.com/RichardLuo0/llvm-project/blob/15fdd47c4b110b64dc61f636e42e0484bf8bdbe0/libcxx/modules/CMakeLists.txt.in#L52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants