MantisBT - CMake
View Issue Details
0012428CMakeCMakepublic2011-08-28 15:002016-06-10 14:31
don la dieu 
Kitware Robot 
normalminoralways
closedmoved 
LinuxUbuntu 11.04
CMake 2.8.5 
 
0012428: PathScale compiler support isn't multiarch aware
Running CMake on a Debian multiarch system (Ubuntu 11.04 (Natty)) fails when trying to find multiarched packages. Using the system gcc works fine.

Seems to work fine on cmake 2.8.3
On a multiarch system:
1) install cmake 2.8.5
2) install PathScale ekopath nightly build
3) find_package() a multiarch package (like zlib)
[maru:~/i3/offline-software/ebuild/z] rm CMakeCache.txt; PATH=/opt/ekopath-4.0.11/bin:${PATH} CC=pathcc CXX=pathCC FC=pathf90 cmake .
-- The C compiler identification is PathScale
-- The CXX compiler identification is PathScale
-- Check for working C compiler: /opt/ekopath-4.0.11/bin/pathcc
-- Check for working C compiler: /opt/ekopath-4.0.11/bin/pathcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/ekopath-4.0.11/bin/pathCC
-- Check for working CXX compiler: /opt/ekopath-4.0.11/bin/pathCC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done

-- CMAKE_SYSTEM_NAME = Linux
-- CMAKE_SYSTEM_VERSION = 2.6.38-11-generic
-- CMAKE_SYSTEM_PROCESSOR = x86_64
-- CMAKE_COMMAND = /usr/bin/cmake
-- CMAKE_VERSION = 2.8.3

-- zlib.h found at /usr/include
-- /usr/lib/x86_64-linux-gnu/libz.so

-- Configuring done
-- Generating done
-- Build files have been written to: /home/nega/i3/offline-software/ebuild/z


[maru:~/i3/offline-software/ebuild/z] rm CMakeCache.txt; PATH=/opt/ekopath-4.0.11/bin:${PATH} CC=pathcc CXX=pathCC FC=pathf90 /opt/cmake/bin/cmake .
-- The C compiler identification is PathScale
-- The CXX compiler identification is PathScale
-- Check for working C compiler: /opt/ekopath-4.0.11/bin/pathcc
-- Check for working C compiler: /opt/ekopath-4.0.11/bin/pathcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler: /opt/ekopath-4.0.11/bin/pathCC
-- Check for working CXX compiler: /opt/ekopath-4.0.11/bin/pathCC -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done

-- CMAKE_SYSTEM_NAME = Linux
-- CMAKE_SYSTEM_VERSION = 2.6.38-11-generic
-- CMAKE_SYSTEM_PROCESSOR = x86_64
-- CMAKE_COMMAND = /opt/cmake/bin/cmake
-- CMAKE_VERSION = 2.8.5
CMake Error at /opt/cmake/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
  Could NOT find ZLIB (missing: ZLIB_LIBRARY) (found version "1.2.3.4")
Call Stack (most recent call first):
  /opt/cmake/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
  /opt/cmake/share/cmake-2.8/Modules/FindZLIB.cmake:70 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:14 (find_package)


-- Configuring incomplete, errors occurred!
No tags attached.
related to 0012037closed Brad King support multiarch lib paths for Debian/Ubuntu 
txt CMakeLists.txt (619) 2011-08-28 15:00
https://public.kitware.com/Bug/file/4029/CMakeLists.txt
txt CMakeCache.txt (10,890) 2011-08-28 15:01
https://public.kitware.com/Bug/file/4030/CMakeCache.txt
? CMakeCCompiler.cmake (1,348) 2011-08-29 12:35
https://public.kitware.com/Bug/file/4032/CMakeCCompiler.cmake
? CMakeCXXCompiler.cmake (1,515) 2011-08-29 12:36
https://public.kitware.com/Bug/file/4033/CMakeCXXCompiler.cmake
diff ubuntu_multiarch_library_directory.diff (1,229) 2011-08-29 12:46
https://public.kitware.com/Bug/file/4034/ubuntu_multiarch_library_directory.diff
log CMakeOutput.log (12,848) 2011-08-29 13:13
https://public.kitware.com/Bug/file/4035/CMakeOutput.log
Issue History
2011-08-28 15:00don la dieuNew Issue
2011-08-28 15:00don la dieuFile Added: CMakeLists.txt
2011-08-28 15:01don la dieuFile Added: CMakeCache.txt
2011-08-28 15:10don la dieuNote Added: 0027279
2011-08-29 10:08Brad KingNote Added: 0027281
2011-08-29 12:35don la dieuFile Added: CMakeCCompiler.cmake
2011-08-29 12:36don la dieuFile Added: CMakeCXXCompiler.cmake
2011-08-29 12:39don la dieuNote Added: 0027283
2011-08-29 12:46don la dieuFile Added: ubuntu_multiarch_library_directory.diff
2011-08-29 12:48don la dieuNote Added: 0027284
2011-08-29 12:53Brad KingNote Added: 0027286
2011-08-29 13:13don la dieuFile Added: CMakeOutput.log
2011-08-29 13:15don la dieuNote Added: 0027288
2011-08-29 13:25Brad KingNote Added: 0027290
2011-08-29 15:15don la dieuNote Added: 0027291
2011-08-29 15:17don la dieuNote Added: 0027292
2011-08-29 15:24Brad KingNote Added: 0027294
2011-08-29 15:26Brad KingRelationship addedrelated to 0012037
2011-08-29 16:58don la dieuNote Added: 0027298
2011-08-29 17:04Brad KingNote Added: 0027299
2011-08-29 20:21don la dieuNote Added: 0027300
2012-08-11 21:09David ColeStatusnew => backlog
2012-08-11 21:09David ColeNote Added: 0030341
2012-10-25 16:32don la dieuNote Added: 0031332
2012-10-25 16:47Brad KingNote Added: 0031335
2016-06-10 14:28Kitware RobotNote Added: 0041896
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0027279)
don la dieu   
2011-08-28 15:10   
Mistaken about 2.8.3. I was using the system version of cmake. A clean 2.8.3 fails in the same way.
(0027281)
Brad King   
2011-08-29 10:08   
Multiarch support was added in 2.8.5, so any earlier version will fail on all compilers.

CMake uses this regex to detect the architecture triplet from the list of implicit link directories detected from the compiler:

  http://cmake.org/gitweb?p=cmake.git;a=blob;f=Modules/Platform/Linux.cmake;hb=v2.8.5#l48 [^]

  SET(CMAKE_LIBRARY_ARCHITECTURE_REGEX "[a-z0-9_]+(-[a-z0-9_]+)?-linux-gnu[a-z0-9_]*")

Please post the CMakeFiles/CMake*Compiler.cmake files from the build tree too. They contain the detected implicit link directories, if any.
(0027283)
don la dieu   
2011-08-29 12:39   
The CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES are set to "/opt/ekopath-4.0.11/lib/4.0.11/x8664/64"
(0027284)
don la dieu   
2011-08-29 12:48   
FWIW I included Ubuntu's multiarch path patch to 2.8.3. Unfortunatly the call to dpkg-architecture limits its utility.
(0027286)
Brad King   
2011-08-29 12:53   
Re 0012428:0027283: That implicit link directory list does not include any multiarch directories. That's why CMake doesn't detect the library architecture triplet.

Please also attach the CMakeOutput.log and CMakeError.log from the CMakeFiles directory. They should contain more information about the implicit link directory detection process.
(0027288)
don la dieu   
2011-08-29 13:15   
There's no CMakeFiles/CMakeError.log with that example project
(0027290)
Brad King   
2011-08-29 13:25   
The log file shows that CMake correctly found the link line:

/usr/bin/ld --hash-style=gnu --eh-frame-hdr -demangle -v --dynamic-linker=/lib64/ld-linux-x86-64.so.2 -rpath /opt/ekopath-4.0.11/lib/4.0.11/x8664/64 -melf_x86_64 -L/opt/ekopath-4.0.11/lib/4.0.11/x8664/64 -o cmTryCompileExec /usr/lib/crt1.o /usr/lib/crti.o /opt/ekopath-4.0.11/lib/4.0.11/x8664/64/crtbegin.o CMakeFiles/cmTryCompileExec.dir/CMakeCXXCompilerABI.cpp.o -lstl -lcxxrt -lpthread -ldl -lm -lgcc -leh -lc /opt/ekopath-4.0.11/lib/4.0.11/x8664/64/crtend.o /usr/lib/crtn.o -lpscrt -lmv -lmpath -lc

and parsed it. However the line does not contain any system directories like /usr/lib or /usr/lib/<arch>. I wonder how the compiler convinces the linker to find such system libraries. What is in /opt/ekopath-4.0.11/lib/4.0.11/x8664?

Do you know any way to convince this toolchain to report the library architecture directories like /usr/lib/<arch>? Does the compiler itself support multiarch?
(0027291)
don la dieu   
2011-08-29 15:15   
GNU binutils has the system directories compiled into it. pathcc relies on that behavior. gcc passes the system directories as a convenience so that you can drop in other linkers that are "command line compatible".
(0027292)
don la dieu   
2011-08-29 15:17   
[maru:~] PATH=/opt/ekopath-4.0.11/bin pathcc -print-search-dirs
install: /opt/ekopath-4.0.11
programs: /opt/ekopath-4.0.11/bin:/opt/ekopath-4.0.11/lib/4.0.11/x8664
libraries: /opt/ekopath-4.0.11/lib/4.0.11/x8664/64:/lib64:/usr/lib64
(0027294)
Brad King   
2011-08-29 15:24   
Re 0012428:0027291: That is good to know, thanks.

Re 0012428:0027292: I don't see the architecture triplet anywhere in those paths :(

Does binutils provide a standard way to get the triplet? How is anyone supposed to know where to install things if there is no easy way to get the triplet?
(0027298)
don la dieu   
2011-08-29 16:58   
No, as multiarch is unrelated to binutils, gcc and GNU in general. It's a packaging standard for Debian (and derivitives) that was partly derived from how gcc handled its internal layout for dealing with cross-compilers. All the gory details are here: http://wiki.debian.org/Multiarch. [^]

On a multiarch aware system the triplet can be retrieved with dpkg-architecture.

[maru:~] dpkg-architecture -qDEB_HOST_MULTIARCH
x86_64-linux-gnu

When bundling .deb's of libraries, this is take care of by debhelper (I think. I only glanced at that part of the docs.)

Since this is really a Debian (and derivitives) issue, maybe a patch similar to the Ubuntu one I provided is the way to go. Or, test this at configure/build time of cmake itself.
(0027299)
Brad King   
2011-08-29 17:04   
See the discussion in 0012037. The dpkg-architecture tool might not be available. Also, if the compilation targets a different architecture than the host then the answer it dpkg-architecture provides is wrong.

We need to detect the triplet from the toolchain for its target architecture. GCC provides a way to do it. We need to find a way to do it with PathScale too.
(0027300)
don la dieu   
2011-08-29 20:21   
Ah! Of course. I was just focused on $host == $target. Anything else would obviously break. I'll poke a bit harder at it, though I might not be able to for a few days.
(0030341)
David Cole   
2012-08-11 21:09   
Sending old, never assigned issues to the backlog.

(The age of the bug, plus the fact that it's never been assigned to anyone means that nobody is actively working on it...)

If an issue you care about is sent to the backlog when you feel it should have been addressed in a different manner, please bring it up on the CMake mailing list for discussion. Sign up for the mailing list here, if you're not already on it: http://www.cmake.org/mailman/listinfo/cmake [^]

It's easy to re-activate a bug here if you can find a CMake developer who has the bandwidth to take it on, and ferry a fix through to our 'next' branch for dashboard testing.
(0031332)
don la dieu   
2012-10-25 16:32   
Hacky, but it gets the job done


--- CMake/Modules/CMakeParseImplicitLinkInfo.cmake 2011-08-31 12:30:44.000000000 -0400
+++ cmake-2.8.8/Modules/CMakeParseImplicitLinkInfo.cmake 2012-10-25 16:03:03.113455792 -0400
@@ -52,6 +52,14 @@
           string(REGEX REPLACE "^-L" "" dir "${arg}")
           list(APPEND implicit_dirs_tmp ${dir})
           set(log "${log} arg [${arg}] ==> dir [${dir}]\n")
+ ## pathscale on linux helper
+ elseif("${arg}" MATCHES "/crt1.o$")
+ string(REGEX REPLACE "/crt1.o$" "" dir "${arg}")
+ list(APPEND implicit_dirs_tmp ${dir})
+ set(log "${log} arg [${arg}] ==> dir [${dir}] PEWP\n")
+ string(REGEX REPLACE "^/usr" "" dir "${dir}")
+ list(APPEND implicit_dirs_tmp ${dir})
+ set(log "${log} arg [${arg}] ==> dir [${dir}] PEWP\n")
         elseif("${arg}" MATCHES "^-l[^:]")
           # Unix library.
           string(REGEX REPLACE "^-l" "" lib "${arg}")
(0031335)
Brad King   
2012-10-25 16:47   
Re 0012428:0031332: The crt1.o shown in your log line I extracted and reported in 0012428:0027290 does not sit in an architecture-triplet directory. How does this match help?

How do other projects detect the proper triplet for this compiler?
(0041896)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.