FortranCInterface: Add support for LLVMFlang mangling

The following `module.f90` file

    module mymodule
    contains
      subroutine mysub()
      end subroutine
    end module

when compiled with `flang-new` (from LLVM 15.0.0) generate the
`_QMmymodulePmysub` symbol.

    $ flang-new -c module.f90
    $ nm module.o
    0000000000000000 T _QMmymodulePmysub

This commit fixes the regular expressions accordingly.
This commit is contained in:
Gilles Gouaillardet
2022-09-09 23:23:30 +09:00
committed by Brad King
parent a2f9e674bb
commit 0f5b6dd215
2 changed files with 5 additions and 3 deletions

View File

@@ -43,6 +43,8 @@ set(module_symbols
MYMODULE_mp_MYSUB # Intel on Windows
mymodule_mysub_ # PGI
mymodule_MP_mysub # NAG
_QMmy_modulePmy_sub # LLVMFlang
_QMmymodulePmysub # LLVMFlang
${FortranCInterface_MODULE_SYMBOLS}
)
list(REMOVE_DUPLICATES module_symbols)

View File

@@ -95,8 +95,8 @@ set(_case_MYSUB "UPPER")
set(_case_MY_SUB "UPPER")
set(_global_regex "^(_*)(mysub|MYSUB)([_$]*)$")
set(_global__regex "^(_*)(my_sub|MY_SUB)([_$]*)$")
set(_module_regex "^(_*)(mymodule|MYMODULE)([A-Za-z_$]*)(mysub|MYSUB)([_$]*)$")
set(_module__regex "^(_*)(my_module|MY_MODULE)([A-Za-z_$]*)(my_sub|MY_SUB)([_$]*)$")
set(_module_regex "^(_*)([A-Za-z$]*)(mymodule|MYMODULE)([A-Za-z_$]*)(mysub|MYSUB)([_$]*)$")
set(_module__regex "^(_*)([A-Za-z$]*)(my_module|MY_MODULE)([A-Za-z_$]*)(my_sub|MY_SUB)([_$]*)$")
# Parse the symbol names.
foreach(symbol ${FortranCInterface_SYMBOLS})
@@ -115,7 +115,7 @@ foreach(symbol ${FortranCInterface_SYMBOLS})
# Look for module symbols.
string(REGEX REPLACE "${_module_${form}regex}"
"\\1;\\2;\\3;\\4;\\5" pieces "${symbol}")
"\\1\\2;\\3;\\4;\\5;\\6" pieces "${symbol}")
list(LENGTH pieces len)
if(len EQUAL 5)
set(FortranCInterface_MODULE_${form}SYMBOL "${symbol}")