Skip to content

[compiler-rt] Fix linking a standalone libatomic for MinGW #74668

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
Dec 7, 2023

Conversation

mstorsjo
Copy link
Member

@mstorsjo mstorsjo commented Dec 6, 2023

Whenever linking with -nodefaultlibs for a MinGW target, we manually need to specify a bunch of libraries - listed in ${MINGW_LIBRARIES}; the same is already done for sanitizers and libunwind/libcxxabi/libcxx.

Practically speaking, linking with -nodefaultlibs but manually passing the libraries in ${MINGW_LIBRARIES} restores most of the libraries that are linked by default, except for the potential compiler builtins and unwind library; i.e. it has essentially the same effect as linking with "--unwindlib=none -rtlib=none", except that -rtlib doesn't accept such a value.

When building only compiler-rt/lib/builtins, not all of compiler-rt, ${MINGW_LIBRARIES} is unset - set it manually here for that case. This matches what is set in
compiler-rt/cmake/config-ix.cmake, except that the builtins (libgcc or compiler-rt builtins) is omitted; the only use within lib/buitlins is for the standalone libatomic, which explicitly already links against the just-built builtins.

Whenever linking with -nodefaultlibs for a MinGW target, we
manually need to specify a bunch of libraries - listed in
${MINGW_LIBRARIES}; the same is already done for sanitizers
and libunwind/libcxxabi/libcxx.

Practically speaking, linking with -nodefaultlibs but manually
passing the libraries in ${MINGW_LIBRARIES} restores most of
the libraries that are linked by default, except for the
potential compiler builtins and unwind library; i.e. it has
essentially the same effect as linking with "--unwindlib=none
-rtlib=none", except that -rtlib doesn't accept such a value.

When building only compiler-rt/lib/builtins, not all of
compiler-rt, ${MINGW_LIBRARIES} is unset - set it manually
here for that case. This matches what is set in
compiler-rt/cmake/config-ix.cmake, except that the builtins
(libgcc or compiler-rt builtins) is omitted; the only use
within lib/buitlins is for the standalone libatomic, which
explicitly already links against the just-built builtins.
@mstorsjo mstorsjo added cmake Build system in general and CMake in particular compiler-rt:builtins labels Dec 6, 2023
@mstorsjo mstorsjo requested a review from petrhosek December 6, 2023 22:37
@mstorsjo mstorsjo merged commit 76b8975 into llvm:main Dec 7, 2023
@mstorsjo mstorsjo deleted the compiler-rt-standalone-libatomic branch December 7, 2023 11:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular compiler-rt:builtins compiler-rt
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants