Page MenuHomePhabricator

[runtimes] Replace LIBCXX_ENABLE_STATIC_ABI_LIBRARY & friends by a new LIBCXX_CXX_ABI choice
Needs ReviewPublic

Authored by ldionne on May 16 2022, 5:54 AM.

Details

Reviewers
phosek
mstorsjo
Group Reviewers
Restricted Project
Restricted Project
Summary

Instead of having complicated options like LIBCXX_ENABLE_STATIC_ABI_LIBRARY
and LIBCXX_STATICALLY_LINK_ABI_IN_STATIC_LIBRARY, introduce the new
libcxxabi-objects choice of ABI library to allow merging the ABI library
objects into libc++.

Note that the same refactoring can be applied to how libc++abi merges
libunwind's objects, however that can be done as a separate step.

Diff Detail

Unit TestsFailed

TimeTest
1,201,190 mslibcxx CI AIX (32-bit) > ibm-libc++-shared-cfg-in.std/algorithms/alg_modifying_operations/alg_transform::ranges.transform.pass.cpp
Script: -- : 'COMPILED WITH'; /opt/IBM/openxlC/17.1.0/bin/ibm-clang++_r /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.pass.cpp --target=powerpc-ibm-aix -nostdinc++ -D__LIBC_NO_CPP_MATH_OVERLOADS__ -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1 -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/lib -lc++ -lc++abi -latomic -Wl,-bbigtoc -o /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/test/std/algorithms/alg.modifying.operations/alg.transform/Output/ranges.transform.pass.cpp.dir/t.tmp.exe
1,201,190 mslibcxx CI AIX (32-bit) > ibm-libc++-shared-cfg-in.std/algorithms/alg_modifying_operations/alg_transform::ranges.transform.pass.cpp
Script: -- : 'COMPILED WITH'; /opt/IBM/openxlC/17.1.0/bin/ibm-clang++_r /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.pass.cpp --target=powerpc-ibm-aix -nostdinc++ -D__LIBC_NO_CPP_MATH_OVERLOADS__ -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1 -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/lib -lc++ -lc++abi -latomic -Wl,-bbigtoc -o /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/test/std/algorithms/alg.modifying.operations/alg.transform/Output/ranges.transform.pass.cpp.dir/t.tmp.exe
1,201,190 mslibcxx CI AIX (32-bit) > ibm-libc++-shared-cfg-in.std/algorithms/alg_modifying_operations/alg_transform::ranges.transform.pass.cpp
Script: -- : 'COMPILED WITH'; /opt/IBM/openxlC/17.1.0/bin/ibm-clang++_r /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.pass.cpp --target=powerpc-ibm-aix -nostdinc++ -D__LIBC_NO_CPP_MATH_OVERLOADS__ -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1 -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/lib -lc++ -lc++abi -latomic -Wl,-bbigtoc -o /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/test/std/algorithms/alg.modifying.operations/alg.transform/Output/ranges.transform.pass.cpp.dir/t.tmp.exe
1,201,190 mslibcxx CI AIX (32-bit) > ibm-libc++-shared-cfg-in.std/algorithms/alg_modifying_operations/alg_transform::ranges.transform.pass.cpp
Script: -- : 'COMPILED WITH'; /opt/IBM/openxlC/17.1.0/bin/ibm-clang++_r /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.pass.cpp --target=powerpc-ibm-aix -nostdinc++ -D__LIBC_NO_CPP_MATH_OVERLOADS__ -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1 -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/lib -lc++ -lc++abi -latomic -Wl,-bbigtoc -o /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/test/std/algorithms/alg.modifying.operations/alg.transform/Output/ranges.transform.pass.cpp.dir/t.tmp.exe
1,201,190 mslibcxx CI AIX (32-bit) > ibm-libc++-shared-cfg-in.std/algorithms/alg_modifying_operations/alg_transform::ranges.transform.pass.cpp
Script: -- : 'COMPILED WITH'; /opt/IBM/openxlC/17.1.0/bin/ibm-clang++_r /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/std/algorithms/alg.modifying.operations/alg.transform/ranges.transform.pass.cpp --target=powerpc-ibm-aix -nostdinc++ -D__LIBC_NO_CPP_MATH_OVERLOADS__ -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/include/c++/v1 -I /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/libcxx/test/support -std=c++2b -Werror -Wall -Wextra -Wshadow -Wundef -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move -Wno-c++11-extensions -Wno-noexcept-type -Wno-atomic-alignment -Wno-user-defined-literals -Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code -Wno-unused-local-typedef -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -D_LIBCPP_DISABLE_AVAILABILITY -fcoroutines-ts -Werror=thread-safety -Wuser-defined-warnings -nostdlib++ -L /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/lib -lc++ -lc++abi -latomic -Wl,-bbigtoc -o /scratch/powerllvm/cpap8006/llvm-project/libcxx-ci/build/aix/test/std/algorithms/alg.modifying.operations/alg.transform/Output/ranges.transform.pass.cpp.dir/t.tmp.exe
View Full Test Results (33,895 Failed)

Event Timeline

ldionne created this revision.May 16 2022, 5:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptMay 16 2022, 5:54 AM
ldionne requested review of this revision.May 16 2022, 5:54 AM
Herald added projects: Restricted Project, Restricted Project, Restricted Project, Restricted Project, Restricted Project. · View Herald TranscriptMay 16 2022, 5:54 AM
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added a reviewer: Restricted Project. · View Herald Transcript
Herald added subscribers: llvm-commits, libcxx-commits, Restricted Project, cfe-commits. · View Herald Transcript

It looks like this patch still lacks compatibility handling for all external users that are setting this option, which need to be able to set the option in this way at least until after the 15.0.0 release.

It looks like this patch still lacks compatibility handling for all external users that are setting this option, which need to be able to set the option in this way at least until after the 15.0.0 release.

What would you think about erroring out if someone is still passing LIBCXX_STATICALLY_LINK_ABI_IN_{SHARED|STATIC}_LIBRARY? Sure, we can try to support both for a while, but I wonder whether there's any actual benefit to balance the added complexity. Concretely, I suspect this impacts very few people, and the fix is really simple. And if we error out during the CMake step, we don't risk breaking anyone silently.

It looks like this patch still lacks compatibility handling for all external users that are setting this option, which need to be able to set the option in this way at least until after the 15.0.0 release.

What would you think about erroring out if someone is still passing LIBCXX_STATICALLY_LINK_ABI_IN_{SHARED|STATIC}_LIBRARY? Sure, we can try to support both for a while, but I wonder whether there's any actual benefit to balance the added complexity. Concretely, I suspect this impacts very few people, and the fix is really simple. And if we error out during the CMake step, we don't risk breaking anyone silently.

I guess that's better than silently (well, cmake warns, but it's easy to miss) no longer doing what it used to, but it's not ideal IMO. I do my continuous build testing with a build invocation that also works for the latest release - but with the suggested transition, there's no single build invocation that works for both the main branch and the 14.x release. I guess I could manage though, but I'd prefer a smoother upgrade path.

I guess that's better than silently (well, cmake warns, but it's easy to miss) no longer doing what it used to, but it's not ideal IMO. I do my continuous build testing with a build invocation that also works for the latest release - but with the suggested transition, there's no single build invocation that works for both the main branch and the 14.x release. I guess I could manage though, but I'd prefer a smoother upgrade path.

Understood. I'll make sure it is backwards compatible.

ldionne updated this revision to Diff 430051.May 17 2022, 7:17 AM

Don't remove the old options yet for backwards compatibility.

ldionne added inline comments.May 17 2022, 7:18 AM
clang/cmake/caches/Fuchsia-stage2.cmake
125

Note that I am removing these options here because I don't think they are required -- since we specify LIBCXXABI_ENABLE_SHARED=OFF, there is no shared libc++abi to link against, so we should already be linking against libc++abi.a regardless of this change.

phosek added inline comments.May 17 2022, 11:57 PM
clang/cmake/caches/Fuchsia-stage2.cmake
125

This option was set to merge libc++abi.a into libc++.a so to achieve the same effect, presumably we would need to set -DLIBCXX_CXX_ABI=libcxxabi-objects?

mstorsjo added inline comments.May 18 2022, 3:19 AM
libcxx/cmake/caches/MinGW.cmake
3

Unfortunately, setting LIBCXX_CXX_ABI=libcxxabi-objects here in the cache file doesn't have any effect, because the run-buildbot script invokes cmake with a different parameter:

function generate-cmake() {
    generate-cmake-base \
          -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi;libunwind" \
          -DLIBCXX_CXX_ABI=libcxxabi \
          "${@}"
}

A cmake parameter explicitly set on the command line always overrides what's set in a cache file.

libcxxabi/CMakeLists.txt
254 ↗(On Diff #430051)

The fallback handling (checking LIBCXX_ENABLE_STATIC_ABI_LIBRARY, updating LIBCXX_CXX_ABI based on that) in libcxx doesn't have any effect here, since libcxxabi is processed strictly before libcxx, so here we only see the original values of the options.

However, luckily enough, I've posted D125715 a couple days ago, which lets us get rid of this whole problematic piece of code altogether (together with fixing a couple other issues), now that we have object libraries in palce!

llvm/docs/HowToBuildWindowsItaniumPrograms.rst
159

If the example instructions used to say LIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON before, you should update the LIBCXX_CXX_ABI setting here to libcxxabi-objects too.

ldionne updated this revision to Diff 430779.May 19 2022, 12:52 PM
ldionne marked 3 inline comments as done.

Address some comments (but not @phosek's yet).

ldionne added inline comments.May 19 2022, 12:52 PM
clang/cmake/caches/Fuchsia-stage2.cmake
125

I agree this is suspicious, but why is there no LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY specified here then? I can add -DLIBCXX_CXX_ABI=libcxxabi-objects, I just want to make sure we both understand what's going on.

libcxx/cmake/caches/MinGW.cmake
3

I actually don't see why we need to specify the ABI library to use by libc++ manually there, so I'll remove it. It should be just the same for all the CI bots we have anyways, but if we did introduce a CI configuration where we don't want to use libc++abi as our ABI library from libc++, it would make sense not to overwrite it. We are testing the libc++abi code base separately regardless of that setting anyway.

libcxxabi/CMakeLists.txt
254 ↗(On Diff #430051)

Awesome, thanks! This should go away when I rebase, then.

llvm/docs/HowToBuildWindowsItaniumPrograms.rst
159

Ugh, good catch, thanks. Not sure why I didn't do it that way in the first place.

phosek added inline comments.May 20 2022, 12:11 AM
clang/cmake/caches/Fuchsia-stage2.cmake
125

This is intentional. We are merging libc++abi.a into libc++.a but we ship libc++abi.so and libc++.so as separate (and use the generated linker script to pull in libc++abi.so when you pass -lc++ to linker). I'd be fine merging libc++abi.so into libc++.so as well, but we'll need to figure out a transition plan since there are several places in our build right now that expect libc++abi.so to exist. We cannot land this change as is because that would break the -static-libstdc++ use case, since Clang driver only passes -lc++ to the linker and not -lc++abi and there's nothing that would pull libc++abi.a in.

ldionne added inline comments.May 20 2022, 6:43 AM
clang/cmake/caches/Fuchsia-stage2.cmake
125

I see, so to summarize, basically you want to use libcxxabi-objects for the static libc++.a, but libcxxabi for the dynamic libc++.so. This change as currently laid out does not permit that to happen, since libcxxabi-objects implies that the objects are merged both in the static and in the shared library. I guess we could introduce a new libcxxabi-objects-static option, however that would be kind of strange. We can either do that, or wait for you to stop relying on libc++abi.so existing and switch to libcxxabi-objects wholesale for Fuchsia. WDYT?

ldionne added inline comments.Fri, May 27, 2:04 PM
clang/cmake/caches/Fuchsia-stage2.cmake
125

Gentle ping. It would be nice to land this in one form or another. If you don't think Fuchsia can stop relying on libc++abi.so being there, I could add yet another libcxxabi-objects-static -- I still feel like that's better than the status quo.

ldionne updated this revision to Diff 432634.Fri, May 27, 2:05 PM

Rebase onto main.

phosek added inline comments.Fri, May 27, 2:09 PM
clang/cmake/caches/Fuchsia-stage2.cmake
125

We discussed this on our team and we don't have any issues switching towards combined libc++.so, we just need to figure out a transition plan. Let me test this change locally to see if landing this as is will break anything.

ldionne added inline comments.Thu, Jun 9, 10:12 AM
clang/cmake/caches/Fuchsia-stage2.cmake
125

Gentle ping -- did you get any time to investigate this?

phosek added inline comments.Mon, Jun 13, 3:22 PM
clang/cmake/caches/Fuchsia-stage2.cmake
125

I did and we are currently hitting a failure related to our libunwind usage. I have created D127528 which should address it.

ldionne added inline comments.Fri, Jun 17, 2:46 PM
clang/cmake/caches/Fuchsia-stage2.cmake
125

Thanks! Since this has been landed, does it mean we can move forward with this patch?