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

Merged
merged 2 commits into from
May 16, 2025

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
Copy link
Contributor

@Maetveis Maetveis left a comment

Choose a reason for hiding this comment

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

LGTM. Assuming you've verified that this works, because I did not. Also please wait for pre-commit to finish before landing.

@slydiman
Copy link
Contributor Author

LGTM. Assuming you've verified that this works, because I did not. Also please wait for pre-commit to finish before landing.

Thanks.
Pre-commit failed on Linux x64 because of flang.

I will complete tests with LLVM_ENABLE_RPMALLOC before commit. No rush.

@slydiman slydiman merged commit 4a4f0ff into llvm:main May 16, 2025
9 of 11 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented May 17, 2025

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-lnt running on systemz-1 while building llvm at step 13 "setup lit".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/136/builds/3932

Here is the relevant piece of the build log for the reference
Step 13 (setup lit) failure: '/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/bin/python /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/lnt/setup.py ...' (failure)
running develop
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/lib/python3.10/site-packages/setuptools/command/easy_install.py:158: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running egg_info
writing LNT.egg-info/PKG-INFO
writing dependency_links to LNT.egg-info/dependency_links.txt
writing entry points to LNT.egg-info/entry_points.txt
writing requirements to LNT.egg-info/requires.txt
writing top-level names to LNT.egg-info/top_level.txt
reading manifest file 'LNT.egg-info/SOURCES.txt'
reading manifest template 'MANIFEST.in'
no previously-included directories found matching 'docs/_build'
no previously-included directories found matching 'tests/*/Output'
no previously-included directories found matching 'tests/*/*/Output'
adding license file 'LICENSE.TXT'
writing manifest file 'LNT.egg-info/SOURCES.txt'
running build_ext
copying build/lib.linux-s390x-3.10/lnt/testing/profile/cPerf.cpython-310-s390x-linux-gnu.so -> lnt/testing/profile
Creating /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/lib/python3.10/site-packages/LNT.egg-link (link to .)
Adding LNT 0.4.2.dev0 to easy-install.pth file
Installing lnt script to /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/sandbox/bin

Installed /home/uweigand/sandbox/buildbot/clang-s390x-linux-lnt/test/lnt
Processing dependencies for LNT==0.4.2.dev0
Searching for typing
Reading https://pypi.org/simple/typing/
Download error on https://pypi.org/simple/typing/: [Errno -3] Temporary failure in name resolution -- Some packages may not be found!
Couldn't find index page for 'typing' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.org/simple/
Download error on https://pypi.org/simple/: [Errno -3] Temporary failure in name resolution -- Some packages may not be found!
No local packages or working download links found for typing
error: Could not find suitable distribution for Requirement.parse('typing')

@slydiman
Copy link
Contributor Author

LLVM Buildbot has detected a new failure on builder clang-s390x-linux-lnt

It seems the DNS resolver failed on this buildbot. This fail is not related to this patch.

@llvm-ci
Copy link
Collaborator

llvm-ci commented May 17, 2025

LLVM Buildbot has detected a new failure on builder lld-x86_64-win running on as-worker-93 while building llvm at step 7 "test-build-unified-tree-check-all".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/146/builds/2937

Here is the relevant piece of the build log for the reference
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM-Unit :: Support/./SupportTests.exe/90/95' FAILED ********************
Script(shard):
--
GTEST_OUTPUT=json:C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe-LLVM-Unit-7896-90-95.json GTEST_SHUFFLE=0 GTEST_TOTAL_SHARDS=95 GTEST_SHARD_INDEX=90 C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe
--

Script:
--
C:\a\lld-x86_64-win\build\unittests\Support\.\SupportTests.exe --gtest_filter=ProgramEnvTest.CreateProcessLongPath
--
C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(160): error: Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp(163): error: fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied



C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:160
Expected equality of these values:
  0
  RC
    Which is: -2

C:\a\lld-x86_64-win\llvm-project\llvm\unittests\Support\ProgramTest.cpp:163
fs::remove(Twine(LongPath)): did not return errc::success.
error number: 13
error message: permission denied




********************


@slydiman
Copy link
Contributor Author

LLVM Buildbot has detected a new failure on builder lld-x86_64-win

lld-x86_64-win seems flaky. This fail is not related to this patch.

ajaden-codes pushed a commit to Jaddyen/llvm-project that referenced this pull request Jun 6, 2025
…mpiler (llvm#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.
@slydiman slydiman deleted the fix-rpmalloc-non-msvc branch June 23, 2025 09:59
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.

4 participants