[llvm] Fixed cmake config in case of LLVM_ENABLE_RPMALLOC=ON and non MSVC compiler (PR #139770)
Dmitry Vasilyev via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 10:46:11 PDT 2025
https://github.com/slydiman created https://github.com/llvm/llvm-project/pull/139770
This patch fixes the following error in case of LLVM_ENABLE_RPMALLOC=ON and clang or other non MSVC compiler:
```
CMake Error at cmake/modules/AddLLVM.cmake:644 (add_library):
Target "LLVMSupport" links to item " -INCLUDE:malloc" which has leading or
trailing whitespace. This is now an error according to policy CMP0004.
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:944 (llvm_add_library)
cmake/modules/AddLLVM.cmake:917 (add_llvm_library)
lib/Support/CMakeLists.txt:139 (add_llvm_component_library)
```
Note `delayload_flags` is empty before this line is case of non MSVC compiler.
The behavior is the same with CMake 3.25.3 and 4.0.2.
>From cdcb1b7ea42342a05e7cc44b861f969f4bde48c2 Mon Sep 17 00:00:00 2001
From: Dmitry Vasilyev <dvassiliev at accesssoftek.com>
Date: Tue, 13 May 2025 21:37:52 +0400
Subject: [PATCH] Fixed cmake config in case of LLVM_ENABLE_RPMALLOC=ON and non
MSVC compiler
This patch fixes the following error in case of LLVM_ENABLE_RPMALLOC=ON and clang or other non MSVC compiler
```
CMake Error at cmake/modules/AddLLVM.cmake:644 (add_library):
Target "LLVMSupport" links to item " -INCLUDE:malloc" which has leading or
trailing whitespace. This is now an error according to policy CMP0004.
Call Stack (most recent call first):
cmake/modules/AddLLVM.cmake:944 (llvm_add_library)
cmake/modules/AddLLVM.cmake:917 (add_llvm_library)
lib/Support/CMakeLists.txt:139 (add_llvm_component_library)
```
The behavior is the same with CMake 3.25.3 and 4.0.2
---
llvm/lib/Support/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/llvm/lib/Support/CMakeLists.txt b/llvm/lib/Support/CMakeLists.txt
index df1e65f3a588c..a4c6dde6a57ff 100644
--- a/llvm/lib/Support/CMakeLists.txt
+++ b/llvm/lib/Support/CMakeLists.txt
@@ -113,6 +113,7 @@ if(LLVM_INTEGRATED_CRT_ALLOC)
add_compile_definitions(ENABLE_OVERRIDE ENABLE_PRELOAD)
set(ALLOCATOR_FILES "${LLVM_INTEGRATED_CRT_ALLOC}/rpmalloc/rpmalloc.c")
set(delayload_flags "${delayload_flags} ${WL}-INCLUDE:malloc")
+ string(STRIP ${delayload_flags} delayload_flags)
elseif(LLVM_INTEGRATED_CRT_ALLOC MATCHES "snmalloc$")
set(ALLOCATOR_FILES "${LLVM_INTEGRATED_CRT_ALLOC}/src/snmalloc/override/new.cc")
set(system_libs ${system_libs} "mincore.lib" "${WL}-INCLUDE:malloc")
More information about the llvm-commits
mailing list