[compiler-rt] Fix linking a standalone libatomic for MinGW #74668
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.