Opened 9 years ago

Closed 9 years ago

Last modified 6 years ago

#48331 closed defect (fixed)

x265 fails to install due to CMAKE_CXX_COMPILER_ID being unset

Reported by: jeremyhu (Jeremy Huddleston Sequoia) Owned by: ryandesign (Ryan Carsten Schmidt)
Priority: Normal Milestone:
Component: ports Version: 2.3.3
Keywords: Cc: dbevans (David B. Evans), cssdev, ays388@…, michaelld (Michael Dickens)
Port: cmake

Description

$ sudo port -v -s upgrade ffmpeg
--->  Computing dependencies for x265.
--->  Configuring x265
-- cmake version 3.2.3
-- Detected x86 target processor
-- Could NOT find NUMA (missing:  NUMA_ROOT_DIR NUMA_INCLUDE_DIR NUMA_LIBRARY) 
CMake Error at CMakeLists.txt:101 (if):
  if given arguments:

    "STREQUAL" "Clang"

  Unknown arguments specified


-- Configuring incomplete, errors occurred!
See also "/opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_multimedia_x265/x265/work/build/CMakeFiles/CMakeOutput.log".
See also "/opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_multimedia_x265/x265/work/build/CMakeFiles/CMakeError.log".
Command failed:  cd "/opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_multimedia_x265/x265/work/build" && /opt/local/bin/cmake -DCMAKE_INSTALL_PREFIX=/opt/local -DCMAKE_OSX_ARCHITECTURES="x86_64;i386" -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_COLOR_MAKEFILE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_WITH_INSTALL_RPATH=ON -DCMAKE_INSTALL_RPATH=/opt/local/lib -DCMAKE_INSTALL_NAME_DIR=/opt/local/lib -DCMAKE_SYSTEM_PREFIX_PATH="/opt/local;/usr" -DCMAKE_MODULE_PATH=/opt/local/share/cmake/Modules -DCMAKE_FIND_FRAMEWORK=LAST -Wno-dev -DCMAKE_C_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_CXX_FLAGS_RELEASE="-DNDEBUG" -DCMAKE_OSX_DEPLOYMENT_TARGET="10.5" -DCMAKE_OSX_SYSROOT="/" /opt/local/var/macports/build/_Users_jeremy_src_macports_trunk_dports_multimedia_x265/x265/work/x265_1.7/source 
Exit code: 1
Error: Failed to configure x265: configure failure: command execution failed
Error: See /opt/local/var/macports/logs/_Users_jeremy_src_macports_trunk_dports_multimedia_x265/x265/main.log for details.
Error: Problem while installing x265
Error: Follow http://guide.macports.org/#project.tickets to report a bug.

CMakeLists.txt is doing:

if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
    set(CLANG 1)
endif()

So it seems that cmake isn't setting CMAKE_CXX_COMPILER_ID for some reason.

This was seen on Leopard using:

default_compilers  macports-clang-3.4 macports-clang-3.3 gcc-4.2 apple-gcc-4.2 gcc-4.0
cxx_stdlib         libstdc++
delete_la_files    yes

And it was also seen on Yosemite with Xcode 7. I suspect cmake is perhaps failing to parse --version output for some reason. Eg for the Leopard case:

$ /opt/local/bin/clang++-mp-3.4 --version
clang version 3.4.2 (tags/RELEASE_34/dot2-final)
Target: x86_64-apple-darwin9.8.0
Thread model: posix

Attachments (5)

CMakeError.log (1.2 KB) - added by jeremyhu (Jeremy Huddleston Sequoia) 9 years ago.
CMakeError.log
CMakeOutput.log (8.3 KB) - added by jeremyhu (Jeremy Huddleston Sequoia) 9 years ago.
CMakeOutput.log
cmake.diff (1.2 KB) - added by ryandesign (Ryan Carsten Schmidt) 9 years ago.
patch-Modules-CMakeDetermineCompilerId.cmake.release.diff (660 bytes) - added by ryandesign (Ryan Carsten Schmidt) 9 years ago.
patch-Modules-CMakeDetermineCompilerId.cmake.devel.diff (660 bytes) - added by ryandesign (Ryan Carsten Schmidt) 9 years ago.

Download all attachments as: .zip

Change History (13)

Changed 9 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Attachment: CMakeError.log added

CMakeError.log

Changed 9 years ago by jeremyhu (Jeremy Huddleston Sequoia)

Attachment: CMakeOutput.log added

CMakeOutput.log

comment:1 Changed 9 years ago by jeremyhu (Jeremy Huddleston Sequoia)

~/src/macports/dports/multimedia/x265/work/build/CMakeFiles/3.2.3/CompilerIdC $ strings a.out 
INFO:compiler[Clang]
INFO:platform[Darwin]
INFO:arch[]
INFO:compiler_version[00000003.00000004.00000002]

~/src/macports/dports/multimedia/x265/work/build/CMakeFiles/3.2.3/CompilerIdCXX $ strings CMakeCXXCompilerId.o 
INFO:compiler[Clang]
INFO:platform[Darwin]
INFO:arch[]
INFO:compiler_version[00000003.00000004.00000002]

comment:2 Changed 9 years ago by dbevans (David B. Evans)

Cc: ays388@… added

add x265 maintainer for information

comment:3 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesign@… added

Cc Me!

comment:4 Changed 9 years ago by MaddTheSane (C.W. Betts)

I was able to get it to compile only as an x86_64 library, not as a universal one.

Using Xcode 6.4 and Yosemite.

comment:5 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

I have reported this problem to the cmake-developers mailing list. Reproducing the relevant parts of my message here:

I found that in CMakeDetermineCompilerId.cmake, cmake compiles a test program (CMAKE_DETERMINE_COMPILER_ID_BUILD) which defines certain strings that describe the compiler, and then examines the strings in the compiled a.out file (CMAKE_DETERMINE_COMPILER_ID_CHECK). If the file contains more than one "INFO:compiler[...]" string, cmake assumes something went wrong and sets COMPILER_ID_TWICE to 1 which causes the compiler id to be forgotten.

The problem is that when building universal, the a.out file produced by the test will contain multiple copies of the strings -- once for each architecture. What the compiler does for you when you use multiple -arch flags is to compile the file separately, once for each architecture, then glue the separate files together into a single file (using the lipo program), so naturally such a file will contain multiple copies of any strings. This is not a bug; this is how universal binaries work. The bug is that cmake considers this valid condition to be erroneous.

Here is an example of the duplicated strings:

$ lipo -info build/CMakeFiles/3.3.2/CompilerIdC/a.out 
Architectures in the fat file: work/build/CMakeFiles/3.3.2/CompilerIdC/a.out are: x86_64 i386
$ strings -arch all build/CMakeFiles/3.3.2/CompilerIdC/a.out 
INFO:compiler[AppleClang]
INFO:platform[Darwin]
INFO:arch[]
INFO:compiler_version[00000007.00000000.00000000.07000072]
INFO:compiler[AppleClang]
INFO:platform[Darwin]
INFO:arch[]
INFO:compiler_version[00000007.00000000.00000000.07000072]

(I know cmake uses its internal FILE(STRINGS) command, not the strings program, but I presume they are similar.)

I was able to get cmake to correctly identify the compilers even when building universal by simply removing the COMPILER_ID_TWICE stuff from CMakeDetermineCompilerId.cmake, but perhaps you want something more elegant that verifies that if there are multiple definitions of a particular info line, all the definitions are the same.

Before making such a change to the cmake port, I'll wait and see if the developers have a better suggestion.

Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Attachment: cmake.diff added

Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

comment:6 in reply to:  5 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: michaelld@… added; ryandesign@… removed
Owner: changed from michaelld@… to ryandesign@…
Status: newassigned

Replying to ryandesign@…:

I'll wait and see if the developers have a better suggestion.

They pointed out that it's our bug, because we're passing -arch flags in CFLAGS, CXXFLAGS, and LDFLAGS, which cmake doesn't want us to. (cmake wants us to set CMAKE_OSX_ARCHITECTURES instead, which we already do.) I'm working on fixing the cmake portgroup to not set those variables.

comment:7 Changed 9 years ago by ryandesign (Ryan Carsten Schmidt)

Resolution: fixed
Status: assignedclosed

r143801 fixes this. I am fairly sure I've done this correctly, plus I've been running with it on my system for 3 months with no ill effects.

comment:8 in reply to:  7 Changed 6 years ago by jmroot (Joshua Root)

Follow-up in #56637.

Note: See TracTickets for help on using tickets.