MantisBT - CMake
View Issue Details
0014790CMakeCMakepublic2014-03-06 08:522014-10-06 10:32
Jan Rüegg 
Brad King 
normalcrashalways
closedfixed 
AppleMac OSX10.8
CMake 2.8.12.2 
CMake 3.0 
0014790: CMake crashes with XCode generator
The following commit makes cmake segfault on our project:

93fc5a53a... Xcode: Fix storyboard view

Version 2.8.12 (before this commit) works fine when running cmake.

Version 2.8.12.2 (after this commit) segfaults...
Unfortunately I cannot reproduce it with a simple project, there everything works fine. Running it through gdb I get the following output:


-- Configuring done
-- Generating done
Program received signal EXC_BAD_ACCESS, Could not access memory.
Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000030
0x00007fff8a45da26 in std::string::c_str ()
(gdb) bt
#0 0x00007fff8a45da26 in std::string::c_str ()
#1 0x000000010036c7dc in cmXCodeObject::GetString ()
0000002 0x00000001003583ab in cmGlobalXCodeGenerator::CreateXCodeTargets ()
0000003 0x00000001003697da in cmGlobalXCodeGenerator::CreateXCodeObjects ()
0000004 0x0000000100354ae3 in cmGlobalXCodeGenerator::OutputXCodeProject ()
0000005 0x000000010035378f in cmGlobalXCodeGenerator::Generate ()
0000006 0x000000010032f305 in cmake::Generate ()
0000007 0x000000010032cd52 in cmake::Run ()
0000008 0x0000000100003c0d in do_cmake ()
#9 0x00000001000022e3 in main ()

So it looks to be really related to the commit, that changes something in cmGlobalXCodeGenerator.cxx
No tags attached.
? ios.toolchain.cmake (8,650) 2014-03-10 03:26
https://public.kitware.com/Bug/file/5090/ios.toolchain.cmake
Issue History
2014-03-06 08:52Jan RüeggNew Issue
2014-03-06 08:53Jan RüeggNote Added: 0035324
2014-03-06 10:45Brad KingNote Added: 0035326
2014-03-06 13:28Ben BoeckelNote Added: 0035329
2014-03-10 03:26Jan RüeggNote Added: 0035352
2014-03-10 03:26Jan RüeggFile Added: ios.toolchain.cmake
2014-03-12 10:27Brad KingNote Added: 0035390
2014-03-14 12:59Jan RüeggNote Added: 0035410
2014-03-14 14:01Brad KingNote Added: 0035411
2014-03-14 14:01Brad KingAssigned To => Brad King
2014-03-14 14:01Brad KingStatusnew => resolved
2014-03-14 14:01Brad KingResolutionopen => fixed
2014-03-14 14:01Brad KingFixed in Version => CMake 3.0
2014-10-06 10:32Robert MaynardNote Added: 0036944
2014-10-06 10:32Robert MaynardStatusresolved => closed

Notes
(0035324)
Jan Rüegg   
2014-03-06 08:53   
One more note: As mentioned in the title, without the -GXcode it works fine...
(0035326)
Brad King   
2014-03-06 10:45   
Thanks for tracking it down to that specific commit.

Some additional refactoring of that code has occurred since 2.8.12.2. Please test with 3.0.0-rc1:

 http://www.cmake.org/files/v3.0/ [^]
(0035329)
Ben Boeckel   
2014-03-06 13:28   
FWIW, the dev/string-apis branch (which just landed in next) changes GetString to return a string and its setters to take strings as parameters. The callsites have not been updated to not use c_str() if needed, so if 3.0-rc1 still has issues, please try 'next' as well to see if the problem still exists there. Thanks.
(0035352)
Jan Rüegg   
2014-03-10 03:26   
With version 3.0.0-rc1 as well as next I don't even get to that point, and receive the error message:

CMake Error in :
  The CMAKE_C_COMPILER:

    gcc

  is not a full path and was not found in the PATH.



CMake Error in :
  The CMAKE_CXX_COMPILER:

    g++

  is not a full path and was not found in the PATH.



-- Configuring incomplete, errors occurred!

I am using the attached ios toolchain file, by the way, with cmake command similar to:

cmake -GXcode -DCMAKE_TOOLCHAIN_FILE=path/to/ios.toolchain.cmake ..
(0035390)
Brad King   
2014-03-12 10:27   
Re 0014790:0035352: CMake 3.0 introduces a requirement that CMAKE_<LANG>_COMPILER always be located as a full path to the compiler tool. However, it looks like the conversion to a full path is not done for the Xcode generator when the compiler is forced by CMakeForceCompiler. I've fixed that here:

 CMakeDetermine*Compiler: Factor out search for compiler in PATH
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6852fb80 [^]

 Xcode: Convert forced CMAKE_<LANG>_COMPILER to full path if possible
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c9bfac3 [^]

and it will be in 3.0.0-rc2. You can build the current 'release' branch from Git by hand or download a nightly binary of the bleeding edge of development:

 http://www.cmake.org/files/dev/?C=M;O=D [^]

Of course that will only work when the compiler really is in the PATH. Otherwise the call to CMAKE_FORCE_<LANG>_COMPILER in the toolchain file will have to specify a full path.

Currenlty your toolchain file contains:

 # Force the compilers to gcc for iOS
 include (CMakeForceCompiler)
 CMAKE_FORCE_C_COMPILER (gcc gcc)
 CMAKE_FORCE_CXX_COMPILER (g++ g++)

This is incorrect. The second argument is supposed to be the id of the compiler:

 http://www.cmake.org/cmake/help/v3.0/variable/CMAKE_LANG_COMPILER_ID.html [^]

Perhaps something like:

 # Force the compilers to gcc for iOS
 include (CMakeForceCompiler)
 CMAKE_FORCE_C_COMPILER (gcc GNU)
 CMAKE_FORCE_CXX_COMPILER (g++ GNU)

or use a full path explicitly:

 # Force the compilers to gcc for iOS
 include (CMakeForceCompiler)
 CMAKE_FORCE_C_COMPILER (/usr/bin/gcc GNU)
 CMAKE_FORCE_CXX_COMPILER (/usr/bin/g++ GNU)
(0035410)
Jan Rüegg   
2014-03-14 12:59   
Yes, it seems to be fixed in the the master as well as the next branch...

Thanks a lot for the help, also regarding the toolchain file.
(0035411)
Brad King   
2014-03-14 14:01   
Great, thanks for reporting back.
(0036944)
Robert Maynard   
2014-10-06 10:32   
Closing resolved issues that have not been updated in more than 4 months.