[libcxx-commits] [PATCH] D132667: [libc++] Inlines format_error for clang-cl DLL.
Mark de Wever via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Thu Aug 25 08:39:55 PDT 2022
Mordante created this revision.
Mordante added reviewers: ldionne, mstorsjo.
Herald added a subscriber: mgorny.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.
This version is build without support for the experimental library but
the code still wants to link this function. Inlining the function solves
the issue.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D132667
Files:
libcxx/CMakeLists.txt
libcxx/include/__format/format_error.h
libcxx/src/format.cpp
Index: libcxx/src/format.cpp
===================================================================
--- libcxx/src/format.cpp
+++ libcxx/src/format.cpp
@@ -10,6 +10,8 @@
_LIBCPP_BEGIN_NAMESPACE_STD
+#ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
format_error::~format_error() noexcept = default;
+#endif
_LIBCPP_END_NAMESPACE_STD
Index: libcxx/include/__format/format_error.h
===================================================================
--- libcxx/include/__format/format_error.h
+++ libcxx/include/__format/format_error.h
@@ -31,7 +31,13 @@
: runtime_error(__s) {}
_LIBCPP_HIDE_FROM_ABI explicit format_error(const char* __s)
: runtime_error(__s) {}
+ // TODO FMT Remove when format is no longer experimental.
+ // Avoids linker errors when building the Clang Windows DLL which doesn't support the experimental library
+# ifndef _LIBCPP_INLINE_FORMAT_ERROR_DTOR
virtual ~format_error() noexcept;
+# else
+ virtual ~format_error() noexcept {}
+# endif
};
_LIBCPP_NORETURN inline _LIBCPP_HIDE_FROM_ABI void
Index: libcxx/CMakeLists.txt
===================================================================
--- libcxx/CMakeLists.txt
+++ libcxx/CMakeLists.txt
@@ -832,6 +832,14 @@
# Use the ISO conforming behaviour for conversion
# in printf, scanf.
_CRT_STDIO_ISO_WIDE_SPECIFIERS)
+ # Clang-cl shared builds don't support the experimental library.
+ # To avoid linker errors the format_error destructor is inlined for the
+ # dylib. Users can never use format in this mode.
+ # TODO FMT Remove when format becomes mainline.
+ if (LIBCXX_ENABLE_SHARED)
+ target_compile_definitions(${target} PRIVATE
+ _LIBCPP_INLINE_FORMAT_ERROR_DTOR)
+ endif()
endif()
endfunction()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132667.455601.patch
Type: text/x-patch
Size: 1864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20220825/7d8d9103/attachment.bin>
More information about the libcxx-commits
mailing list