Configuring compiler-rt to use default target only does not work

Hi!

I’m trying to configure LLVM with -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON so that compiler-rt is built for the native/default target only. However, that never succeeds, no matter what options I specify.

In particular, I’m configuring with:

cmake -G Ninja ../llvm -DCMAKE_BUILD_TYPE=Release -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON  -DCMAKE_INSTALL_PREFIX=../stage1.install  -DLLVM_PARALLEL_LINK_JOBS=4 -DLLVM_ENABLE_PROJECTS="clang-tools-extra;llvm;compiler-rt;clang"

which fails with:

-- Looking for rpc/xdr.h - not found
CMake Error at /data/home/glaubitz/llvm-project/compiler-rt/cmake/Modules/CompilerRTUtils.cmake:440 (string):
  string sub-command REPLACE requires at least four arguments.
Call Stack (most recent call first):
  /data/home/glaubitz/llvm-project/compiler-rt/CMakeLists.txt:106 (construct_compiler_rt_default_triple)


-- Looking for fopen in c

and

-- Performing Test COMPILER_RT_HAS_Z_TEXT - Success
-- Performing Test COMPILER_RT_HAS_FUSE_LD_LLD_FLAG
-- Performing Test COMPILER_RT_HAS_FUSE_LD_LLD_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_VERSION_SCRIPT
-- Performing Test COMPILER_RT_HAS_VERSION_SCRIPT - Success
CMake Error at /data/home/glaubitz/llvm-project/compiler-rt/cmake/base-config-ix.cmake:196 (add_default_target_arch):
  add_default_target_arch Macro invoked with incorrect arguments for macro
  named: add_default_target_arch
Call Stack (most recent call first):
  /data/home/glaubitz/llvm-project/compiler-rt/cmake/config-ix.cmake:213 (test_targets)
  /data/home/glaubitz/llvm-project/compiler-rt/CMakeLists.txt:251 (include)


-- Compiler-RT supported architectures: 
-- Performing Test COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG
-- Performing Test COMPILER_RT_HAS_VISIBILITY_HIDDEN_FLAG - Success
-- Performing Test COMPILER_RT_HAS_XRAY_COMPILER_FLAG
-- Performing Test COMPILER_RT_HAS_XRAY_COMPILER_FLAG - Failed
-- Performing Test COMPILER_RT_HAS_ATOMIC_KEYWORD
-- Performing Test COMPILER_RT_HAS_ATOMIC_KEYWORD - Success
-- Performing Test COMPILER_RT_HAS_FLOAT16
-- Performing Test COMPILER_RT_HAS_FLOAT16 - Failed
-- Performing Test COMPILER_RT_HAS_ASM_LSE
-- Performing Test COMPILER_RT_HAS_ASM_LSE - Failed
-- Builtin supported architectures: 
-- Supported architectures for crt: 
CMake Error at /data/home/glaubitz/llvm-project/compiler-rt/cmake/Modules/AddCompilerRT.cmake:762 (get_compiler_rt_output_dir):
  get_compiler_rt_output_dir Function invoked with incorrect arguments for
  function named: get_compiler_rt_output_dir
Call Stack (most recent call first):
  /data/home/glaubitz/llvm-project/compiler-rt/unittests/CMakeLists.txt:4 (configure_compiler_rt_lit_site_cfg)


CMake Error at /data/home/glaubitz/llvm-project/compiler-rt/cmake/Modules/AddCompilerRT.cmake:762 (get_compiler_rt_output_dir):
  get_compiler_rt_output_dir Function invoked with incorrect arguments for
  function named: get_compiler_rt_output_dir
Call Stack (most recent call first):
  /data/home/glaubitz/llvm-project/compiler-rt/test/CMakeLists.txt:15 (configure_compiler_rt_lit_site_cfg)


-- Builtin supported architectures: 
-- Supported architectures for crt: 
-- check-shadowcallstack does nothing.
-- Looking for sys/resource.h
-- Looking for sys/resource.h - found
-- Clang version: 15.0.0
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG
-- Performing Test CXX_SUPPORTS_NO_NESTED_ANON_TYPES_FLAG - Failed
-- Looking for include file sys/inotify.h
-- Looking for include file sys/inotify.h - found
-- Not building amdgpu-arch: hsa-runtime64 not found
-- Registering Bye as a pass plugin (static build: OFF)
-- Failed to find LLVM FileCheck
-- git version: v0.0.0 normalized to 0.0.0
-- Version: 1.6.0
-- Looking for shm_open in rt
-- Looking for shm_open in rt - found
-- Performing Test HAVE_CXX_FLAG_STD_CXX11
-- Performing Test HAVE_CXX_FLAG_STD_CXX11 - Success
-- Performing Test HAVE_CXX_FLAG_WALL
-- Performing Test HAVE_CXX_FLAG_WALL - Success
-- Performing Test HAVE_CXX_FLAG_WEXTRA
-- Performing Test HAVE_CXX_FLAG_WEXTRA - Success
-- Performing Test HAVE_CXX_FLAG_WSHADOW
-- Performing Test HAVE_CXX_FLAG_WSHADOW - Success
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE
-- Performing Test HAVE_CXX_FLAG_WSUGGEST_OVERRIDE - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC
-- Performing Test HAVE_CXX_FLAG_PEDANTIC - Success
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS
-- Performing Test HAVE_CXX_FLAG_PEDANTIC_ERRORS - Success
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32
-- Performing Test HAVE_CXX_FLAG_WSHORTEN_64_TO_32 - Failed
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_FSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS
-- Performing Test HAVE_CXX_FLAG_WNO_DEPRECATED_DECLARATIONS - Success
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS
-- Performing Test HAVE_CXX_FLAG_FNO_EXCEPTIONS - Success
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING
-- Performing Test HAVE_CXX_FLAG_WSTRICT_ALIASING - Success
-- Performing Test HAVE_CXX_FLAG_WD654
-- Performing Test HAVE_CXX_FLAG_WD654 - Failed
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY
-- Performing Test HAVE_CXX_FLAG_WTHREAD_SAFETY - Failed
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Success
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- success
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK
-- Performing Test HAVE_STEADY_CLOCK -- success
-- Configuring incomplete, errors occurred!
See also "/data/home/glaubitz/llvm-project/build/CMakeFiles/CMakeOutput.log".
See also "/data/home/glaubitz/llvm-project/build/CMakeFiles/CMakeError.log".

Looks like syntax of the cmake REPLACE command has changed, hasn’t it?

Adrian