Notes |
|
(0034786)
|
Brad King
|
2013-12-18 11:13
|
|
As explained here:
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/8795/focus=8812 [^]
CMake converts libraries in implicit linker search paths to the "-lm" form.
The difference you see must be due to which directories are detected as implicitly passed to the linker by the compiler front-end. Look under the CMakeFiles/2.8.11.1 directory at the top of the build tree for "CMake*Compiler.cmake" files. Inside there are variables like CMAKE_C_IMPLICIT_LINK_DIRECTORIES. What are they for C and Fortran? |
|
|
(0034793)
|
Sean Patrick Santos
|
2013-12-18 12:56
|
|
Here are the IMPLICIT_LINK variables for a system where I found the same effect with 2.8.10.2.
This is not the same as the system where I originally found the issue, but this machine has simpler settings. Note that I'm working on HPC systems where these paths can be quite long.
set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "netcdf_c++;netcdff;netcdf;mpi;dl;pthread;rt;c")
set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/glade/apps/el6/usr/lib;/glade/apps/el6/usr/lib64;/glade/apps/opt/ncl/6.1.2/gnu/4.4.6/lib;/glade/apps/opt/netcdf/4.3.0/gnu/4.7.2/lib;/opt/ibmhpc/pecurrent/mpich2/gnu/lib64;/glade/u/apps/opt/gnu/4.7.2/lib/gcc/x86_64-unknown-linux-gnu/4.7.2;/glade/u/apps/opt/gnu/4.7.2/lib64;/lib64;/usr/lib64;/glade/u/apps/opt/gnu/4.7.2/lib")
set(CMAKE_Fortran_IMPLICIT_LINK_LIBRARIES "netcdf_c++;netcdff;netcdf;gfortran;m;quadmath;m;c")
set(CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES "/glade/apps/el6/usr/lib;/glade/apps/el6/usr/lib64;/glade/apps/opt/ncl/6.1.2/gnu/4.4.6/lib;/glade/apps/opt/netcdf/4.3.0/gnu/4.7.2/lib;/glade/u/apps/opt/gnu/4.7.2/lib/gcc/x86_64-unknown-linux-gnu/4.7.2;/glade/u/apps/opt/gnu/4.7.2/lib64;/lib64;/usr/lib64;/glade/u/apps/opt/gnu/4.7.2/lib")
Note that this actually shows up for multiple compilers, and even for a BlueGene system that I've checked, which was why I was inclined to think that there's something that's explicitly treating C and Fortran differently.
But in fact there are differences between some static libraries too, so I was wrong in thinking that this was a shared library issue originally. |
|
|
(0034799)
|
Brad King
|
2013-12-18 15:10
|
|
Re 0014647:0034793: Both the C and Fortran values you report list "/usr/lib64" so I would expect "/usr/lib64/libm.so" to become "-lm" in both cases. Does the difference occur in the build tree where you got these values? |
|
|
(0034800)
|
Sean Patrick Santos
|
2013-12-18 15:16
|
|
Yes, they are the same build tree. And in fact I see the same conditions repeating on other systems and with other libraries besides libm.
As far as I can tell, CMAKE_Fortran_IMPLICIT_LINK_DIRECTORIES does not cause *any* absolute library paths to be converted to "-l" options when linking with the Fortran compiler, at least in CMake 2.8.10 and 2.8.11. So maybe that is the real bug here. |
|
|
(0034802)
|
Brad King
|
2013-12-18 15:36
|
|
|
|
(0034804)
|
Brad King
|
2013-12-18 15:40
|
|
To test my hypothesis in 0014647:0034802, add this to your project code:
foreach(type SHARED_LIBRARY SHARED_MODULE EXE)
set(CMAKE_${type}_LINK_STATIC_Fortran_FLAGS "-Wl,-Bstatic")
set(CMAKE_${type}_LINK_DYNAMIC_Fortran_FLAGS "-Wl,-Bdynamic")
endforeach()
(with whatever are the proper flags). Does it make Fortran linking use the "-lm" form? |
|
|
(0034809)
|
Sean Patrick Santos
|
2013-12-18 16:04
|
|
|
|
(0034829)
|
Brad King
|
2013-12-19 14:18
|
|
Unfortunately I think there are several Fortran compilers that do not recognize the same options their C compiler uses (like -Wl,-Bstatic) for specifying the library search path. The flag mapping for this language will have to be added to the information file for each compiler/platform combo.
Moving to backlog for now.
|
|
|
(0042447)
|
Kitware Robot
|
2016-06-10 14:29
|
|
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. |
|