flang icon indicating copy to clipboard operation
flang copied to clipboard

DLLEXPORT issue

Open isuruf opened this issue 7 years ago • 0 comments

I have an issue with the module files and dllimports. Whenever I compile a fortran file that use the ieee_arithmetic module, I get a linker error in windows. For eg. error LNK2019: unresolved external symbol _ieee_arithmetic_8_ referenced in function check_mod_ieeecheckcasesr4_. This is because _ieee_arithmetic_8_ is declared as external global instead of external dllimport global in the LLVM IR file generated by flang2. If I edit the IR, then the unresolved symbol issue goes away.

flang doesn't know when to use dllimport and should be told what to do. So, I looked at ieee_arithmetic.f95 and it has

#ifdef PGDLL
!DEC$ ATTRIBUTES DLLEXPORT :: IEEE_ARITHMETIC
#endif

PGDLL is not defined in windows. So, I tried defining it. Then I get errors. error: use of undefined value @__imp__ieee_arithmetic_8__ seems to be because when ieee_arithmetic module is used, it's not marked as an impsym. So, flang needs to be updated so that for modules having DLLEXPORT, these variables are marked as an import symbol (equivalent to DLLIMPORT) when the module is used.

isuruf avatar Nov 29 '17 18:11 isuruf