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

2014-06-24 Thread Mojca Miklavec
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/CMakcut

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 

Re: [cmake-developers] Unsupported -arch x86_64 mysteriously ends up in Fortran_FLAGS

2013-01-23 Thread Mojca Miklavec
On Wed, Jan 23, 2013 at 5:29 PM, Brad King wrote:
 On 01/22/2013 02:11 PM, Mojca Miklavec wrote:
 I realised that an unsupported compiler flag -arch x86_64
 mysteriously sneaks into Fortran_FLAGS when
 -DCMAKE_OSX_ARCHITECTURES=x86_64

 The -arch flag is hard-coded here:

  
 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v2.8.10.2#l1826

 It was added to CMake way back when universal binary support was
 first added to OS X under the assumption that all compilers that
 would be used in combination with CMAKE_OSX_ARCHITECTURES would
 support the flag.  Obviously the assumption is wrong.

True. Not even the original gcc compilers (without Apple's
modifications) support the -arch flag. MacPorts ship the original
gcc compilers and actually use them for a couple of ports. I'm not
100% sure, but some of the reasons include faster and more efficient
computations in physics simulations (apparently using the latest gcc
4.8 matters) or support for Fortran. So testing for Mac OS X and GCC
doesn't yet guarantee the existence of that flag.

 The hard-coded flag needs to be replaced with a lookup of a new
 per-language platform information variable, perhaps called

  CMAKE_LANG_OSX_ARCHITECTURE_FLAG

Thanks a lot for the answer.

Since you know the internals much better than I do: do I have to file
a bug report myself?

Thanks again,
Mojca
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers


[cmake-developers] Unsupported -arch x86_64 mysteriously ends up in Fortran_FLAGS

2013-01-22 Thread Mojca Miklavec
Dear CMake developers,

I'm a newbie to CMake (I've never written any project myself), but
while trying to install a physics package Root from the master of
https://github.com/bbannier/ROOT (https://root.cern.ch/svn/root/trunk)
I realised that an unsupported compiler flag -arch x86_64
mysteriously sneaks into Fortran_FLAGS when
-DCMAKE_OSX_ARCHITECTURES=x86_64
is passed to cmake. That flag CMAKE_OSX_ARCHITECTURES is added
automatically to all projects in MacPorts (third-party package manager
for Mac OS X) even when cross-compiling or compilation of fat binaries
(like i386+x86_64) is not needed.

The g95 compiler ignores -arch ... flag, but GCC's gfortran 4.x
throws an error and breaks compilation. I could probably try to
prevent DCMAKE_OSX_ARCHITECTURES from being passed to cmake (via some
tricks in MacPorts or by modifying MacPorts sources), but I still
believe that passing -arch x86_64 to Fortran_FLAGS is a bug in
CMake. I tried to figure out when those flags are set, but I don't
know enough about CMake. I've seen several places where compiler flags
are simply copied from C to Fortran, for example here:

# Create a set of shared library variable specific to Fortran
# For 90% of the systems, these are the same flags as the C versions
# so if these are not set just copy the flags from the c version
if(NOT DEFINED CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS)
  set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS
${CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS})
endif()

but I don't have enough knowledge to be able to track the problem down
to a single spot. There is a slight chance that the problematic flag
is introduced by the project, but there are other projects in MacPorts
suffering from the same symptoms.


The command that I used to compile Root:

cmake \
-DCMAKE_Fortran_COMPILER=/opt/local/bin/gfortran-mp-4.5 \
-DCMAKE_C_COMPILER=/usr/bin/clang \
-DCMAKE_CXX_COMPILER=/usr/bin/clang++ \
-DCMAKE_INSTALL_PREFIX=/path/to/install \
-DCMAKE_OSX_ARCHITECTURES=x86_64 ../root_trunk

In case that anyone would want to try it on the particular project,
the generated file
misc/minicern/CMakeFiles/minicern.dir/flags.make
ends up containing the following variables (among others):
C_FLAGS =  -m64 -pipe -W -Wall -fsigned-char -fno-common -O2 -g
-arch x86_64 -fPIC -Ipath/to/some/include/dirs
Fortran_FLAGS =  -m64 -std=legacy -arch x86_64 -fPIC
-Ipath/to/some/include/dirs
(Another problem is that -std=legacy is not recognised by g95 and
throws another error, but that one is a bug in the project.) I also
didn't know how to disable Fortran compiler altogether, but that's a
completely different issue.

I'm using 64-bit Mac OS X 10.7.4, cmake version 2.8.10.

I would be very grateful for any insight about how to get rid of that
-arch x86_64 flag. Thanks and best regards,
Mojca

Related tickets:
- https://trac.macports.org/ticket/37732 (about the -arch flag in Fortran)
- https://trac.macports.org/ticket/37688 ([also] about development of
a package for Root using CMake)
- https://savannah.cern.ch/bugs/index.php?99944 (not strictly related though)
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/cgi-bin/mailman/listinfo/cmake-developers