[cmake-developers] Weird build error against libc++ on OS X 10.7 (cutting at 1024 characters)

Mojca Miklavec mojca at macports.org
Tue Jun 24 08:31:37 EDT 2014


Dear CMake developers,

I tried to compile CMake against libc++ on OS X 10.7. For a weird
reason it fails:

Built target cmsysTestsC
[ 25%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_scale.c.o
[ 25%] Building CXX object Source/kwsys/CMakeFiles/cmsys.dir/IOStream.cxx.o
[ 25%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_sub.c.o
[ 25%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_user.c.o
[ 26%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/frm_win.c.o
[ 26%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_alnum.c.o
[ 26%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_alpha.c.o
[ 27%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_enum.c.o
[ 27%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_int.c.o
[ 27%] [ 27%] Building CXX object
Source/kwsys/CMakeFiles/cmsys.dir/SystemInformation.cxx.o
Building C object Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_ipv4.c.o
[ 28%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_num.c.o
[ 28%] Building C object
Source/CursesDialog/form/CMakeFiles/cmForm.dir/fty_regex.c.o
Linking C static library libcmForm.a
ar: C: No such file or directory
make[2]: *** [Source/CursesDialog/form/libcmForm.a] Error 1
make[2]: Leaving directory `/path/to/cmake-3.0.0'
make[1]: *** [Source/CursesDialog/form/CMakeFiles/cmForm.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Linking CXX static library libcmsys.a
make[2]: Leaving directory `/path/to/cmake-3.0.0'
[ 28%] Built target cmsys
make[1]: Leaving directory `/path/to/cmake-3.0.0'
make: *** [all] Error 2


When I use "make" again and a single core, it fails with

[ 66%] Building CXX object
Source/CMakeFiles/CMakeLib.dir/cmNinjaUtilityTargetGenerator.cxx.o
cd /path/to/cmake-3.0.0/Source && /usr/bin/clang++
-DCMAKE_BUILD_WITH_CMAKE -pipe -Os -arch x86_64 -stdlib=libc++
-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
-mmacosx-version-min=10.7 -I/path/to/cmake-3.0.0/Utilities
-I/path/to/cmake-3.0.0/Source -I/opt/libcxxlocal/include
-I/path/to/cmake-3.0.0/Utilities/cmcompress
-I/path/to/cmake-3.0.0/Source/CTest
-I/path/to/cmake-3.0.0/Source/CursesDialog/form    -o
CMakeFiles/CMakeLib.dir/cmNinjaUtilityTargetGenerator.cxx.o -c
/path/to/cmake-3.0.0/Source/cmNinjaUtilityTargetGenerator.cxx
Linking CXX static library libCMakeLib.a
cd /path/to/cmake-3.0.0/Source &&
/path/to/cmake-3.0.0/Bootstrap.cmk/cmake -P
CMakeFiles/CMakeLib.dir/cmake_clean_target.cmake
cd /path/to/cmake-3.0.0/Source &&
/path/to/cmake-3.0.0/Bootstrap.cmk/cmake -E cmake_link_script
CMakeFiles/CMakeLib.dir/link.txt --verbose=1
/usr/bin/ar cr libCMakeLib.a
CMakeFiles/CMakeLib.dir/cmStandardIncludes.cxx.o
CMakeFiles/CMakeLib.dir/cmArchiveWrite.cxx.o
CMakeFiles/CMakeLib.dir/cmBootstrapCommands1.cxx.o
CMakeFiles/CMakeLib.dir/cmBootstrapCommands2.cxx.o
CMakeFiles/CMakeLib.dir/cmCacheManager.cxx.o
CMakeFiles/CMakeLib.dir/cmCommands.cxx.o
CMakeFiles/CMakeLib.dir/cmCommandArgumentLexer.cxx.o
CMakeFiles/CMakeLib.dir/cmCommandArgumentParser.cxx.o
CMakeFiles/CMakeLib.dir/cmCommandArgumentParserHelper.cxx.o
CMakeFiles/CMakeLib.dir/cmComputeComponentGraph.cxx.o
CMakeFiles/CMakeLib.dir/cmComputeLinkDepends.cxx.o
CMakeFiles/CMakeLib.dir/cmComputeLinkInformation.cxx.o
CMakeFiles/CMakeLib.dir/cmComputeTargetDepends.cxx.o
CMakeFiles/CMakeLib.dir/cmCryptoHash.cxx.o
CMakeFiles/CMakeLib.dir/cmCustomCommand.cxx.o
CMakeFiles/CMakeLib.dir/cmCustomCommandGenerator.cxx.o
CMakeFiles/CMakeLib.dir/cmDefinitions.cxx.o
CMakeFiles/CMakeLib.dir/cmDepends.cxx.o
CMakeFiles/CMakeLib.dir/cmDependsC.cxx.o
CMakeFiles/CMakeLib.dir/cmDependsFortran.cxx.o CMakeFiles/CMak
ar: CMakeFiles/CMak: No such file or directory
make[2]: *** [Source/libCMakeLib.a] Error 1
make[1]: *** [Source/CMakeFiles/CMakeLib.dir/all] Error 2
make: *** [all] Error 2

The weird part is that part of the command is simply "cut off":
    CMakeFiles/CMakeLib.dir/cmDependsFortran.cxx.o CMakeFiles/CMak<cut>

I looked into Source/CMakeFiles/CMakeLib.dir/link.txt. The first line
in that file contains 5356 characters, but the line gets cut off at
exactly 1024 when printed on the screen and fails with

ar: CMakeFiles/CMak: No such file or directory

For some reason the command

/path/to/cmake-3.0.0/Bootstrap.cmk/cmake -E cmake_link_script
CMakeFiles/CMakeLib.dir/link.txt --verbose=1

isn't outputting the whole command, but cutting it in the middle instead.

If I execute that command from link.txt manually, it works ok and the
build continues.

It then fails again with

cd /path/to/cmake-3.0.0/Source &&
/path/to/cmake-3.0.0/Bootstrap.cmk/cmake -E cmake_link_script
CMakeFiles/ccmake.dir/link.txt --verbose=1
/usr/bin/clang++   -pipe -Os -arch x86_64 -stdlib=libc++  -isysroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
-mmacosx-version-min=10.7 -Wl,-search_paths_first
-Wl,-headerpad_max_install_names  -L/opt/libcxxlocal/lib
-Wl,-headerpad_max_install_names -arch x86_64
CMakeFiles/ccmake.dir/CursesDialog/cmCursesOptionsWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesBoolWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesCacheEntryComposite.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesDummyWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesFilePathWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesForm.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesLabelWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesLongMessageForm.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesMainForm.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesPathWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesStringWidget.cxx.o
CMakeFiles/ccmake.dir/Curs
clang: error: no such file or directory: 'CMakeFiles/ccmake.dir/Curs'
make[2]: *** [bin/ccmake] Error 1
make[1]: *** [Source/CMakeFiles/ccmake.dir/all] Error 2
make: *** [all] Error 2


Even if I try to run that manually it then fails with

> sudo /usr/bin/clang++   -pipe -Os -arch x86_64 -stdlib=libc++  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -mmacosx-version-min=10.7 -Wl,-search_paths_first -Wl,-headerpad_max_install_names  -L/prefix/lib -Wl,-headerpad_max_install_names -arch x86_64 CMakeFiles/ccmake.dir/CursesDialog/cmCursesOptionsWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesBoolWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesCacheEntryComposite.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesDummyWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesFilePathWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesForm.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesLabelWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesLongMessageForm.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesMainForm.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesPathWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesStringWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/cmCursesWidget.cxx.o CMakeFiles/ccmake.dir/CursesDialog/ccmake.cxx.o  -o ../bin/ccmake  libCMakeLib.a CursesDialog/form/libcmForm.a kwsys/libcmsys.a /prefix/lib/libexpat.dylib /prefix/lib/libz.dylib /prefix/lib/libarchive.dylib ../Utilities/cmcompress/libcmcompress.a /prefix/lib/libcurl.dylib -framework CoreFoundation /prefix/lib/libncurses.dylib -v
Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
Target: x86_64-apple-darwin11.4.2
Thread model: posix
 "/usr/bin/ld" -demangle -dynamic -arch x86_64 -macosx_version_min
10.7.0 -syslibroot
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk
-o ../bin/ccmake -lcrt1.10.6.o -L/prefix/lib -search_paths_first
-headerpad_max_install_names -headerpad_max_install_names
CMakeFiles/ccmake.dir/CursesDialog/cmCursesOptionsWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesBoolWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesCacheEntryComposite.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesDummyWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesFilePathWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesForm.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesLabelWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesLongMessageForm.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesMainForm.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesPathWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesStringWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/cmCursesWidget.cxx.o
CMakeFiles/ccmake.dir/CursesDialog/ccmake.cxx.o libCMakeLib.a
CursesDialog/form/libcmForm.a kwsys/libcmsys.a
/prefix/lib/libexpat.dylib /prefix/lib/libz.dylib
/prefix/lib/libarchive.dylib ../Utilities/cmcompress/libcmcompress.a
/prefix/lib/libcurl.dylib -framework CoreFoundation
/prefix/lib/libncurses.dylib -lc++ -lSystem
/usr/bin/../lib/clang/4.2/lib/darwin/libclang_rt.osx.a
ld: archive has no table of contents for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Running with a newer compiler says
    ld: archive has no table of contents file
'CursesDialog/form/libcmForm.a' for architecture x86_64

That was the file that failed to compile earlier. But it seems that
the compiler made the file (is that a bug?) and CMake didn't know
anything was wrong and assumed the file was fine. The workaround was
to remove that file, compile it manually by running the contents from
CMakeFiles/cmForm.dir/link.txt, run make again, do a few other things
manually following the same procedure (after some commands were cut
after 1024 characters).

And then the build succeeded.

I would be grateful for any hints about how to avoid these problems
with 1024 characters limit.

Thank you,
    Mojca

(CMake works ok when it is built against libstdc++ on 10.7 or against
libc++ on 10.9.)


More information about the cmake-developers mailing list