diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 5f1d68762c03..75bd8ed11e1b 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -570,14 +570,15 @@ if( MSVC_IDE ) endif() # set stack reserved size to ~10MB +set(_is_exe "$,EXECUTABLE>") if(MSVC) # CMake previously automatically set this value for MSVC builds, but the # behavior was changed in CMake 2.8.11 (Issue 12437) to use the MSVC default # value (1 MB) which is not enough for us in tasks such as parsing recursive # C++ templates in Clang. - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_CXX_LINKER_WRAPPER_FLAG}/STACK:10000000") + add_link_options("$<${_is_exe}:LINKER:/STACK:10000000>") elseif(MINGW OR CYGWIN) - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--stack,16777216") + add_link_options("$<${_is_exe}:LINKER:--stack,16777216>") # Pass -mbig-obj to mingw gas to avoid COFF 2**16 section limit. if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang")