[all-commits] [llvm/llvm-project] 4940ca: [libcxx] [test] Don't use header defines for detec...

Martin Storsjö via All-commits all-commits at lists.llvm.org
Mon Jun 6 13:19:40 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 4940caaebbe04af55c0bd36d2ad291fa75932260
      https://github.com/llvm/llvm-project/commit/4940caaebbe04af55c0bd36d2ad291fa75932260
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M libcxx/test/support/test_macros.h
    M libcxx/utils/libcxx/test/features.py

  Log Message:
  -----------
  [libcxx] [test] Don't use header defines for detecting linking against a DLL

In clang-cl/MSVC environments, linking against a DLL C++ standard
library requires having dllimport attributes in the headers; this
has been used for detecting whether the tests link against a DLL,
by looking at the libc++ specific define
_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS.

In mingw environments, thanks to slightly different code generation
and a couple linker tricks, it's possible to link against a DLL C++
standard library without dllimport attributes. Therefore, don't
rely on the libc++ specific header define for the detection.

Replace the detection with a runtime test.

Differential Revision: https://reviews.llvm.org/D125922


  Commit: dfa88927ae1411ccc3b248b7e624f2acf623d947
      https://github.com/llvm/llvm-project/commit/dfa88927ae1411ccc3b248b7e624f2acf623d947
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M libcxx/include/__config

  Log Message:
  -----------
  [libcxx] Omit dllimport in public headers in MinGW mode

In MinGW environments, thanks to slightly different code generation
and linker tricks, it's possible to link against a DLL C++ standard
library without dllimport attributes.

This allows using one single set of headers for linking against
either the DLL or a static library, leaving the decision entirely
up to the linking stage (where it can be switched with options like
-static-libstdc++).

This matches how libstdc++ headers work; there's no dllimport attributes
by default (unless the user has defined _GLIBCXX_DLL when including
headers).

This allows using one single set of headers while linking against
either a DLL or a static library, just like on Unix platforms.

This matches how libc++ has been used in MinGW configurations for
years (by first building the DLL, then configuring a static-only
build and installing on top, overwriting the libc++ config file
with one for static linking) by multiple MinGW toolchains, making
the dllimport-less use the de-facto tested configuration in the wild.

This also allows building all of libc++ in one single CMake
configuration, instead of having to do two separate builds on top of
each other.

(Linking against a DLL without dllimport can break if e.g. templates
use inconsistent visibility attributes - in cases where it still
works when using explicit dllimport; such a case was fixed in
948dd664c3ed30dd853df03cb931436f280bad4a / D99932. With this as the
default configuration, we can catch such issues in CI.)

Differential Revision: https://reviews.llvm.org/D125924


  Commit: 4a3722a2c3dff1fe885cc38bf43d3c095c9851e7
      https://github.com/llvm/llvm-project/commit/4a3722a2c3dff1fe885cc38bf43d3c095c9851e7
  Author: Martin Storsjö <martin at martin.st>
  Date:   2022-06-06 (Mon, 06 Jun 2022)

  Changed paths:
    M libcxxabi/include/__cxxabi_config.h

  Log Message:
  -----------
  [libcxxabi] Check __SEH__, when checking if ARM EHABI is implied

ARM EHABI isn't signalled by any specific compiler builtin define,
but is implied by the lack of defines specifying any other
exception handling mechanism, `__USING_SJLJ_EXCEPTIONS__` or
`__ARM_DWARF_EH__`.

As Windows SEH also can be used for unwinding, check for the
`__SEH__` define too, in the same way.

Differential Revision: https://reviews.llvm.org/D126866


Compare: https://github.com/llvm/llvm-project/compare/731dfca8a018...4a3722a2c3df


More information about the All-commits mailing list