herbertluo
herbertluo

Reputation: 79

CMake `test_big_endian` failed with `no suitable type found`

gcc (GCC) 10.2.0 cmake version 3.19.4

CMakeFile.txt

    ...
    test_big_endian(WORDS_BIGENDIAN)
    ...

cmake output:

-- Check if the system is big endian -- Searching 16 bit integer -- Looking for sys/types.h -- Looking for sys/types.h - not found -- Looking for stdint.h -- Looking for stdint.h - not found -- Looking for stddef.h -- Looking for stddef.h - not found -- Check size of unsigned short -- Check size of unsigned short - failed -- Check size of unsigned int -- Check size of unsigned int - failed -- Check size of unsigned long -- Check size of unsigned long - failed CMake Error at /usr/local/cmake/share/cmake-3.19/Modules/TestBigEndian.cmake:51 (message): no suitable type found Call Stack (most recent call first): contrib/xz/cmake/tuklib_integer.cmake:23 (test_big_endian)
contrib/xz/CMakeLists.txt:126 (tuklib_integer)

CMakeError.log output:

Determining if the include file sys/types.h exists failed with the following output: Change Dir: /data/clickhouse/clickhouse/ClickHouse/build/CMakeFiles/CMakeTmp

Run Build Command(s):/usr/local/bin/ninja cmTC_73c6f && [1/2] Building C object CMakeFiles/cmTC_73c6f.dir/CheckIncludeFile.c.o [2/2] Linking C executable cmTC_73c6f FAILED: cmTC_73c6f : && /usr/local/bin/gcc -fdiagnostics-color=always -pipe -msse4.1 -msse4.2 -mpopcnt -Wall -Werror -w -fuse-ld=gold -rdynamic -Wl,--no-undefined -Wl,-no-pie -rdynamic CMakeFiles/cmTC_73c6f.dir/CheckIncludeFile.c.o -o cmTC_73c6f && : /usr/bin/ld.gold: error: cannot find -lgcc_s /usr/bin/ld.gold: error: cannot find -lgcc_s /lib/../lib64/libc.a(syslog.o):function __vsyslog_chk: error: undefined reference to '_Unwind_Resume' /lib/../lib64/libc.a(syslog.o):function __vsyslog_chk: error: undefined reference to '_Unwind_Resume' /lib/../lib64/libc.a(syslog.o):function openlog: error: undefined reference to '_Unwind_Resume' /lib/../lib64/libc.a(syslog.o):function closelog: error: undefined reference to '_Unwind_Resume' /lib/../lib64/libc.a(syslog.o)(.eh_frame+0xd78b): error: undefined reference to '__gcc_personality_v0' /lib/../lib64/libc.a(backtrace.o):function backtrace_helper: error: undefined reference to '_Unwind_GetIP' /lib/../lib64/libc.a(backtrace.o):function backtrace_helper: error: undefined reference to '_Unwind_GetCFA' /lib/../lib64/libc.a(backtrace.o):function __backtrace: error: undefined reference to '_Unwind_Backtrace' collect2: error: ld returned 1 exit status ninja: build stopped: subcommand failed.

I found where the error occurred. cmake-3.19/Modules/CheckIncludeFile.cmake:

  if(${VARIABLE})
      if(NOT CMAKE_REQUIRED_QUIET)
        message(CHECK_PASS "found")
      endif()
      set(${VARIABLE} 1 CACHE INTERNAL "Have include ${INCLUDE}")
      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
        "Determining if the include file ${INCLUDE} "
        "exists passed with the following output:\n"
        "${OUTPUT}\n\n")
    else()
      if(NOT CMAKE_REQUIRED_QUIET)
        message(CHECK_FAIL "not found")
      endif()
      set(${VARIABLE} "" CACHE INTERNAL "Have include ${INCLUDE}")
      file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
        "Determining if the include file ${INCLUDE} "
        "exists failed with the following output:\n"
        "${OUTPUT}\n\n")
    endif()

What does the error mean? How to fix it?

---- new ----

/usr/bin/ld.gold: error: cannot find -lgcc_s cause by gcc flag -Wl,-no-pie. Why gcc_s can not found?

Upvotes: 0

Views: 1966

Answers (2)

user15308163
user15308163

Reputation:

Btw in cmake 3.20 they introduced CMAKE_LANG_BYTE_ORDER.

Which is faster than using TestBigEndian: https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_BYTE_ORDER.html#variable:CMAKE_%3CLANG%3E_BYTE_ORDER

Upvotes: 1

herbertluo
herbertluo

Reputation: 79

The reason was version of ld too low (2.23). Updated to version (2.27), it works fine.

Upvotes: 0

Related Questions