This is an archive of the discontinued LLVM Phabricator instance.

[libc++abi] Install the libc++abi headers from libc++abi
ClosedPublic

Authored by ldionne on Apr 28 2021, 7:24 AM.

Details

Reviewers
phosek
thakis
Group Reviewers
Restricted Project
Restricted Project
Commits
rG6dfdf79b8c48: [libc++abi] Install the libc++abi headers from libc++abi
Summary

libc++abi should be responsible for installing its own headers, it
doesn't make sense for libc++ to be responsible for it.

Diff Detail

Event Timeline

ldionne created this revision.Apr 28 2021, 7:24 AM
ldionne requested review of this revision.Apr 28 2021, 7:24 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptApr 28 2021, 7:24 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
ldionne added inline comments.Apr 28 2021, 7:24 AM
llvm/utils/gn/secondary/libcxx/include/BUILD.gn
494–504

Trying to save you a headache @thakis, but I'd like you to double-check this is OK.

phosek accepted this revision.Apr 28 2021, 10:00 AM

LGTM

libcxx/cmake/Modules/HandleLibCXXABI.cmake
15

We should also consider inlining this macro, I don't think it's getting us anything and I always have to lookup what each argument does so at least in my experience it harms readability.

thakis accepted this revision.EditedApr 28 2021, 12:17 PM

Makes sense to me.

Just to confirm: Even back when clang assumed that libc++ headers shipped with the compiler instead of the sdk on macOS (which I think is still the case in currently shipping xcode), it didn't assume that the libc++abi headers ship with the compiler, right? (I patched this in and clang still seems to compile a program that includes <iostream> fine, so it looks like it.)

Is there anything else that installs this header? We don't need it, but someone might?

ldionne added a comment.EditedOct 5 2021, 4:29 PM

Makes sense to me.

Just to confirm: Even back when clang assumed that libc++ headers shipped with the compiler instead of the sdk on macOS (which I think is still the case in currently shipping xcode), it didn't assume that the libc++abi headers ship with the compiler, right? (I patched this in and clang still seems to compile a program that includes <iostream> fine, so it looks like it.)

Fact: Clang used to assume that libc++ was shipped in <toolchain>/include/c++/v1, and nowadays it looks in <sdk>/include/c++/v1 first, and only falls back to <toolchain>/include/c++/v1.
Fact: Recent SDKs have the libc++ headers in <sdk>/usr/include/c++/v1.
Fact: The <cxxabi.h> header is present in both <sdk>/usr/include/c++/v1 and <sdk>/usr/include (and also in <toolchain>/usr/include/c++/v1 until we remove all traces of libc++/libc++abi from the toolchain). It looks like they are always the same thing. It's harmless but silly, since we should really have only one copy. It turns out I don't understand how the copy in <sdk>/usr/include ends up there, so I'll investigate that.

Your main question: I'm pretty sure Clang used to expect <cxxabi.h> in <toolchain>/usr/include/c++/v1, alongside the rest of libc++.

I actually hadn't realized that, and it does change what I was going to do. Instead of always installing <cxxabi.h> to <install>/usr/include, I think the correct thing to do would be to always install it to <install>/usr/include/c++/v1, but to do that directly from libc++abi. My next update will reflect that.

Edit I just found out where <sdk>/usr/include/cxxabi.h comes from. We copy it explicitly here: https://github.com/llvm/llvm-project/blob/main/libcxx/utils/ci/apple-install-libcxx.sh#L159. I wrote that code, I should have known!

libcxx/cmake/Modules/HandleLibCXXABI.cmake
15

Oh yeah, totally, I want to clean up this mess, one step at a time.

ldionne updated this revision to Diff 377384.Oct 5 2021, 4:39 PM
ldionne retitled this revision from [libc++] Do not copy the libc++abi headers into the libc++ build tree to [libc++][libc++abi] Install libc++abi headers from libc++abi, not libc++.
ldionne edited the summary of this revision. (Show Details)
ldionne added a subscriber: dim.

Install <cxxabi.h> from libc++abi.

Pinging @dim since I think you folks use a different ABI library - you should make
sure that your ABI library is installing <cxxabi.h> in a place where users can find
it on its own.

Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2021, 4:39 PM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a subscriber: arichardson. · View Herald Transcript
ldionne updated this revision to Diff 377386.Oct 5 2021, 4:43 PM

Drop the gn changes.

llvm/utils/gn/secondary/libcxx/include/BUILD.gn
494–504

@thakis I suspect you'll have more fixing up to do since you need to install the libc++abi headers from the libc++abi build. I'll just drop this GN change to avoid muddying the waters, but I'm still giving you this heads up.

ldionne updated this revision to Diff 377598.Oct 6 2021, 10:26 AM

Link cxx_static against libc++abi to get the header dependency.

emaste added a subscriber: emaste.Nov 19 2021, 7:58 AM
ldionne updated this revision to Diff 409672.Feb 17 2022, 8:36 AM
ldionne retitled this revision from [libc++][libc++abi] Install libc++abi headers from libc++abi, not libc++ to [libc++abi] Install the libc++abi headers from libc++abi.
ldionne edited the summary of this revision. (Show Details)

Rebase onto main, and don't touch any logic inside libc++. In other words, only start installing
the headers from libc++abi. I'll keep any potentially-breaking change in a separate patch.

ldionne updated this revision to Diff 409731.Feb 17 2022, 11:30 AM

Rebase onto main -- I am unable to reproduce the CI issue with GCC, and it looks like a fluke to me.

ldionne accepted this revision as: Restricted Project, Restricted Project.Feb 28 2022, 2:22 PM
This revision is now accepted and ready to land.Feb 28 2022, 2:22 PM
This revision was automatically updated to reflect the committed changes.