[llvm] 3d0aed7 - [CMake] Use compiler-rt location instead of resource directory to find clang-cls runtime directory
Markus Böck via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 18 01:26:29 PDT 2021
Author: Markus Böck
Date: 2021-03-18T09:24:49+01:00
New Revision: 3d0aed79362de001bf010ae027f099a177ed19ed
URL: https://github.com/llvm/llvm-project/commit/3d0aed79362de001bf010ae027f099a177ed19ed
DIFF: https://github.com/llvm/llvm-project/commit/3d0aed79362de001bf010ae027f099a177ed19ed.diff
LOG: [CMake] Use compiler-rt location instead of resource directory to find clang-cls runtime directory
The current cmake script attempts to add the path containing clangs various runtime systems by getting the resource directory and then appending the hardcoded value /lib/windows to it. This works for a normal clang-cl build but fails for a build of clang using LLVM_ENABLE_PER_TARGET_RUNTIME_DIR, such as the builds from llvm/runtimes.
This patch instead uses -print-libgcc-file-name in conjunction with --rtlib=compiler-rt, and instead adds the containing directory as library path.
For non per-target runtime directory builds, such as the release builds, there is no change. Even if the builtins library were to be deleted or moved it would output the same path as before.
For per-target runtime builds that also have the builtins library, this now finds the correct directory containing all of clang runtime libraries.
Only case still not handled by this change, is if a per-target runtime directory build is used, but the builtins library was not built.
I believe that is the best we can do for now however, without modifying clang.
Differential Revision: https://reviews.llvm.org/D98786
Added:
Modified:
llvm/cmake/modules/HandleLLVMOptions.cmake
Removed:
################################################################################
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 2e088bd6e916..d85fe137c191 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -982,8 +982,8 @@ endif()
# linker directly, it isn't sufficient to pass -fsanitize=* to the linker.
if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER))
execute_process(
- COMMAND ${CMAKE_CXX_COMPILER} /clang:-print-resource-dir
- OUTPUT_VARIABLE clang_resource_dir
+ COMMAND ${CMAKE_CXX_COMPILER} /clang:-print-libgcc-file-name /clang:--rtlib=compiler-rt
+ OUTPUT_VARIABLE clang_compiler_rt_file
ERROR_VARIABLE clang_cl_stderr
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
@@ -992,8 +992,9 @@ if (CLANG_CL AND (LLVM_BUILD_INSTRUMENTED OR LLVM_USE_SANITIZER))
message(FATAL_ERROR
"Unable to invoke clang-cl to find resource dir: ${clang_cl_stderr}")
endif()
- file(TO_CMAKE_PATH "${clang_resource_dir}" clang_resource_dir)
- append("/libpath:${clang_resource_dir}/lib/windows"
+ 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}"
CMAKE_EXE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS)
More information about the llvm-commits
mailing list