Opened 6 months ago

Last modified 5 months ago

#73556 assigned defect

llvm-6.0, llvm-9.0: fails when using cmake ≥ 4

Reported by: rmottola (Riccardo) Owned by: jeremyhu (Jeremy Huddleston Sequoia)
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc: jeremyhu (Jeremy Huddleston Sequoia)
Port: llvm-6.0, llvm-9.0

Description

--->  Configuring llvm-6.0
Executing:  cd "/opt/local/var/macports/build/llvm-6.0-312790df/work/build" && /opt/local/bin/cmake -DCMAKE_INSTALL_PREFIX='/opt/local/libexec/llvm-6.0' -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_C_COMPILER="$CC" -DCMAKE_COLOR_MAKEFILE=ON -DCMAKE_CXX_COMPILER="$CXX" -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_MAKE_PROGRAM=/usr/bin/make -DCMAKE_MODULE_PATH=/opt/local/share/cmake/Modules -DCMAKE_SYSTEM_PREFIX_PATH="/opt/local/libexec/llvm-6.0;/opt/local;/usr" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_POLICY_DEFAULT_CMP0025=NEW -Wno-dev -DCMAKE_SYSTEM_PREFIX_PATH="/opt/local/libexec/llvm-6.0;/opt/local;/usr" -DLLVM_LINK_LLVM_DYLIB=ON -DLLVM_ENABLE_ASSERTIONS=OFF -DLLVM_ENABLE_RTTI=ON -DLLVM_INCLUDE_TESTS=OFF -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_ENABLE_FFI=ON -DLLVM_BINDINGS_LIST=none -DFFI_INCLUDE_DIR=`pkg-config --cflags-only-I libffi | sed 's/-I//'` -DFFI_LIBRARY_DIR=/opt/local/lib -DCMAKE_LIBTOOL=/opt/local/bin/libtool -DPYTHON_EXECUTABLE=/opt/local/bin/python2.7 -DLLVM_ENABLE_BACKTRACES=OFF -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_OSX_ARCHITECTURES="x86_64" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_SYSROOT="/" ../llvm-6.0.1.src 
CMake Error at CMakeLists.txt:3 (cmake_minimum_required):
  Compatibility with CMake < 3.5 has been removed from CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.

  Or, add -DCMAKE_POLICY_VERSION_MINIMUM=3.5 to try configuring anyway.



Attachments (2)

llvm6-cmake4.tar (10.0 KB) - added by rmottola (Riccardo) 5 months ago.
Patches to make clang6 compile with cmake 4
llvm9-cmake4.tar (10.0 KB) - added by rmottola (Riccardo) 5 months ago.
Patches to make clang9 compile with cmake 4

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 months ago by rmottola (Riccardo)

This looks almost identical to #73554, but we know clang/llvm 6.0 built in the past, I have the installed.

we know checking the command line:

/opt/local/bin/cmake

is 4.2.1

If I go into '/opt/local/var/macports/build/llvm-6.0-312790df/work/build' and check 'CMakeCache.txt'

i find:

CMAKE_CACHE_MAJOR_VERSION:INTERNAL=4
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=2
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=1
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=/opt/local/bin/cmake
//Path to cpack program executable.

which looks right, so somehow the check is filing, the correct cmake is found, isn't it?

Last edited 5 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:2 Changed 6 months ago by rmottola (Riccardo)

I tried removing

cmake_minimum_required(VERSION 3.4.3)

from CMakeLists.txt

and builds goes further, until:

CMake Error in CMakeLists.txt:
  No cmake_minimum_required command is present.  A line of code such as

    cmake_minimum_required(VERSION 4.2)

so heck!

What I tried is to remove minor. e.g. 3.2

But he error remains.

https://cmake.org/cmake/help/latest/command/cmake_minimum_required.html

This makes me think I am using a "too new" cmake. How does it come? Perhaps on other systems a different cmake is installed, maybe the system one?

Last edited 5 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

comment:3 Changed 6 months ago by jmroot (Joshua Root)

Owner: set to jeremyhu
Port: llvm-6.0 added; llvm removed
Status: newassigned

comment:4 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

Keywords: leopard removed
Summary: llvm 6.0 fails on 10.5 Leopard cmake < 3.5llvm-6.0: fails when using cmake ≥ 4

I doubt this is specific to any macOS version. Rather, presumably you have installed the cmake-devel port, which is at version 4.x.

To work around this problem, you can deactivate cmake-devel and install cmake instead, which is still at version 3.x specifically because of problems like the one you found here. See #73505.

llvm-6.0, and probably some other older llvm-* ports, will need to be fixed for compatibility with cmake 4.x. Anyone can submit pull requests with such fixes.

comment:5 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

Port: llvm-9.0 added
Summary: llvm-6.0: fails when using cmake ≥ 4llvm-6.0, llvm-9.0: fails when using cmake ≥ 4

Let's call #73554 (for llvm-9.0) a duplicate of this one.

comment:6 Changed 5 months ago by rmottola (Riccardo)

Ok. I can confirm all assumptions up to know. I'm working on llvm 6.0 / clang 6.0.

  • I have cmake-devel 4 installed (for whatever reason it was pulled in as dependency)
  • cmake 4 is explicitly incompatible with stuff below 3.5

I tried just "upgrading" requisites. There are

llvm-6.0.1.src/CMakeLists.txt
llvm-6.0.1.src/projects/compiler-rt/CMakeLists.txt
llvm-6.0.1.src/runtimes/CMakeLists.txt
llvm-6.0.1.src/projects/libcxx/CMakeLists.txt

and a couple of more places, I had also to change a setting from OLD to NEW... and got it building. At the same, these patches make clearly require cmake 3.5, perhaps should be applied conditionally, but it is a proof that not much more is needed.

Last edited 5 months ago by ryandesign (Ryan Carsten Schmidt) (previous) (diff)

Changed 5 months ago by rmottola (Riccardo)

Attachment: llvm6-cmake4.tar added

Patches to make clang6 compile with cmake 4

comment:7 Changed 5 months ago by rmottola (Riccardo)

Same concept applies fine also for Clang9 - patches attached. llvm itself requires less patches, but then clang is built that uses more subdirectories.

Changed 5 months ago by rmottola (Riccardo)

Attachment: llvm9-cmake4.tar added

Patches to make clang9 compile with cmake 4

comment:8 Changed 5 months ago by rmottola (Riccardo)

As a further update, I deactivated cmake-devel and activated standard cmake, with that I was able to build llvm/clang11 fine. So checked both paths.

comment:9 in reply to:  6 Changed 5 months ago by ryandesign (Ryan Carsten Schmidt)

Replying to rmottola:

I had also to change a setting from OLD to NEW...

Specifically you changed CMP0051 from OLD to NEW. Documentation confirms the OLD behavior is no longer available in CMake 4. But there was a comment above that line explaining why it was set to OLD. That suggests that changing it to NEW will cause a problem.

Are your patches based on upstream llvm commits? If so, please include the commit URLs. If not, please see how upstream llvm solved these problems and use those patches.

At the same, these patches make clearly require cmake 3.5, perhaps should be applied conditionally, but it is a proof that not much more is needed.

We don't need to apply conditionally in MacPorts since we don't need to maintain compatibility with CMake < 3.5 since our cmake port is currently at version 3.31.10. Even the cmake-bootstrap port, should we need to switch to that, is at version 3.9.6.

Note: See TracTickets for help on using tickets.