From d0203fb567cafc97138cff1128f78cb41203ceef Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 24 Mar 2011 16:06:58 -0400 Subject: 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. --- Modules/FortranCInterface/CMakeLists.txt | 13 ++++++++++++- Modules/FortranCInterface/my_module_.c | 7 ------- Modules/FortranCInterface/mymodule_.c | 7 ------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt index 4bcaae9..d35a72c 100644 --- a/Modules/FortranCInterface/CMakeLists.txt +++ b/Modules/FortranCInterface/CMakeLists.txt @@ -70,6 +70,17 @@ else() endif() # 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) # Skip symbols with '$' if C cannot handle them. if(C_SUPPORTS_DOLLAR OR NOT "${symbol}" MATCHES "\\$") @@ -89,7 +100,7 @@ endforeach() add_library(myfort STATIC mysub.f my_sub.f ${myfort_modules}) # 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) # Require symbols through Fortran. diff --git a/Modules/FortranCInterface/my_module_.c b/Modules/FortranCInterface/my_module_.c index 364b214..6510ae9 100644 --- a/Modules/FortranCInterface/my_module_.c +++ b/Modules/FortranCInterface/my_module_.c @@ -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) {} -#endif diff --git a/Modules/FortranCInterface/mymodule_.c b/Modules/FortranCInterface/mymodule_.c index b5feda6..5270605 100644 --- a/Modules/FortranCInterface/mymodule_.c +++ b/Modules/FortranCInterface/mymodule_.c @@ -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) {} -#endif -- cgit v0.12