[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
This commit is contained in:
Matthew Voss 2023-03-10 14:11:37 -08:00
parent 5cfbd0f4e7
commit 26fa96542d

View File

@ -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)