Skip to content

Fixed cmake config in case of LLVM_ENABLE_RPMALLOC=ON and non MSVC compiler #139770

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

slydiman
Copy link
Contributor

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.

@slydiman slydiman requested review from Maetveis and aganea May 13, 2025 17:46
@slydiman slydiman added the cmake Build system in general and CMake in particular label May 13, 2025
@llvmbot
Copy link
Member

llvmbot commented May 13, 2025

@llvm/pr-subscribers-llvm-support

Author: Dmitry Vasilyev (slydiman)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/139770.diff

1 Files Affected:

  • (modified) llvm/lib/Support/CMakeLists.txt (+1)
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")

…mpiler

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
@slydiman slydiman force-pushed the fix-rpmalloc-non-msvc branch from cdcb1b7 to ab24e01 Compare May 14, 2025 04:27
Comment on lines 115 to +116
set(delayload_flags "${delayload_flags} ${WL}-INCLUDE:malloc")
string(STRIP ${delayload_flags} delayload_flags)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
set(delayload_flags "${delayload_flags} ${WL}-INCLUDE:malloc")
string(STRIP ${delayload_flags} delayload_flags)
set(delayload_flags "${delayload_flags}" "${WL}-INCLUDE:malloc")

or alternatively list(APPEND delayload_flags "${WL}-INCLUDE:malloc"). (I'd prefer the latter in new code, but the former is consistent with the existing code in this region).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular llvm:support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants