[llvm] 26fa965 - [cmake] Quote args when generating /libpath option specifying runtime dir for link/lld-link

Matthew Voss via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 10 14:13:25 PST 2023


Author: Matthew Voss
Date: 2023-03-10T14:12:46-08:00
New Revision: 26fa96542d94d26ff38b2b4383441dcbe601f0a8

URL: https://github.com/llvm/llvm-project/commit/26fa96542d94d26ff38b2b4383441dcbe601f0a8
DIFF: https://github.com/llvm/llvm-project/commit/26fa96542d94d26ff38b2b4383441dcbe601f0a8.diff

LOG: [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

Added: 
    

Modified: 
    llvm/cmake/modules/HandleLLVMOptions.cmake

Removed: 
    


################################################################################
diff  --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 4c4a1120651bf..578a3169178ee 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)


        


More information about the llvm-commits mailing list