diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -130,6 +130,10 @@ set(export_file_linker_flag "${CMAKE_CURRENT_BINARY_DIR}/${native_export_file}") if(MSVC) set(export_file_linker_flag "/DEF:\"${export_file_linker_flag}\"") + elseif(WIN32) + # If we're compiling on Windows and the compiler is not Visual Studio, + # then tell it to forward the `/DEF` flag to the linker. + set(export_file_linker_flag "-Wl,/DEF:\"${export_file_linker_flag}\"") endif() set_property(TARGET ${target_name} APPEND_STRING PROPERTY LINK_FLAGS " ${export_file_linker_flag}")