Opened 12 years ago

Closed 12 years ago

#35253 closed defect (invalid)

cmake @2.8.8 fails to build with XCode 4.5 DP3 clang with -std=c++11 -stdlib=libc++

Reported by: acmorrow (Andrew C. Morrow) Owned by: cssdev
Priority: Normal Milestone:
Component: ports Version: 2.1.1
Keywords: Cc:
Port: cmake

Description

I've been experimenting with building a macports based dev environment with clang and libc++. However, CMake fails to build correctly when configure.compiler is 'clang', and when configure.cxxflags contains '-stdlib=libc++'. More specifically:

building with clang++ -std=c++11 works building with clang++ -std=c++11 -stdlib=libc++ does not.

I dont' know yet whether this is a problem with CMake, or a problem with libc++. The build seems to fail because a linker response file is incompletely consumed:

Linking C static library libcmcurl.a
ar: CMak: No such file or directory
make[2]: *** [Utilities/cmcurl/libcmcurl.a] Error 1
make[2]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8'
make[1]: *** [Utilities/cmcurl/CMakeFiles/cmcurl.dir/all] Error 2
make[1]: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8'
make: *** [all] Error 2
make: Leaving directory `/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8'
Command failed:  cd "/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8" && /usr/bin/make -w all 
Exit code: 2

Notice the truncated file name 'CMak'

Digging in, we can manually try to invoke the makefile for libcmcurl.a:

find . -name libcmcurl.a | xargs sudo rm
acm-mac-pro:cmake-2.8.8 acm$ sudo make all VERBOSE=1
<snipped ...>
make -f Utilities/cmcurl/CMakeFiles/cmcurl.dir/build.make Utilities/cmcurl/CMakeFiles/cmcurl.dir/build
Linking C static library libcmcurl.a
cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Utilities/cmcurl && /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Bootstrap.cmk/cmake -P CMakeFiles/cmcurl.dir/cmake_clean_target.cmake
cd /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Utilities/cmcurl && /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Bootstrap.cmk/cmake -E cmake_link_script CMakeFiles/cmcurl.dir/link.txt --verbose=1
/usr/bin/ar cr libcmcurl.a  CMakeFiles/cmcurl.dir/base64.c.o CMakeFiles/cmcurl.dir/connect.c.o CMakeFiles/cmcurl.dir/content_encoding.c.o CMakeFiles/cmcurl.dir/cookie.c.o CMakeFiles/cmcurl.dir/dict.c.o CMakeFiles/cmcurl.dir/easy.c.o CMakeFiles/cmcurl.dir/escape.c.o CMakeFiles/cmcurl.dir/file.c.o CMakeFiles/cmcurl.dir/formdata.c.o CMakeFiles/cmcurl.dir/ftp.c.o CMakeFiles/cmcurl.dir/getenv.c.o CMakeFiles/cmcurl.dir/getinfo.c.o CMakeFiles/cmcurl.dir/gtls.c.o CMakeFiles/cmcurl.dir/hash.c.o CMakeFiles/cmcurl.dir/hostares.c.o CMakeFiles/cmcurl.dir/hostasyn.c.o CMakeFiles/cmcurl.dir/hostip4.c.o CMakeFiles/cmcurl.dir/hostip6.c.o CMakeFiles/cmcurl.dir/hostip.c.o CMakeFiles/cmcurl.dir/hostsyn.c.o CMakeFiles/cmcurl.dir/hostthre.c.o CMakeFiles/cmcurl.dir/http.c.o CMakeFiles/cmcurl.dir/http_chunks.c.o CMakeFiles/cmcurl.dir/http_digest.c.o CMakeFiles/cmcurl.dir/http_negotiate.c.o CMakeFiles/cmcurl.dir/http_ntlm.c.o CMakeFiles/cmcurl.dir/if2ip.c.o CMakeFiles/cmcurl.dir/inet_ntop.c.o CMakeFiles/cmcurl.dir/inet_pton.c.o CMak
ar: CMak: No such file or directory
make[2]: *** [Utilities/cmcurl/libcmcurl.a] Error 1
make[1]: *** [Utilities/cmcurl/CMakeFiles/cmcurl.dir/all] Error 2
make: *** [all] Error 2

If you look at the invocation of 'ar' at the end and the list of files, you can clearly see a truncated filename at the end.

And if we look at the link.txt file that was used to drive the link, it *does not* contain truncated data:

$ cat /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Utilities/cmcurl/CMakeFiles/cmcurl.dir/link.txt 
/usr/bin/ar cr libcmcurl.a  CMakeFiles/cmcurl.dir/base64.c.o CMakeFiles/cmcurl.dir/connect.c.o CMakeFiles/cmcurl.dir/content_encoding.c.o CMakeFiles/cmcurl.dir/cookie.c.o CMakeFiles/cmcurl.dir/dict.c.o CMakeFiles/cmcurl.dir/easy.c.o CMakeFiles/cmcurl.dir/escape.c.o CMakeFiles/cmcurl.dir/file.c.o CMakeFiles/cmcurl.dir/formdata.c.o CMakeFiles/cmcurl.dir/ftp.c.o CMakeFiles/cmcurl.dir/getenv.c.o CMakeFiles/cmcurl.dir/getinfo.c.o CMakeFiles/cmcurl.dir/gtls.c.o CMakeFiles/cmcurl.dir/hash.c.o CMakeFiles/cmcurl.dir/hostares.c.o CMakeFiles/cmcurl.dir/hostasyn.c.o CMakeFiles/cmcurl.dir/hostip4.c.o CMakeFiles/cmcurl.dir/hostip6.c.o CMakeFiles/cmcurl.dir/hostip.c.o CMakeFiles/cmcurl.dir/hostsyn.c.o CMakeFiles/cmcurl.dir/hostthre.c.o CMakeFiles/cmcurl.dir/http.c.o CMakeFiles/cmcurl.dir/http_chunks.c.o CMakeFiles/cmcurl.dir/http_digest.c.o CMakeFiles/cmcurl.dir/http_negotiate.c.o CMakeFiles/cmcurl.dir/http_ntlm.c.o CMakeFiles/cmcurl.dir/if2ip.c.o CMakeFiles/cmcurl.dir/inet_ntop.c.o CMakeFiles/cmcurl.dir/inet_pton.c.o CMakeFiles/cmcurl.dir/krb4.c.o CMakeFiles/cmcurl.dir/ldap.c.o CMakeFiles/cmcurl.dir/llist.c.o CMakeFiles/cmcurl.dir/md5.c.o CMakeFiles/cmcurl.dir/mprintf.c.o CMakeFiles/cmcurl.dir/multi.c.o CMakeFiles/cmcurl.dir/netrc.c.o CMakeFiles/cmcurl.dir/parsedate.c.o CMakeFiles/cmcurl.dir/progress.c.o CMakeFiles/cmcurl.dir/security.c.o CMakeFiles/cmcurl.dir/select.c.o CMakeFiles/cmcurl.dir/sendf.c.o CMakeFiles/cmcurl.dir/share.c.o CMakeFiles/cmcurl.dir/socks.c.o CMakeFiles/cmcurl.dir/speedcheck.c.o CMakeFiles/cmcurl.dir/splay.c.o CMakeFiles/cmcurl.dir/ssh.c.o CMakeFiles/cmcurl.dir/sslgen.c.o CMakeFiles/cmcurl.dir/ssluse.c.o CMakeFiles/cmcurl.dir/strdup.c.o CMakeFiles/cmcurl.dir/strequal.c.o CMakeFiles/cmcurl.dir/strerror.c.o CMakeFiles/cmcurl.dir/telnet.c.o CMakeFiles/cmcurl.dir/tftp.c.o CMakeFiles/cmcurl.dir/timeval.c.o CMakeFiles/cmcurl.dir/transfer.c.o CMakeFiles/cmcurl.dir/url.c.o CMakeFiles/cmcurl.dir/version.c.o

Interestingly, the length of the truncated command line that was actually passed to ar comes out very close to exactly 1k:

$ echo -n /usr/bin/ar cr libcmcurl.a  CMakeFiles/cmcurl.dir/base64.c.o CMakeFiles/cmcurl.dir/connect.c.o CMakeFiles/cmcurl.dir/content_encoding.c.o CMakeFiles/cmcurl.dir/cookie.c.o CMakeFiles/cmcurl.dir/dict.c.o CMakeFiles/cmcurl.dir/easy.c.o CMakeFiles/cmcurl.dir/escape.c.o CMakeFiles/cmcurl.dir/file.c.o CMakeFiles/cmcurl.dir/formdata.c.o CMakeFiles/cmcurl.dir/ftp.c.o CMakeFiles/cmcurl.dir/getenv.c.o CMakeFiles/cmcurl.dir/getinfo.c.o CMakeFiles/cmcurl.dir/gtls.c.o CMakeFiles/cmcurl.dir/hash.c.o CMakeFiles/cmcurl.dir/hostares.c.o CMakeFiles/cmcurl.dir/hostasyn.c.o CMakeFiles/cmcurl.dir/hostip4.c.o CMakeFiles/cmcurl.dir/hostip6.c.o CMakeFiles/cmcurl.dir/hostip.c.o CMakeFiles/cmcurl.dir/hostsyn.c.o CMakeFiles/cmcurl.dir/hostthre.c.o CMakeFiles/cmcurl.dir/http.c.o CMakeFiles/cmcurl.dir/http_chunks.c.o CMakeFiles/cmcurl.dir/http_digest.c.o CMakeFiles/cmcurl.dir/http_negotiate.c.o CMakeFiles/cmcurl.dir/http_ntlm.c.o CMakeFiles/cmcurl.dir/if2ip.c.o CMakeFiles/cmcurl.dir/inet_ntop.c.o CMakeFiles/cmcurl.dir/inet_pton.c.o CMak | wc -c
    1022

While the full length of link.txt is 1969 bytes:

$ wc -c /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Utilities/cmcurl/CMakeFiles/cmcurl.dir/link.txt     1969 /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Utilities/cmcurl/CMakeFiles/cmcurl.dir/link.txt

If we run the bootstrap cmake command that causes this link under dtruss, we can see that it reads the full lenth of link.txt, but only writes 1k worth of it back to stdout.

sudo dtruss /opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_devel_cmake/cmake/work/cmake-2.8.8/Bootstrap.cmk/cmake -E cmake_link_script CMakeFiles/cmcurl.dir/link.txt --verbose=1
<...snip...>
open_nocancel("CMakeFiles/cmcurl.dir/link.txt\0", 0x0, 0x1B6)		 = 3 0
fstat64(0x3, 0x7FFF67B0F3E8, 0x7FFF67B0F4AC)		 = 0 0
read_nocancel(0x3, "/usr/bin/ar cr libcmcurl.a  CMakeFiles/cmcurl.dir/base64.c.o CMakeFiles/cmcurl.dir/connect.c.o CMakeFiles/cmcurl.dir/content_encoding.c.o CMakeFiles/cmcurl.dir/cookie.c.o CMakeFiles/cmcurl.dir/dict.c.o CMakeFiles/cmcurl.dir/easy.c.o CMakeFiles/cmcurl.dir/e", 0x1000)		 = 1969 0
read_nocancel(0x3, "es/cmcurl.dir/http_digest.c.o CMakeFiles/cmcurl.dir/http_negotiate.c.o CMakeFiles/cmcurl.dir/http_ntlm.c.o CMakeFiles/cmcurl.dir/if2ip.c.o CMakeFiles/cmcurl.dir/inet_ntop.c.o CMakeFiles/cmcurl.dir/inet_pton.c.o CMakeFiles/cmcurl.dir/krb4.c.o CMakeFiles/cmc", 0x1000)		 = 0 0
fstat64(0x1, 0x7FFF67B0F7D8, 0x7FFF67B0F89C)		 = 0 0
ioctl(0x1, 0x4004667A, 0x7FFF67B0F874)		 = 0 0
write_nocancel(0x1, "/usr/bin/ar cr libcmcurl.a  CMakeFiles/cmcurl.dir/base64.c.o CMakeFiles/cmcurl.dir/connect.c.o CMakeFiles/cmcurl.dir/content_encoding.c.o CMakeFiles/cmcurl.dir/cookie.c.o CMakeFiles/cmcurl.dir/dict.c.o CMakeFiles/cmcurl.dir/easy.c.o CMakeFiles/cmcurl.dir/e", 0x400)		 = 1024 0
pipe(0x7FFF67B0F630, 0x0, 0xA8)		 = 4 0

At this point this is as far as I have been able to investigate, since I'm unfamiliar with the CMake internals.

Change History (3)

comment:1 Changed 12 years ago by mf2k (Frank Schima)

Owner: changed from macports-tickets@… to css@…

In the future, please Cc the port maintainer(s).

comment:2 in reply to:  1 Changed 12 years ago by acmorrow (Andrew C. Morrow)

Replying to macsforever2000@…:

In the future, please Cc the port maintainer(s).

Will do. You can also close this ticket. I figured out how to get past where I was stuck debugging and it appears that CMake is in the right, and something else is misbehaving.

comment:3 Changed 12 years ago by mf2k (Frank Schima)

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.