FortranCInterface: Fix mangling detection with Cray Fortran >= 7.3.2

The Cray Fortran compiler started using module init symbols in version 7.3.2.
Starting in commit 71287734 (Teach FortranC interface for Intel, PGI, and gcc
4.2, 2009-08-05) we provide C versions of the module init symbols so that the
detection executable can link when the C versions of the module-mangled symbols
are picked up.

If no C module-mangled symbol matches then we cannot let the C module init
symbol appear because it will be duplicated by the Fortran copy that provides
the module-mangled symbol.  This was first handled for the PathScale compiler
in commit 21faaa5d (FortranCInterface: Fix PathScale detection, 2010-01-22) and
commit 46858720 (FortranCInterface: Fix PathScale detection again, 2010-02-16).
Handle it now for the Cray compiler too.
This commit is contained in:
Brad King 2011-03-24 16:06:58 -04:00
parent 09d1c1080d
commit d0203fb567
3 changed files with 12 additions and 15 deletions

View File

@ -70,6 +70,17 @@ else()
endif() endif()
# Generate C symbol sources. # Generate C symbol sources.
set(symbol_sources)
if(NOT "${CMAKE_Fortran_COMPILER_ID}" MATCHES "^(PathScale|Cray)$")
# Provide mymodule_ and my_module_ init symbols because:
# - PGI Fortran uses module init symbols
# but not for:
# - PathScale Fortran uses module init symbols but module symbols
# use '.in.' so we cannot provide them anyway.
# - Cray Fortran >= 7.3.2 uses module init symbols but module symbols
# use 'mysub$mymodule_' so we cannot provide them anyway.
list(APPEND symbol_sources mymodule_.c my_module_.c)
endif()
foreach(symbol IN LISTS global_symbols module_symbols) foreach(symbol IN LISTS global_symbols module_symbols)
# Skip symbols with '$' if C cannot handle them. # Skip symbols with '$' if C cannot handle them.
if(C_SUPPORTS_DOLLAR OR NOT "${symbol}" MATCHES "\\$") if(C_SUPPORTS_DOLLAR OR NOT "${symbol}" MATCHES "\\$")
@ -89,7 +100,7 @@ endforeach()
add_library(myfort STATIC mysub.f my_sub.f ${myfort_modules}) add_library(myfort STATIC mysub.f my_sub.f ${myfort_modules})
# Provide symbols through C but fall back to Fortran. # Provide symbols through C but fall back to Fortran.
add_library(symbols STATIC mymodule_.c my_module_.c ${symbol_sources}) add_library(symbols STATIC ${symbol_sources})
target_link_libraries(symbols myfort) target_link_libraries(symbols myfort)
# Require symbols through Fortran. # Require symbols through Fortran.

View File

@ -1,8 +1 @@
#if defined(__PATHSCALE__)
/* PathScale Fortran wants my_module_ when calling any my_module symbol,
but module symbols use '.in.' so we cannot provide them anyway. */
void pathscale_my_module_(void) {}
#else
/* PGI Fortran wants my_module_ when calling any my_module symbol. */
void my_module_(void) {} void my_module_(void) {}
#endif

View File

@ -1,8 +1 @@
#if defined(__PATHSCALE__)
/* PathScale Fortran wants mymodule_ when calling any mymodule symbol,
but module symbols use '.in.' so we cannot provide them anyway. */
void pathscale_mymodule_(void) {}
#else
/* PGI Fortran wants mymodule_ when calling any mymodule symbol. */
void mymodule_(void) {} void mymodule_(void) {}
#endif