CMake panics because is "unable to detect platform". How can I tell it that I'm on Un*x?

Hi all!

I’m trying to build the LLVM-embedded-toolchain-for-Arm. I separately cloned the LLVM repo as instructed (I’m on tag llvmorg-16.0.0, commit 08d094a0e457). However, when building, CMake complains

CMake Error at /home/alessandro/tesi/LLVM-embedded-toolchain-for-Arm/repos/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake:150 (MESSAGE):
  Unable to determine platform
Call Stack (most recent call first):
  CMakeLists.txt:157 (include)

The referenced file contains:

if(WIN32)
  set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
  if(CYGWIN)
    set(LLVM_ON_WIN32 0)
    set(LLVM_ON_UNIX 1)
  else(CYGWIN)
    set(LLVM_ON_WIN32 1)
    set(LLVM_ON_UNIX 0)
  endif(CYGWIN)
else(WIN32)
  if(FUCHSIA OR UNIX)
    set(LLVM_ON_WIN32 0)
    set(LLVM_ON_UNIX 1)
    if(APPLE OR ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
      set(LLVM_HAVE_LINK_VERSION_SCRIPT 0)
    else()
      set(LLVM_HAVE_LINK_VERSION_SCRIPT 1)
    endif()
  else(FUCHSIA OR UNIX)
    MESSAGE(SEND_ERROR "Unable to determine platform") // <----- HERE
  endif(FUCHSIA OR UNIX)
endif(WIN32)

I can’t find the UNIX variable in the CMake files: how should I set it? I tried running CMake like

cmake -DLLVM_ENABLE_PROJECTS=clang -DCMAKE_BUILD_TYPE=Debug -DLLVM_USE_LINKER=lld -DLLVM_PARALLEL_LINK_JOBS=1 -G "Ninja" -B ./build -S ./llvm

but with no success.

What am I doing wrong?

Thanks!

UNIX is a CMake builtin variable (UNIX — CMake 3.26.1 Documentation). It should be set automatically.

  • What is your platform / operating system?
  • You should ask the embedded toolchain guys for help.

Yep that was my guess too.

Arch Linux

Do you mean the GH issues, or do you know of more specific places?

message(STATUS "Using LLVM on: ${CMAKE_SYSTEM_NAME}")

As it is an LLVM file, you could temporarily hack the file.

It prints blank:

-- Using LLVM on: 

Something is wrong with CMake on your platform or your CMake installation. Maybe try the latest binary packages from cmake.org and see if that works better.

Somehow, it seemed to be a problem of the actual LLVM codebase. Compiling main branch worked fine. This kinda closes the issue, but I wonder if it’s a problem of the LLVM repo or of the embedded toolchain