Building gollvm on Windows 10 (i386): unable to determine host target triple; string sub-command REGEX, mode MATCH needs at least 5 arguments; Unknown architecture host

I have experienced some issues (gollvm’s project README), which look pretty much CMake related:

cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS=-stdlib=libc++ -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DGOLLVM_DEFAULT_LINKER=lld -G Ninja …/llvm-project/llvm

– The C compiler identification is Clang 10.0.0 with GNU-like command-line
– The CXX compiler identification is Clang 10.0.0 with GNU-like command-line
– The ASM compiler identification is Clang
– Found assembler: C:/Program Files/LLVM/bin/clang.exe
– Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe
– Check for working C compiler: C:/Program Files/LLVM/bin/clang.exe – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe
– Check for working CXX compiler: C:/Program Files/LLVM/bin/clang++.exe – works
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Detecting CXX compile features
– Detecting CXX compile features - done
– Looking for dlfcn.h
– Looking for dlfcn.h - not found
– Looking for errno.h
– Looking for errno.h - found
– Looking for fcntl.h
– Looking for fcntl.h - found
– Looking for link.h
– Looking for link.h - not found
– Looking for malloc/malloc.h
– Looking for malloc/malloc.h - not found
– Looking for signal.h
– Looking for signal.h - found
– Looking for sys/ioctl.h
– Looking for sys/ioctl.h - not found
– Looking for sys/mman.h
– Looking for sys/mman.h - not found
– Looking for sys/param.h
– Looking for sys/param.h - not found
– Looking for sys/resource.h
– Looking for sys/resource.h - not found
– Looking for sys/stat.h
– Looking for sys/stat.h - found
– Looking for sys/time.h
– Looking for sys/time.h - not found
– Looking for sys/types.h
– Looking for sys/types.h - found
– Looking for termios.h
– Looking for termios.h - not found
– Looking for unistd.h
– Looking for unistd.h - not found
– Looking for valgrind/valgrind.h
– Looking for valgrind/valgrind.h - not found
– Looking for fenv.h
– Looking for fenv.h - found
– Looking for FE_ALL_EXCEPT
– Looking for FE_ALL_EXCEPT - found
– Looking for FE_INEXACT
– Looking for FE_INEXACT - found
– Looking for mach/mach.h
– Looking for mach/mach.h - not found
– Looking for histedit.h
– Looking for histedit.h - not found
– Looking for CrashReporterClient.h
– Looking for CrashReporterClient.h - not found
– Looking for pfm_initialize in pfm
– Looking for pfm_initialize in pfm - not found
– Looking for xar_open in xar
– Looking for xar_open in xar - not found
– Looking for arc4random
– Looking for arc4random - not found
– Looking for backtrace
– Looking for backtrace - not found
– Could NOT find Backtrace (missing: Backtrace_LIBRARY Backtrace_INCLUDE_DIR)
– Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW
– Performing Test C_SUPPORTS_WERROR_UNGUARDED_AVAILABILITY_NEW - Success
– Looking for _Unwind_Backtrace
– Looking for _Unwind_Backtrace - not found
– Looking for getpagesize
– Looking for getpagesize - not found
– Looking for sysconf
– Looking for sysconf - not found
– Looking for getrusage
– Looking for getrusage - not found
– Looking for setrlimit
– Looking for setrlimit - not found
– Looking for isatty
– Looking for isatty - not found
– Looking for futimens
– Looking for futimens - not found
– Looking for futimes
– Looking for futimes - not found
– Looking for posix_fallocate
– Looking for posix_fallocate - not found
– Looking for sigaltstack
– Looking for sigaltstack - not found
– Looking for lseek64
– Looking for lseek64 - not found
– Looking for mallctl
– Looking for mallctl - not found
– Looking for mallinfo
– Looking for mallinfo - not found
– Looking for malloc_zone_statistics
– Looking for malloc_zone_statistics - not found
– Looking for getrlimit
– Looking for getrlimit - not found
– Looking for posix_spawn
– Looking for posix_spawn - not found
– Looking for pread
– Looking for pread - not found
– Looking for sbrk
– Looking for sbrk - not found
– Looking for strerror
– Looking for strerror - found
– Looking for strerror_r
– Looking for strerror_r - not found
– Looking for strerror_s
– Looking for strerror_s - found
– Looking for setenv
– Looking for setenv - not found
– Looking for _chsize_s
– Looking for _chsize_s - found
– Looking for _alloca
– Looking for _alloca - not found
– Looking for __alloca
– Looking for __alloca - not found
– Looking for __chkstk
– Looking for __chkstk - not found
– Looking for __chkstk_ms
– Looking for __chkstk_ms - not found
– Looking for ___chkstk
– Looking for ___chkstk - not found
– Looking for ___chkstk_ms
– Looking for ___chkstk_ms - not found
– Looking for __ashldi3
– Looking for __ashldi3 - not found
– Looking for __ashrdi3
– Looking for __ashrdi3 - not found
– Looking for __divdi3
– Looking for __divdi3 - not found
– Looking for __fixdfdi
– Looking for __fixdfdi - not found
– Looking for __fixsfdi
– Looking for __fixsfdi - not found
– Looking for __floatdidf
– Looking for __floatdidf - not found
– Looking for __lshrdi3
– Looking for __lshrdi3 - not found
– Looking for __moddi3
– Looking for __moddi3 - not found
– Looking for __udivdi3
– Looking for __udivdi3 - not found
– Looking for __umoddi3
– Looking for __umoddi3 - not found
– Looking for __main
– Looking for __main - not found
– Looking for __cmpdi2
– Looking for cmpdi2 - not found
– Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC
– Performing Test HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC - Failed
– Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC
– Performing Test HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC - Failed
– Looking for GLIBC

– Looking for GLIBC
- not found
– Performing Test HAVE_STD_IS_TRIVIALLY_COPYABLE
– Performing Test HAVE_STD_IS_TRIVIALLY_COPYABLE - Success
– Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB
– Performing Test HAVE_CXX_ATOMICS_WITHOUT_LIB - Success
– Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB
– Performing Test HAVE_CXX_ATOMICS64_WITHOUT_LIB - Success
– Performing Test LLVM_HAS_ATOMICS
– Performing Test LLVM_HAS_ATOMICS - Success
– Performing Test SUPPORTS_VARIADIC_MACROS_FLAG
– Performing Test SUPPORTS_VARIADIC_MACROS_FLAG - Success
– Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG
– Performing Test SUPPORTS_GNU_ZERO_VARIADIC_MACRO_ARGUMENTS_FLAG - Success
CMake Warning at cmake/modules/GetHostTriple.cmake:26 (message):
unable to determine host target triple
Call Stack (most recent call first):
cmake/config-ix.cmake:378 (get_host_triple)
CMakeLists.txt:647 (include)

CMake Error at cmake/config-ix.cmake:386 (string):
string sub-command REGEX, mode MATCH needs at least 5 arguments total to
** command.**
Call Stack (most recent call first):
CMakeLists.txt:647 (include)

CMake Error at cmake/config-ix.cmake:430 (message):
Unknown architecture host
Call Stack (most recent call first):
CMakeLists.txt:647 (include)

So there are 2 or 3 problems, which caused this.
Ivan

I am referencing my logs:
https://drive.google.com/file/d/19k6pkZAMM_JJU3W6e6g4rxfXcWcR5uJH/view?usp=sharing
https://drive.google.com/file/d/1Fdtpx1lNk1f3tWS6mY526fw6cH6jHFfg/view?usp=sharing

Ivan

That error is usually a sign that the project code at the location being complained about is missing some quotes around one of the arguments to the string(REGEX MATCH) command. That argument is likely a variable substitution that the author expected to never be empty, but it turned out to be empty for your particular situation and the argument ends up being elided. That reduces the number of arguments the command sees, leading to this error message.