From 26fa96542d94d26ff38b2b4383441dcbe601f0a8 Mon Sep 17 00:00:00 2001 From: Matthew Voss Date: Fri, 10 Mar 2023 14:11:37 -0800 Subject: [PATCH] [cmake] Quote args when generating /libpath option specifying runtime dir for link/lld-link When the runtime dir path includes whitespace (ex. when it's installed under "Program Files" on Windows), the lack of quotes causes the linker to interpret the path as one or more arguments. None of these path fragments exist, so the link fails. Differential Revision: https://reviews.llvm.org/D145827 --- llvm/cmake/modules/HandleLLVMOptions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake index 4c4a1120651b..578a3169178e 100644 --- a/llvm/cmake/modules/HandleLLVMOptions.cmake +++ b/llvm/cmake/modules/HandleLLVMOptions.cmake @@ -1102,7 +1102,7 @@ if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER)) endif() file(TO_CMAKE_PATH "${clang_compiler_rt_file}" clang_compiler_rt_file) get_filename_component(clang_runtime_dir "${clang_compiler_rt_file}" DIRECTORY) - append("/libpath:${clang_runtime_dir}" + append("/libpath:\"${clang_runtime_dir}\"" CMAKE_EXE_LINKER_FLAGS CMAKE_MODULE_LINKER_FLAGS CMAKE_SHARED_LINKER_FLAGS)