Notes |
|
(0032253)
|
Ben Lentz
|
2013-02-12 17:49
|
|
Thanks to the awesome dude over at perzl.org, he fixes this problem with (follow the $WHERE):
*** ./Modules/Platform/AIX.cmake Thu Nov 15 23:49:55 2012
--- ./Modules/Platform/AIX.cmake Thu Nov 15 23:50:18 2012
***************
*** 8,14 ****
# -Wl,-blibpath:/usr/lib:/lib whether RPATH support is on or not.
# When our own RPATH is to be added it may be inserted before the
# "always" paths.
! set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /usr/lib /lib)
# Files named "libfoo.a" may actually be shared libraries.
set_property(GLOBAL PROPERTY TARGET_ARCHIVES_MAY_BE_SHARED_LIBS 1)
--- 8,14 ----
# -Wl,-blibpath:/usr/lib:/lib whether RPATH support is on or not.
# When our own RPATH is to be added it may be inserted before the
# "always" paths.
! set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH $WHERE/lib /usr/lib /lib)
# Files named "libfoo.a" may actually be shared libraries.
set_property(GLOBAL PROPERTY TARGET_ARCHIVES_MAY_BE_SHARED_LIBS 1) |
|
|
(0032257)
|
Brad King
|
2013-02-13 12:47
|
|
Given this source file:
$ cat hello.cpp
#include <iostream>
int main() {
std::cout << "hello" << std::endl;
return 0;
}
what is the output of the commands:
$ g++ hello.cpp -v
$ ldd ./a.out
$ ./a.out
in the same environment where CMake fails to run.
Also, please provide a link to documentation of "$WHERE". |
|
|
(0032261)
|
Ben Lentz
|
2013-02-13 13:10
|
|
$ cat hello.cpp
#include <iostream>
int main() {
std::cout << "hello" << std::endl;
return 0;
}
$ g++ hello.cpp -v
Using built-in specs.
Target: powerpc-ibm-aix5.3.0.0
Configured with: ../configure --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=c,c++,java --prefix=/opt/freeware --enable-threads --enable-version-specific-runtime-libs --host=powerpc-ibm-aix5.3.0.0 --target=powerpc-ibm-aix5.3.0.0 --build=powerpc-ibm-aix5.3.0.0 --disable-libjava-multilib
Thread model: aix
gcc version 4.2.0
/opt/freeware/libexec/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/cc1plus -quiet -v -D_ALL_SOURCE hello.cpp -quiet -dumpbase hello.cpp -auxbase hello -version -o /tmp//ccVlCLLc.s
ignoring nonexistent directory "/usr/local/include"
ignoring nonexistent directory "/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/../../../../powerpc-ibm-aix5.3.0.0/include"
#include "..." search starts here:
#include <...> search starts here:
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/include/c++
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/include/c++/powerpc-ibm-aix5.3.0.0
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/include/c++/backward
/opt/freeware/include
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/include
/usr/include
End of search list.
GNU C++ version 4.2.0 (powerpc-ibm-aix5.3.0.0)
compiled by GNU C version 4.2.0.
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 1996167973c219369b345460d5c6f097
/usr/bin/as -u -mppc -o /tmp//cc0D0Vzw.o /tmp//ccVlCLLc.s
/opt/freeware/libexec/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/collect2 -bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect /lib/crt0.o -L/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0 -L/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/../../.. /tmp//cc0D0Vzw.o -lstdc++ -lm -lgcc_s /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc.a -lc -lgcc_s /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc.a
ld: 0711-224 WARNING: Duplicate symbol: .__divdi3
ld: 0711-224 WARNING: Duplicate symbol: .__moddi3
ld: 0711-224 WARNING: Duplicate symbol: .__udivdi3
ld: 0711-224 WARNING: Duplicate symbol: .__umoddi3
ld: 0711-224 WARNING: Duplicate symbol: .__udivmoddi4
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
$ ldd ./a.out
./a.out needs:
/usr/lib/libc.a(shr.o)
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libstdc++.a(libstdc++.so.6)
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_s.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)
$ ./a.out
hello |
|
|
(0032263)
|
Ben Lentz
|
2013-02-13 13:11
|
|
$WHERE is a reference to the --prefix location.
e.g.
./configure --prefix=/opt/local/cmake
then
set(CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH /opt/local/cmake/lib /usr/lib /lib) |
|
|
(0032266)
|
Brad King
|
2013-02-13 13:45
|
|
Thanks. However, I'd like to see the actual vendor documentation for $WHERE. Which part of the invoked toolchain understands and evaluates it?
I'd also like to understand why the hello-world executable links properly with the g++ compiler front-end but when the same front-end is invoked by CMake the behavior is different. Look for Source/CMakeFiles/cmake.dir/link.txt in the build tree, then "cd Source" in the build tree and run the command with "-v". Report the full command here along with the output. |
|
|
(0032270)
|
Ben Lentz
|
2013-02-13 14:57
|
|
$WHERE is a shell environment variable I made up. I'm not sure what vendor documentation you're asking about. I invented it. I use it as a replacement shell variable in my build scripts to pass to ./configure --prefix and the patch, when applied inline in the build script, will workaround the problem I'm having. |
|
|
(0032271)
|
Brad King
|
2013-02-13 15:09
|
|
|
|
(0032273)
|
Ben Lentz
|
2013-02-13 15:12
|
|
Yes, I was suggesting perhaps you pass the ./configure --prefix=<THIS> parameter onto the CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH.
I will follow your instructions and report back. Please give me a few minutes. |
|
|
(0032274)
|
Ben Lentz
|
2013-02-13 15:23
|
|
./Source/CMakeFiles/cmake.dir/link.txt
/usr/bin/g++ CMakeFiles/cmake.dir/cmakemain.cxx.o -o ../bin/cmake -Wl,-brtl,-bnoipath,-bexpall libCMakeLib.a kwsys/libcmsys.a ../Utilities/cmexpat/libcmexpat.a ../Utilities/cmlibarchive/libarchive/libcmlibarchive.a ../Utilities/cmbzip2/libcmbzip2.a ../Utilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/libcmcurl.a ../Utilities/cmzlib/libcmzlib.a -lld /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_eh.a /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_eh.a -Wl,-blibpath:/usr/lib:/lib
[blentz@optaix53ts /home/blentz/build/cmake-2.8.10.2/Source]$ /usr/bin/g++ CMakeFiles/cmake.dir/cmakemain.cxx.o -o ../bin/cmake -Wl,-brtl,-bnoipath,-bexpall libCMakeLib.a kwsys/libcmsys.a ../Utilities/cmexpat/libcmexpat.a ../Utilities/cmlibarchive/libarchive/libcmlibarchive.a ../Utilities/cmbzip2/libcmbzip2.a ../Utilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/libcmcurl.a ../Utilities/cmzlib/libcmzlib.a -lld /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_eh.a /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_eh.a -Wl,-blibpath:/usr/lib:/lib -v
Using built-in specs.
Target: powerpc-ibm-aix5.3.0.0
Configured with: ../configure --with-as=/usr/bin/as --with-ld=/usr/bin/ld --enable-languages=c,c++,java --prefix=/opt/freeware --enable-threads --enable-version-specific-runtime-libs --host=powerpc-ibm-aix5.3.0.0 --target=powerpc-ibm-aix5.3.0.0 --build=powerpc-ibm-aix5.3.0.0 --disable-libjava-multilib
Thread model: aix
gcc version 4.2.0
/opt/freeware/libexec/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/collect2 -bpT:0x10000000 -bpD:0x20000000 -btextro -bnodelcsect -o ../bin/cmake /lib/crt0.o -L/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0 -L/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/../../.. CMakeFiles/cmake.dir/cmakemain.cxx.o -brtl -bnoipath -bexpall libCMakeLib.a kwsys/libcmsys.a ../Utilities/cmexpat/libcmexpat.a ../Utilities/cmlibarchive/libarchive/libcmlibarchive.a ../Utilities/cmbzip2/libcmbzip2.a ../Utilities/cmcompress/libcmcompress.a ../Utilities/cmcurl/libcmcurl.a ../Utilities/cmzlib/libcmzlib.a -lld /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_eh.a /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_eh.a -blibpath:/usr/lib:/lib -lstdc++ -lm -lgcc_s /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc.a -lc -lgcc_s /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc.a
ld: 0711-224 WARNING: Duplicate symbol: .__udivdi3
ld: 0711-224 WARNING: Duplicate symbol: .__umoddi3
ld: 0711-224 WARNING: Duplicate symbol: .__divdi3
ld: 0711-224 WARNING: Duplicate symbol: .__moddi3
ld: 0711-224 WARNING: Duplicate symbol: .__udivmoddi4
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information. |
|
|
(0032275)
|
Ben Lentz
|
2013-02-13 15:24
|
|
make is successful in the Source directory.
make fails in the root directory with the following (the same as originally posted):
Target "Source/CMakeFiles/CTestLib.dir/build" is up to date.
[ 91%] Built target CTestLib
Target "Source/CMakeFiles/ccmake.dir/build" is up to date.
[ 94%] Built target ccmake
Target "Source/CMakeFiles/cmake.dir/build" is up to date.
[ 95%] Built target cmake
Target "Source/CMakeFiles/cpack.dir/build" is up to date.
[ 95%] Built target cpack
Target "Source/CMakeFiles/ctest.dir/build" is up to date.
[ 95%] Built target ctest
[ 96%] Generating ../Docs/ctest.txt
exec(): 0509-036 Cannot load program ../bin/ctest because of the following errors:
0509-150 Dependent module libstdc++.a(libstdc++.so.6) could not be loaded.
0509-022 Cannot load module libstdc++.a(libstdc++.so.6).
0509-026 System error: A file or directory in the path name does not exist.
make: 1254-004 The error code from the last command is 255.
Stop.
make: 1254-004 The error code from the last command is 2.
Stop.
make: 1254-004 The error code from the last command is 2.
Stop. |
|
|
(0032276)
|
Ben Lentz
|
2013-02-13 15:25
|
|
Somehow RPATH was dumped out when ctest was linked.
[blentz@optaix53ts /home/blentz/build/cmake-2.8.10.2]$ ldd bin/ctest
bin/ctest needs:
Cannot find libstdc++.a(libstdc++.so.6)
Cannot find libgcc_s.a(shr.o)
/usr/lib/libc.a(shr.o)
/usr/lib/librtl.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)
[blentz@optaix53ts /home/blentz/build/cmake-2.8.10.2]$ dump -H bin/ctest
bin/ctest:
***Loader Section***
Loader Header Information
VERSION# #SYMtableENT #RELOCent LENidSTR
0x00000001 0x000003fd 0x0000c088 0x0000005c
#IMPfilID OFFidSTR LENstrTBL OFFstrTBL
0x00000005 0x00096638 0x000052be 0x00096694
***Import File Strings***
INDEX PATH BASE MEMBER
0 /usr/lib:/lib
1 libstdc++.a libstdc++.so.6
2 libgcc_s.a shr.o
3 libc.a shr.o
4 librtl.a shr.o |
|
|
(0032277)
|
Brad King
|
2013-02-13 16:34
|
|
Okay, here is what is going on. From "man ld":
Options (-bOptions)
libpath:Path
Uses Path as the library path when writing the loader section of
the output file. Path is neither checked for validity nor used when
searching for libraries specified by the -l flag. Path overrides
any library paths generated when the -L flag is used.
If you do not specify any -L flags, or if you specify the nolibpath
option, the default library path information is written in the
loader section of the output file. The default library path
information is the value of the LIBPATH environment variable if it
is defined, and /usr/lib:/lib, otherwise.
CMake wants to avoid having all -L paths included in the library path loader section because:
- Often some -L directories belong to the build tree and should not end up in installed binaries
- CMake has its own interface for configuring RPATH entries which are implemented as libpath on AIX
Therefore CMake always passes -Wl,-blibpath:$something to set the libpath explicitly. It includes /usr/lib:/lib in $something because "man ld" says that is the normal default but may precede it by any RPATH directories specified by the project configuration. This is explained in the comment above CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH in AIX.cmake.
What breaks here is that the g++ compiler front-end passes -L paths to its runtime libraries like stdc++ when invoking the linker. When no -blibpath is specified then the linker adds those runtime library directories to the libpath in the binary so it can find them. That is why the hello.cpp example works. When CMake passes its explicit -blibpath:/usr/lib:/lib then it not only prevents the project's build tree paths from showing up but it also prevents the compiler front-end's implicit runtime library search paths from showing up too. That is why the CMake build breaks without LIBPATH in the environment.
CMake actually does detect the compiler front-end's implicit runtime library search paths. They are recorded in "CMakeFiles/<v>/CMake<lang>Compiler.cmake". For example, in a project with C, C++, and Fortran enabled and built with xlc/xlC/xlf I get:
$ grep IMPLICIT_LINK_DIRECTORIES CMakeFiles/*/CMake*Compiler.cmake
.../CMakeCCompiler.cmake:set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/usr/vac/lib")
.../CMakeCXXCompiler.cmake:set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/usr/vac/lib;/usr/vacpp/lib")
.../CMakeFortranCompiler.cmake:set(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "/usr/lpp/xlf/lib")
These are the paths that XL passes to the linker for its runtime libraries.
Potentially these could be added to the runtime path automatically in front of /usr/lib:/lib.
What do you get in these files in CMake's build tree with gcc? |
|
|
(0032278)
|
Ben Lentz
|
2013-02-13 16:53
|
|
Just for clarification's sake, this is IBM AIX 5.3 TL12 SP5 with GNU gcc 4.2.0 and *IBM's* ld linker. Some folks consider this a unique combination, as I think most folks on the AIX on POWER platform are using IBM's XL C/C++ compiler and IBM's AIX linker.
Personally I've found that most software compiles with less difficulty using gcc even on AIX POWER.
I will send you the information in one moment. |
|
|
(0032279)
|
Ben Lentz
|
2013-02-13 16:59
|
|
$ grep IMPLICIT_LINK_DIRECTORIES CMakeFiles/*/CMake*Compiler.cmake
CMakeFiles/2.8.10.2/CMakeCCompiler.cmake:set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0;/opt/freeware/lib")
CMakeFiles/2.8.10.2/CMakeCXXCompiler.cmake:set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0;/opt/freeware/lib")
These directories have copies of libstdc++.a and libgcc_s.a.
$ ldd bin/ctest
bin/ctest needs:
Cannot find libstdc++.a(libstdc++.so.6)
Cannot find libgcc_s.a(shr.o)
/usr/lib/libc.a(shr.o)
/usr/lib/librtl.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o)
$ ls -l /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libstdc++.a /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_s.a
-rw-r--r-- 1 root system 125958 Mar 25 2008 /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_s.a
-rwxr-xr-x 1 root system 3376733 Mar 25 2008 /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libstdc++.a |
|
|
(0032282)
|
Brad King
|
2013-02-14 10:34
|
|
Please test the attached patch series:
v2.8.10.2+0001-Avoid-duplicate-RPATH-entries.patch
v2.8.10.2+0002-AIX-GNU-Put-implicit-link-directories-in-runtime-lib.patch
on top of CMake 2.8.10.2. |
|
|
(0032286)
|
Ben Lentz
|
2013-02-14 12:12
|
|
It builds now with those two patches.
$ ldd /opt/local/cmake/bin/ctest
/opt/local/cmake/bin/ctest needs:
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libstdc++.a(libstdc++.so.6)
/opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_s.a(shr.o)
/usr/lib/libc.a(shr.o)
/usr/lib/librtl.a(shr.o)
/unix
/usr/lib/libcrypt.a(shr.o) |
|
|
(0032291)
|
Brad King
|
2013-02-15 13:16
|
|
|
|
(0033423)
|
Robert Maynard
|
2013-07-01 09:37
|
|
Closing resolved issues that have not been updated in more than 4 months. |
|