MantisBT - CMake
View Issue Details
0014507CMakeCMakepublic2013-10-23 15:052016-05-16 09:25
Izaak Beekman 
Brad King 
normalminoralways
closedfixed 
Linux RHEL 5 X86_64RHEL 5RHEL 5
CMake 2.8.12 
CMake 3.0CMake 3.0 
0014507: -i_dynamic flag (depricated) incorrectly added when using intel compilers
See: http://www.cmake.org/pipermail/cmake/2009-March/028121.html [^]

The -i_dynamic flag is deprecated and not even listed in the intel man page for composer_xe 2013
Create a fortran project using the intel compilers as your compilers, then try to build a statically linked executable with the -static-intel flags.
Highly annoying. Should affect all platforms.
No tags attached.
Issue History
2013-10-23 15:05Izaak BeekmanNew Issue
2013-10-23 15:24Brad KingNote Added: 0034228
2013-10-23 15:25Brad KingNote Edited: 0034228bug_revision_view_page.php?bugnote_id=34228#r1299
2013-10-23 15:27Brad KingNote Added: 0034229
2013-10-23 18:52Izaak BeekmanNote Added: 0034230
2013-10-24 09:27Brad KingNote Added: 0034233
2013-10-24 09:37Brad KingNote Added: 0034234
2013-10-24 09:37Brad KingAssigned To => Brad King
2013-10-24 09:37Brad KingStatusnew => assigned
2013-10-24 09:37Brad KingTarget Version => CMake 3.0
2013-10-25 13:18Izaak BeekmanNote Added: 0034244
2013-10-25 14:58Brad KingNote Added: 0034246
2013-10-29 15:48Izaak BeekmanNote Added: 0034289
2013-10-29 15:50Brad KingStatusassigned => resolved
2013-10-29 15:50Brad KingResolutionopen => fixed
2013-10-29 15:50Brad KingFixed in Version => CMake 3.0
2014-03-05 09:58Robert MaynardNote Added: 0035302
2014-03-05 09:58Robert MaynardStatusresolved => closed

Notes
(0034228)
Brad King   
2013-10-23 15:24   
(edited on: 2013-10-23 15:25)
Is this patch sufficient?

diff --git a/Modules/Platform/Linux-Intel-Fortran.cmake b/Modules/Platform/Linux-Intel-Fortran.cmake
index bb671ee..0c9523c 100644
--- a/Modules/Platform/Linux-Intel-Fortran.cmake
+++ b/Modules/Platform/Linux-Intel-Fortran.cmake
@@ -1,4 +1,4 @@
 include(Platform/Linux-Intel)
 __linux_compiler_intel(Fortran)
-set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS} -i_dynamic -nofor_main")
-set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "-i_dynamic")
+set(CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS "${CMAKE_SHARED_LIBRARY_CREATE_Fortran_FLAGS} -nofor_main")
+set(CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS "")

(0034229)
Brad King   
2013-10-23 15:27   
FYI, only platform/compiler combinations for which someone contributes nightly testing submissions to our dashboard:

 http://open.cdash.org/index.php?project=CMake [^]

can be supported easily by upstream developers. Currently there is no submission for the Intel compilers on Linux. If you can run one please see instructions here:

 http://www.cmake.org/Wiki/CMake/Git/Dashboard [^]
(0034230)
Izaak Beekman   
2013-10-23 18:52   
I'm going to look into setting up a Linux Intel compiler dashboard submission.

As far as your first comment is concerned: Where are the fortran compile and link rules built up? Why is CMAKE_SHARED_LIBRARY_LINK_Fortran_FLAGS added when linking a Fortran executable? (I also seem to get some other spurious, although harmless -L flags).

I am trying to build a redistributable Linux binary, so static linking is crucial, but -i_dynamic prevents this.
(0034233)
Brad King   
2013-10-24 09:27   
Re 0014507:0034230: It would be great to have nightly testing for this compiler, thanks.

The CMAKE_SHARED_LIBRARY_LINK_<LANG>_FLAGS are used when creating a target that might link *to* a shared library. This is needed on some platforms to link executables to the shared runtime library, for example. CMake always passes this flag when linking an executable because it does not know if a -lfoo might find a shared library. This is historical.

Currently there is no first-class support for linking an executable statically. However, I know many people have gotten it working for local builds creating redistributable packages.
(0034234)
Brad King   
2013-10-24 09:37   
Meanwhile I've applied the patch from 0014507:0034228:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f61bcbce [^]
(0034244)
Izaak Beekman   
2013-10-25 13:18   
From digging around, it seems like -i_dynamic is equivalent to -shared-intel. I'm going to double check this on the Intel Forums. AFAIK, there is no need to request dynamic linking against the Intel runtime fortran library, even when compiling an executable binary that links against other dynamic libraries. It might make sense to do so for a MinSizeRel build, but I don't think this should be the default. I'm going to double check all of this with the folks at Intel and report back.
(0034246)
Brad King   
2013-10-25 14:58   
Re 0014507:0034244: Thanks. If it isn't needed for a basic build to work then we probably shouldn't add it by default at all. We have plenty of interfaces for users and project code to add flags when they want them.
(0034289)
Izaak Beekman   
2013-10-29 15:48   
Removing -i_dynamic is definitely the correct thing to do. Deprecated AND completely unnecessary.

Also noteworthy is that the compiler gives precedent to the rightmost options. I'm somewhat surprised that the options setup by CMake are added to the right of the user's options. This might be worth changing.
(0035302)
Robert Maynard   
2014-03-05 09:58   
Closing resolved issues that have not been updated in more than 4 months