diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt index 069d33bfd3d309..ea72c595a9b807 100644 --- a/compiler-rt/lib/builtins/CMakeLists.txt +++ b/compiler-rt/lib/builtins/CMakeLists.txt @@ -38,6 +38,13 @@ if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) include(UseLibtool) endif() include(AddCompilerRT) + + if(MINGW) + # Simplified version of what's set in cmake/config-ix.cmake; not including + # builtins, which are linked separately. + set(MINGW_LIBRARIES mingw32 moldname mingwex msvcrt advapi32 shell32 + user32 kernel32 mingw32 moldname mingwex msvcrt) + endif() endif() if (COMPILER_RT_STANDALONE_BUILD) @@ -881,12 +888,14 @@ if(COMPILER_RT_BUILD_STANDALONE_LIBATOMIC) endif() foreach (arch ${BUILTIN_SUPPORTED_ARCH}) if(CAN_TARGET_${arch}) + list(APPEND COMPILER_RT_LIBATOMIC_LINK_LIBS_${arch} clang_rt.builtins-${arch}) + append_list_if(MINGW "${MINGW_LIBRARIES}" COMPILER_RT_LIBATOMIC_LINK_LIBS_${arch}) add_compiler_rt_runtime(clang_rt.atomic ${BUILTIN_TYPE} ARCHS ${arch} SOURCES atomic.c LINK_FLAGS ${COMPILER_RT_LIBATOMIC_LINK_FLAGS} - LINK_LIBS clang_rt.builtins-${arch} + LINK_LIBS ${COMPILER_RT_LIBATOMIC_LINK_LIBS_${arch}} PARENT_TARGET builtins-standalone-atomic) endif() endforeach()