This is an archive of the discontinued LLVM Phabricator instance.

[CMake] Use libcxx targets for in-tree sanitizer C++ ABI
ClosedPublic

Authored by phosek on Sep 29 2022, 12:56 AM.

Details

Summary

When in-tree libcxx is selected as the sanitizer C++ ABI, use libcxx
targets rather than libcxxabi and libunwind, since those may not be
available on all platforms (Windows for example).

Diff Detail

Event Timeline

phosek created this revision.Sep 29 2022, 12:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 12:56 AM
Herald added a subscriber: Enna1. · View Herald Transcript
phosek requested review of this revision.Sep 29 2022, 12:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 29 2022, 12:56 AM
Herald added a subscriber: Restricted Project. · View Herald Transcript

LGTM modulo two small questions.

compiler-rt/CMakeLists.txt
582–592

Should we document this directly here?

583–587

If the unwinder bits here no longer apply, then do we still need the TODO above?

phosek added inline comments.Sep 29 2022, 6:27 PM
compiler-rt/CMakeLists.txt
582–592

I don't think so, the use of libcxxabi and libunwind instead of libcxx is for legacy reasons that are no longer relevant. Using libcxx targets when you set SANITIZER_CXX_ABI_LIBNAME=libc++ shouldn't be surprising, adding the comment about libcxxabi and libunwind here would just add confusion.

583–587

This TODO is still relevant, although it's primarily useful to me as a future reminder when I start refactoring this code further.

This revision was not accepted when it landed; it landed in state Needs Review.Sep 29 2022, 6:29 PM
This revision was automatically updated to reflect the committed changes.
phosek updated this revision to Diff 464383.Sep 30 2022, 1:31 PM

Rework the patch to make sure we use the correct unwinder and C++ ABI.

This revision was landed with ongoing or failed builds.Sep 30 2022, 1:32 PM
hans added a subscriber: hans.Oct 3 2022, 6:00 AM

This caused our builds to break:

CMake Error at /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/cmake/Modules/AddCompilerRT.cmake:383 (target_link_libraries):
  Error evaluating generator expression:

    $<TARGET_LINKER_FILE:$<IF:$<TARGET_EXISTS:libcxx-abi-shared>,libcxx-abi-shared,libcxx-abi-static>>

  No target "libcxx-abi-static"
Call Stack (most recent call first):
  /b/s/w/ir/cache/builder/src/third_party/llvm/compiler-rt/lib/ubsan/CMakeLists.txt:242 (add_compiler_rt_runtime)

see https://bugs.chromium.org/p/chromium/issues/detail?id=1370500#c1 for a reproducer.

I've reverted in 20a269cf774e774fb5c7194b1aebe24df27a233f until this is figured out.

phosek reopened this revision.Oct 8 2022, 8:35 PM
phosek updated this revision to Diff 466333.
This revision was not accepted when it landed; it landed in state Needs Review.Oct 8 2022, 8:36 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.