Skip to content

[libcxx] [docs] Update the MinGW build example #68790

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2023

Conversation

mstorsjo
Copy link
Member

The previous example wasn't a configuration that we actually test, but was a simplistic configuration with libstdc++ as ABI library.

The previous example configuration has bitrotted and broken in a couple different ways since it was added:

  • In b0fd949, libcxx added uses of weak symbols that can be overridden by the user. GNU ld fails to export such weak symbols on MinGW, resulting in errors like: C:/msys64/mingw64/bin/ld: cannot export ZNSt3__126__libcpp_assertion_handlerEPKciS1_S1: symbol wrong type (2 vs 3) By switching to using LLD, -DLLVM_ENABLE_LLD=ON, alternatively -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld, linking still succeeds.

  • In a80e65e, building with -DLIBCXX_CXX_ABI=libstdc++ in this configuration started failing. Switch to showing how to build with libcxxabi instead, which is the tested configuration and also is the typical configuration in how it most usually would be used on Windows.

These updates allow removing the mentions of the old caveats with the build configuration.

The previous example wasn't a configuration that we actually
test, but was a simplistic configuration with libstdc++ as ABI
library.

The previous example configuration has bitrotted and broken in
a couple different ways since it was added:

- In b0fd949, libcxx added uses
  of weak symbols that can be overridden by the user. GNU ld
  fails to export such weak symbols on MinGW, resulting in errors
  like:
    C:/msys64/mingw64/bin/ld: cannot export _ZNSt3__126__libcpp_assertion_handlerEPKciS1_S1_: symbol wrong type (2 vs 3)
  By switching to using LLD, -DLLVM_ENABLE_LLD=ON, alternatively
  -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld, linking still succeeds.

- In a80e65e, building with
  -DLIBCXX_CXX_ABI=libstdc++ in this configuration started failing.
  Switch to showing how to build with libcxxabi instead, which is
  the tested configuration and also is the typical configuration in
  how it most usually would be used on Windows.
@mstorsjo mstorsjo added libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. libc++abi libc++abi C++ Runtime Library. Not libc++. platform:windows labels Oct 11, 2023
@mstorsjo mstorsjo requested a review from a team as a code owner October 11, 2023 11:04
@llvmbot
Copy link
Member

llvmbot commented Oct 11, 2023

@llvm/pr-subscribers-libcxx
@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-libcxxabi

Author: Martin Storsjö (mstorsjo)

Changes

The previous example wasn't a configuration that we actually test, but was a simplistic configuration with libstdc++ as ABI library.

The previous example configuration has bitrotted and broken in a couple different ways since it was added:

  • In b0fd949, libcxx added uses of weak symbols that can be overridden by the user. GNU ld fails to export such weak symbols on MinGW, resulting in errors like: C:/msys64/mingw64/bin/ld: cannot export ZNSt3__126__libcpp_assertion_handlerEPKciS1_S1: symbol wrong type (2 vs 3) By switching to using LLD, -DLLVM_ENABLE_LLD=ON, alternatively -DCMAKE_SHARED_LINKER_FLAGS=-fuse-ld=lld, linking still succeeds.

  • In a80e65e, building with -DLIBCXX_CXX_ABI=libstdc++ in this configuration started failing. Switch to showing how to build with libcxxabi instead, which is the tested configuration and also is the typical configuration in how it most usually would be used on Windows.

These updates allow removing the mentions of the old caveats with the build configuration.


Full diff: https://github.com/llvm/llvm-project/pull/68790.diff

1 Files Affected:

  • (modified) libcxx/docs/BuildingLibcxx.rst (+4-10)
diff --git a/libcxx/docs/BuildingLibcxx.rst b/libcxx/docs/BuildingLibcxx.rst
index e919e1e6f32bfc3..e33d2dce288d098 100644
--- a/libcxx/docs/BuildingLibcxx.rst
+++ b/libcxx/docs/BuildingLibcxx.rst
@@ -160,19 +160,13 @@ e.g. the ``mingw-w64-x86_64-clang`` package), together with CMake and ninja.
   > cmake -G Ninja -S runtimes -B build                                               \
           -DCMAKE_C_COMPILER=clang                                                    \
           -DCMAKE_CXX_COMPILER=clang++                                                \
-          -DLLVM_ENABLE_RUNTIMES=libcxx                                               \
-          -DLIBCXX_CXX_ABI=libstdc++
+          -DLLVM_ENABLE_LLD=ON                                                        \
+          -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"                                   \
+          -DLIBCXXABI_ENABLE_SHARED=OFF                                               \
+          -DLIBCXX_ENABLE_STATIC_ABI_LIBRARY=ON
   > ninja -C build cxx
-  > cp /mingw64/bin/{libstdc++-6,libgcc_s_seh-1,libwinpthread-1}.dll lib
   > ninja -C build check-cxx
 
-As this build configuration ends up depending on a couple other DLLs that
-aren't available in path while running tests, copy them into the same
-directory as the tested libc++ DLL.
-
-(Building a libc++ that depends on libstdc++ isn't necessarily a config one
-would want to deploy, but it simplifies the config for testing purposes.)
-
 .. _`libc++abi`: http://libcxxabi.llvm.org/
 
 

Copy link
Member

@ldionne ldionne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks a lot for keeping those up-to-date!

@ldionne ldionne merged commit ebf1fea into llvm:main Oct 11, 2023
@mstorsjo mstorsjo deleted the libcxx-docs-mingw-example branch October 12, 2023 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++abi libc++abi C++ Runtime Library. Not libc++. libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. platform:windows
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants