CMake hung while compiling libical

Hi All,

While compiling libical using CMake on SLES12 - we see that CMake gets hung.
CMake details -

cmake --version

cmake version 3.5.2

On cranking gdb to CMake, we see the below backtrace.
(gdb) bt
#0 0x00007fe49d392a43 in __select_nocancel () from /lib64/libc.so.6
#1 0x0000000000ab5c5a in kwsysProcessWaitForPipe ()
#2 0x0000000000ab5780 in cmsysProcess_WaitForData ()
#3 0x000000000083b02d in cmSystemTools::RunSingleCommand(std::vector<std::string, std::allocator< std::string> > const&, std::string*, std::string*, int*, char const*, cmSystemTools::OutputOption, double) ()
#4 0x0000000000a05e07 in cmGlobalGenerator::Build(std::string const&, std::string const&, std::string const&, std::string const&, std::string&, std::string const&, std::string const&, bool, bool, bool, double, cmSystemTools::OutputOption, std::vector<std::string, std::allocator< std::string> > const&) ()
#5 0x0000000000a05756 in cmGlobalGenerator::TryCompile(std::string const&, std::string const&, std::string const&, std::string const&, bool, std::string&, cmMakefile*) ()
#6 0x00000000007dc3f4 in cmMakefile::TryCompile(std::string const&, std::string const&, std::string const&, std::string const&, bool, std::vector<std::string, std::allocator< std::string> > const*, std::string&) ()
#7 0x00000000008a806c in cmCoreTryCompile::TryCompileCode(std::vector<std::string, std::allocator< std::string> > const&) ()
#8 0x0000000000919bcc in cmTryCompileCommand::InitialPass(std::vector<std::string, std::allocator< std::string> > const&, cmExecutionStatus&) ()
#9 0x00000000008d57e1 in cmCommand::InvokeInitialPass(std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&) ()
#10 0x00000000007cd8bf in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
#11 0x00000000008faa3f in cmIfFunctionBlocker::IsFunctionBlocked(cmListFileFunction const&, cmMakefile&, cmExecutionStatus&) ()
#12 0x00000000007daa64 in cmMakefile::IsFunctionBlocked(cmListFileFunction const&, cmExecutionStatus&) ()
#13 0x00000000007cd733 in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
#14 0x000000000090871a in cmMacroHelperCommand::InvokeInitialPass(std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&) ()
#15 0x00000000007cd8bf in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
#16 0x000000000090871a in cmMacroHelperCommand::InvokeInitialPass(std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&) ()
#17 0x00000000007cd8bf in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
#18 0x00000000008faa3f in cmIfFunctionBlocker::IsFunctionBlocked(cmListFileFunction const&, cmMakefile&, cmExecutionStatus&) ()
#19 0x00000000007daa64 in cmMakefile::IsFunctionBlocked(cmListFileFunction const&, cmExecutionStatus&) ()
#20 0x00000000007cd733 in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&) ()
#21 0x00000000007ceb98 in cmMakefile::ReadListFile(cmListFile const&, std::string const&) ()
#22 0x00000000007d36a2 in cmMakefile::Configure() ()
#23 0x0000000000a01fcd in cmGlobalGenerator::Configure() ()
#24 0x0000000000a21fb2 in cmGlobalUnixMakefileGenerator3::Configure() ()
#25 0x00000000008625f4 in cmake::ActualConfigure() ()
#26 0x000000000086175f in cmake::Configure() ()
#27 0x000000000086333b in cmake::Run(std::vector<std::string, std::allocatorstd::string > const&, bool) ()
#28 0x000000000078a6d2 in do_cmake(int, char const* const*) ()
#29 0x0000000000789c9d in main ()
(gdb)

Could anyone help in fixing this.

Thanks,
Prakash

Does this happen on the latest version of CMake?

3.5.2 was a while ago.

Looks like it gets hung in a try-compile. Can you run cmake --trace and figure out which try_compile is hanging? Or do you see any output that might give a clue as to where it is stuck?

Ran cmake with --trace option

/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(70): try_compile(HAVE_OPEN ${CMAKE_BINARY_DIR} ${_cfe_source} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_INCLUDES} OUTPUT_VARIABLE OUTPUT )
CMake Warning (dev) at /opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake:70 (try_compile):
Policy CMP0056 is not set: Honor link flags in try_compile() source-file
signature. Run “cmake --help-policy CMP0056” for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

For compatibility with older versions of CMake, try_compile is not honoring
caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) in the test project.
Call Stack (most recent call first):
ConfigureChecks.cmake:36 (check_function_exists)
CMakeLists.txt:320 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(78): unset(_cfe_source )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(80): if(HAVE_OPEN )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(81): set(HAVE_OPEN 1 CACHE INTERNAL Have function open )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(82): if(NOT CMAKE_REQUIRED_QUIET )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(83): message(STATUS Looking for open - found )
– Looking for open - found
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(85): file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log Determining if the function open exists passed with the following output:\n ${OUTPUT}\n\n )
/home/kumarj/d1/d2/d3/2022.0.0/binaries/libical/ConfigureChecks.cmake(37): check_function_exists(nanosleep HAVE_NANOSLEEP )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(42): if(NOT DEFINED HAVE_NANOSLEEP OR x${HAVE_NANOSLEEP} STREQUAL xHAVE_NANOSLEEP )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(43): set(MACRO_CHECK_FUNCTION_DEFINITIONS -DCHECK_FUNCTION_EXISTS=nanosleep ${CMAKE_REQUIRED_FLAGS} )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(45): if(NOT CMAKE_REQUIRED_QUIET )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(46): message(STATUS Looking for nanosleep )
– Looking for nanosleep
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(48): if(CMAKE_REQUIRED_LIBRARIES )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(51): else()
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(52): set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(54): if(CMAKE_REQUIRED_INCLUDES )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(57): else()
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(58): set(CHECK_FUNCTION_EXISTS_ADD_INCLUDES )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(61): if(CMAKE_C_COMPILER_LOADED )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(62): set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c )
/opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake(70): try_compile(HAVE_NANOSLEEP ${CMAKE_BINARY_DIR} ${_cfe_source} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_INCLUDES} OUTPUT_VARIABLE OUTPUT )
CMake Warning (dev) at /opt/tools/share/cmake-3.5/Modules/CheckFunctionExists.cmake:70 (try_compile):
Policy CMP0056 is not set: Honor link flags in try_compile() source-file
signature. Run “cmake --help-policy CMP0056” for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

For compatibility with older versions of CMake, try_compile is not honoring
caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) in the test project.
Call Stack (most recent call first):
ConfigureChecks.cmake:37 (check_function_exists)
CMakeLists.txt:320 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

Thank you @YMba9g8j9CJp0wLoQf5y and @bill.hoffman,

We tried with Cmake 3.20 on SLES12 platform, we still see the intermittent hang -

Stack trace
gdb) bt
#0 0x00007f4fc5694a43 in __select_nocancel () from /lib64/libc.so.6
#1 0x000000000091a92a in cmsysProcess_WaitForData ()
#2 0x000000000050f9ac in cmSystemTools::RunSingleCommand(std::vector<std::string, std::allocator< std::string> > const&, std::string*, std::string*, int*, char const*, cmSystemTools::OutputOption, std::chrono::duration<double, std::ratio<1l, 1l> >, cmProcessOutput::Encoding) ()
#3 0x00000000007cd870 in cmGlobalGenerator::Build(int, std::string const&, std::string const&, std::string const&, std::vector<std::string, std::allocator< std::string> > const&, std::string&, std::string const&, std::string const&, bool, bool, bool, std::chrono::duration<double, std::ratio<1l, 1l> >, cmSystemTools::OutputOption, std::vector<std::string, std::allocator< std::string> > const&) ()
#4 0x00000000007ce25a in cmGlobalGenerator::TryCompile(int, std::string const&, std::string const&, std::string const&, std::string const&, bool, std::string&, cmMakefile*) ()
#5 0x0000000000492543 in cmMakefile::TryCompile(std::string const&, std::string const&, std::string const&, std::string const&, bool, int, std::vector<std::string, std::allocator< std::string> > const*, std::string&) ()
#6 0x00000000008a4c66 in cmCoreTryCompile::TryCompileCode(std::vector<std::string, std::allocator< std::string> > const&, bool) ()
#7 0x000000000064c0b9 in cmTryCompileCommand::InitialPass(std::vector<std::string, std::allocator< std::string> > const&, cmExecutionStatus&) ()
#8 0x00000000005555dc in cmCommand::InvokeInitialPass(std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&)
()
#9 0x0000000000555815 in cmLegacyCommandWrapper::operator()(std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&) const ()
#10 0x00000000004a3aba in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&, cm::optional< std::string>) ()
#11 0x00000000005e032e in cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction, std::allocator >, cmExecutionStatus&) ()
#12 0x00000000005d6f0c in cmFunctionBlocker::IsFunctionBlocked(cmListFileFunction const&, cmExecutionStatus&) ()
#13 0x00000000004a33c6 in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&, cm::optional< std::string>) ()
#14 0x0000000000613ed1 in (anonymous namespace)::cmMacroHelperCommand::operator()(std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&) const ()
#15 0x00000000004a3aba in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&, cm::optional< std::string>) ()
#16 0x00000000005e032e in cmIfFunctionBlocker::Replay(std::vector<cmListFileFunction, std::allocator >, cmExecutionStatus&) ()
#17 0x00000000005d6f0c in cmFunctionBlocker::IsFunctionBlocked(cmListFileFunction const&, cmExecutionStatus&) ()
#18 0x00000000004a33c6 in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&, cm::optional< std::string>) ()
#19 0x00000000004a6c77 in cmMakefile::RunListFile(cmListFile const&, std::string const&, cmMakefile::DeferCommands*) [clone .constprop.786] ()
#20 0x00000000004a7262 in cmMakefile::ReadDependentFile(std::string const&, bool) ()
#21 0x00000000005e337e in cmIncludeCommand(std::vector<std::string, std::allocator< std::string> > const&, cmExecutionStatus&) ()
#22 0x00000000004f14f5 in std::_Function_handler<bool (std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&), cmState::AddBuiltinCommand(std::string const&, bool ()(std::vector<std::string, std::allocator< std::string> > const&, cmExecutionStatus&))::{lambda(std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&)#1}>::_M_invoke(std::_Any_data const&, std::vector<cmListFileArgument, std::allocator > const&, cmExecutionStatus&) ()
#23 0x00000000004a3aba in cmMakefile::ExecuteCommand(cmListFileFunction const&, cmExecutionStatus&, cm::optional< std::string>) ()
#24 0x00000000004a422e in cmMakefile::RunListFile(cmListFile const&, std::string const&, cmMakefile::DeferCommands
) ()
#25 0x00000000004a4ef2 in cmMakefile::Configure() ()
#26 0x00000000007dc216 in cmGlobalGenerator::Configure() ()
#27 0x00000000007eda83 in cmGlobalUnixMakefileGenerator3::Configure() ()
#28 0x000000000053fc61 in cmake::ActualConfigure() ()
#29 0x0000000000540f3d in cmake::Configure() ()
#30 0x000000000054dbb3 in cmake::Run(std::vector<std::string, std::allocator< std::string> > const&, bool) ()
#31 0x0000000000433095 in (anonymous namespace)::do_cmake(int, char const* const*) ()
#32 0x000000000041afb1 in main ()
(gdb)

cmake --trace

/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(58): if(NOT DEFINED HAVE_SIGNAL OR x${HAVE_SIGNAL} STREQUAL xHAVE_SIGNAL )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(59): set(MACRO_CHECK_FUNCTION_DEFINITIONS -DCHECK_FUNCTION_EXISTS=signal ${CMAKE_REQUIRED_FLAGS} )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(61): if(NOT CMAKE_REQUIRED_QUIET )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(62): message(CHECK_START Looking for signal )
– Looking for signal
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(64): if(CMAKE_REQUIRED_LINK_OPTIONS )
/home/kumarj/x1/x2/x3/2022.0.0/binaries/libical/ConfigureChecks.cmake(67): else()
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(68): set(CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(70): if(CMAKE_REQUIRED_LIBRARIES )
/home/kumarj/x1/x2/x3/2022.0.0/binaries/libical/ConfigureChecks.cmake(73): else()
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(74): set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(76): if(CMAKE_REQUIRED_INCLUDES )
/home/kumarj/x1/x2/x3/2022.0.0/binaries/libical/ConfigureChecks.cmake(79): else()
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(80): set(CHECK_FUNCTION_EXISTS_ADD_INCLUDES )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(83): if(CMAKE_C_COMPILER_LOADED )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(84): set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c )
/home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake(92): try_compile(HAVE_SIGNAL ${CMAKE_BINARY_DIR} ${_cfe_source} COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_INCLUDES} OUTPUT_VARIABLE OUTPUT )
CMake Warning (dev) at /home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake:92 (try_compile):
Policy CMP0066 is not set: Honor per-config flags in try_compile()
source-file signature. Run “cmake --help-policy CMP0066” for policy
details. Use the cmake_policy command to set the policy and suppress this
warning.

For compatibility with older versions of CMake, try_compile is not honoring
caller config-specific compiler flags (e.g. CMAKE_C_FLAGS_DEBUG) in the
test project.
Call Stack (most recent call first):
ConfigureChecks.cmake:38 (check_function_exists)
CMakeLists.txt:320 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

CMake Warning (dev) at /home/kj/cmake-3.20.1/Modules/CheckFunctionExists.cmake:92 (try_compile):
Policy CMP0056 is not set: Honor link flags in try_compile() source-file
signature. Run “cmake --help-policy CMP0056” for policy details. Use the
cmake_policy command to set the policy and suppress this warning.

For compatibility with older versions of CMake, try_compile is not honoring
caller link flags (e.g. CMAKE_EXE_LINKER_FLAGS) in the test project.
Call Stack (most recent call first):
ConfigureChecks.cmake:38 (check_function_exists)
CMakeLists.txt:320 (include)
This warning is for project developers. Use -Wno-dev to suppress it.

I hope the above logs help in understanding the issue. Please let us know if we could try something else to get more information and/or fix it.

Thanks in advance.

Regards,
Prakash

Looks like the bug is occurring in the CheckFunctionExists module. Is that correct? If so could you create a SSCCE?

In the meantime try using CheckSymbolExists instead.

From the docs:



Note

Prefer using CheckSymbolExists instead of this module, for the following reasons:

    check_function_exists() can't detect functions that are inlined in headers or specified as a macro.

    check_function_exists() can't detect anything in the 32-bit versions of the Win32 API, because of a mismatch in calling conventions.

    check_function_exists() only verifies linking, it does not verify that the function is declared in system headers.


Looks like the problem is here:

What is on that line in your project? If you have a CMakeLists.txt with just that line in it does it still hang? What function is that checking for? Is there anything in CMakeFiles/CMakeOutput.log or CMakeError.log that is useful? Seems like other function exist calls are working. So what is it about this one?

@bill.hoffman : We use cmake to compile Libical version 3.0.8

So, this does not happen every time? Sometimes it works? Can you post the CMakeOutput.log and CMakeError.log files? Looks like for some reason the compiler is hanging and cmake is waiting for it to finish. There might be something in those files. If you create a small cmake project with just this:

cmake_minimum_required(VERSION 3.1.0) 
project(libical C) #CXX is optional for the bindings
include(CheckFunctionExists)
check_function_exists(signal HAVE_SIGNAL)

Does that work?

Hey,
Is there any config that needs to be enabled to generate these files “CMakeOutput.log and CMakeError.log”?

No, they should be in the build tree by default in the CMakeFiles directory.

Hey,
I got the hang issue with cmake v3.5

cmake logs:
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(127): add_definitions(-DWITH_CXX_BINDINGS )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(136): add_feature_info(Option WITH_CXX_BINDINGS WITH_CXX_BINDINGS build the C++ bindings. Requires a C++ compiler )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(284): if(${_enabled} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(285): set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES ${_name} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(290): set_property(GLOBAL PROPERTY CMAKE${_name}_DESCRIPTION ${_desc} )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(142): option(STATIC_ONLY Build static libraries only. )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(143): add_feature_info(Option STATIC_ONLY STATIC_ONLY build static libraries only )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(284): if(${_enabled} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(286): else()
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(287): set_property(GLOBAL APPEND PROPERTY DISABLED_FEATURES ${_name} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(290): set_property(GLOBAL PROPERTY CMAKE${_name}_DESCRIPTION ${_desc} )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(148): if(STATIC_ONLY )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(152): option(SHARED_ONLY Build shared (dynamic) libraries only. Takes precedence over STATIC_ONLY )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(153): add_feature_info(Option SHARED_ONLY SHARED_ONLY build shared libraries only )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(284): if(${_enabled} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(286): else()
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(287): set_property(GLOBAL APPEND PROPERTY DISABLED_FEATURES ${_name} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(290): set_property(GLOBAL PROPERTY CMAKE${_name}_DESCRIPTION ${_desc} )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(158): if(SHARED_ONLY )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(163): if(NOT STATIC_ONLY AND NOT SHARED_ONLY )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(164): add_feature_info(Build types TRUE build both shared and static libraries )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(284): if(${_enabled} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(285): set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES ${_name} )
/opt/tools/share/cmake-3.5/Modules/FeatureSummary.cmake(290): set_property(GLOBAL PROPERTY CMAKE${_name}_DESCRIPTION ${_desc} )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(171): if(STATIC_ONLY )
/home/brema/d1/d2/d3/2022.0.0/binaries/libical/CMakeLists.txt(180): find_package(Perl REQUIRED )
/opt/tools/share/cmake-3.5/Modules/FindPerl.cmake(28): include(${CMAKE_CURRENT_LIST_DIR}/FindCygwin.cmake )
/opt/tools/share/cmake-3.5/Modules/FindCygwin.cmake(20): if(WIN32 )
/opt/tools/share/cmake-3.5/Modules/FindPerl.cmake(30): set(PERL_POSSIBLE_BIN_PATHS ${CYGWIN_INSTALL_PATH}/bin )
/opt/tools/share/cmake-3.5/Modules/FindPerl.cmake(34): if(WIN32 )
/opt/tools/share/cmake-3.5/Modules/FindPerl.cmake(45): find_program(PERL_EXECUTABLE NAMES perl PATHS ${PERL_POSSIBLE_BIN_PATHS} )
/opt/tools/share/cmake-3.5/Modules/FindPerl.cmake(50): if(PERL_EXECUTABLE )
/opt/tools/share/cmake-3.5/Modules/FindPerl.cmake(52): execute_process(COMMAND ${PERL_EXECUTABLE} -V:version OUTPUT_VARIABLE PERL_VERSION_OUTPUT_VARIABLE RESULT_VARIABLE PERL_VERSION_RESULT_VARIABLE ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE )

I could not attach the error logs due to new user restrictions.

Hey @bill.hoffman

I have tried the same test which was suggesting, seems the check_function_exists macro is failing to detect the function’s existence in the system,

I ran the CMake project once, it is getting a successful result.
while running in a loop. It fails.

Test project code:
brema@pbi-18-s12:~/x1/x2/x3/check> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.1.0)
project(libical C) #CXX is optional for the bindings
include(CheckFunctionExists)
check_function_exists(signal HAVE_SIGNAL)

Logs:

– The C compiler identification is GNU 4.8.3
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Looking for signal
– Looking for signal - found
– Configuring done
– Generating done
– Build files have been written to: /home/brema/x1/x2/x3/check

– The C compiler identification is GNU 4.8.3
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Looking for signal
– Looking for signal - found
– Configuring done
– Generating done
– Build files have been written to: /home/brema/x1/x2/x3/check

– The C compiler identification is GNU 4.8.3
– Check for working C compiler: /usr/bin/cc
– Check for working C compiler: /usr/bin/cc – works
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Detecting C compile features
– Detecting C compile features - done
– Looking for signal

GDB logs on hanged Cmake proces:
warning: /etc/gdbinit.d/gdb-heap.py: No such file or directory
-: No such file or directory.
Attaching to process 18334
Reading symbols from /bin/bash…(no debugging symbols found)…done.
Reading symbols from /lib64/libreadline.so.6…(no debugging symbols found)…done.
Loaded symbols for /lib64/libreadline.so.6
Reading symbols from /lib64/libtinfo.so.5…(no debugging symbols found)…done.
Loaded symbols for /lib64/libtinfo.so.5
Reading symbols from /lib64/libdl.so.2…(no debugging symbols found)…done.
Loaded symbols for /lib64/libdl.so.2
Reading symbols from /lib64/libc.so.6…(no debugging symbols found)…done.
Loaded symbols for /lib64/libc.so.6
Reading symbols from /lib64/ld-linux-x86-64.so.2…(no debugging symbols found)…done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
0x00007fb589c792dc in waitpid () from /lib64/libc.so.6
Missing separate debuginfos, use: zypper install bash-debuginfo-4.2-75.2.x86_64
(gdb) bt
#0 0x00007fb589c792dc in waitpid () from /lib64/libc.so.6
#1 0x0000000000429781 in ?? ()
#2 0x000000000042aa92 in wait_for ()
#3 0x000000000046222f in execute_command_internal ()
#4 0x0000000000460676 in execute_command_internal ()
#5 0x0000000000462951 in execute_command ()
#6 0x0000000000424164 in ?? ()
#7 0x0000000000462176 in execute_command_internal ()
#8 0x0000000000462951 in execute_command ()
#9 0x000000000041b7f1 in reader_loop ()
#10 0x000000000041b4db in main ()
(gdb)

Looks like the Cmake tool is waiting for some pid.

What version of CMake are you running in this last test and where did the build come from? Does it work if you use this one: https://github.com/Kitware/CMake/releases/download/v3.20.3/cmake-3.20.3-linux-x86_64.tar.gz

When CMake’s process blocks inside cmsysProcess_WaitForData, it means that it is waiting for some child process to write data to its output pipes, or close them. If the child process creates long-lived/daemonized grandchildren that inherit those pipes, then CMake will continue to block waiting for those.

Does pstree show any child processes of the hung CMake process?

Hey @bill.hoffman, CMake hung while compiling libical

I was using Cmake 3.20.1 in my last test.

I have installed the same binaries(i.e 3.20.3) which you have shared, even in this build also seeing the same hang issue.

-- The C compiler identification is GNU 4.8.3
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for signal
-- Looking for signal - found
-- Configuring done
-- Generating done
-- Build files have been written to: /home/brema/x1/x2/x3/check

-- The C compiler identification is GNU 4.8.3
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Looking for signal

OS details:

brema@hostname:~> cat /etc/os-release
NAME="SLES"
VERSION="12"
VERSION_ID="12"
PRETTY_NAME="SUSE Linux Enterprise Server 12"
ID="sles"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:suse:sles:12"

Please let me if any info needed to debug further, Thanks

Hi @brad.king

pstree details:

brema@pbi-18-s12:~> pstree -alps 30335
systemd,1 --switched-root --system --deserialize 19
  └─sshd,1308 -D
      └─sshd,30329
          └─sshd,30334
              └─bash,30335
                  └─cmake,11784 ../check
                      └─(gmake,11806)
brema@pbi-18-s12:~> pstree -alp 30335
bash,30335
  └─cmake,11784 ../check
      └─(gmake,11806)
brema@pbi-18-s12:~> pstree -ap 30335
bash,30335
  └─cmake,11784 ../check
      └─(gmake,11806)
brema@pbi-18-s12:~> pstree -p 30335
bash(30335)───cmake(11784)───gmake(11806)
brema@pbi-18-s12:~> pstree -a 30335
bash
  └─cmake ../check
      └─(gmake)

bash(30335)───cmake(11784)───gmake(11806)

From that pstree output, we can see that it is actually gmake that is hanging, and cmake is blocked waiting for it.

1 Like

Can you try it with the ninja build generator to see if it is a gmake issue? Another thought would be to try –debug-trycompile as an option. Then running gmake by hand in the “left over” files. And see if gmake hangs without cmake.

One other question, are you deleting the build tree in between runs of CMake?

Hey @bill.hoffman,

Yes, I am deleting all CMake autogenerate files in each iteration.

brema@hostname:~/x1/x2/x3/check> ls
CMakeFiles CMakeLists.txt

brema@hostname:~/x1/x2/x3/check> cat CMakeLists.txt
cmake_minimum_required(VERSION 3.1.0)
project(libical C) #CXX is optional for the bindings
include(CheckFunctionExists)
check_function_exists(signal HAVE_SIGNAL)

while [ TRUE ]; do echo ; rm -rf CMakeCache.txt CMakeFiles cmake_install.cmake Makefile ; cmake …/check; done