flang icon indicating copy to clipboard operation
flang copied to clipboard

Windows: fixes

Open ghost opened this issue 7 years ago • 25 comments

ghost avatar Oct 25 '17 18:10 ghost

 Creating library ..\..\lib\flang.lib and object ..\..\lib\flang.exp
[00:07:40] mmulcplx16.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx16_str1_mxv_ referenced in function pgf90_matmul_cplx16
[00:07:40] mmulcplx16.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx16_str1_vxm_ referenced in function pgf90_matmul_cplx16
[00:07:40] mmulcplx16.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx16_str1_ referenced in function pgf90_matmul_cplx16
[00:07:40] mmulcplx16_t.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx16_str1_mxv_t_ referenced in function pgf90_matmul_cplx16mxv_t
[00:07:40] mmulcplx8.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx8_str1_mxv_ referenced in function pgf90_matmul_cplx8
[00:07:40] mmulcplx8.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx8_str1_vxm_ referenced in function pgf90_matmul_cplx8
[00:07:40] mmulcplx8.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx8_str1_ referenced in function pgf90_matmul_cplx8
[00:07:40] mmulcplx8_t.c.obj : error LNK2019: unresolved external symbol pg_mm_cplx8_str1_mxv_t_ referenced in function pgf90_matmul_cplx8mxv_t
[00:07:40] mmulint1.c.obj : error LNK2019: unresolved external symbol pg_mm_int1_str1_mxv_ referenced in function pgf90_matmul_int1
[00:07:40] mmulint1.c.obj : error LNK2019: unresolved external symbol pg_mm_int1_str1_vxm_ referenced in function pgf90_matmul_int1
[00:07:40] mmulint1.c.obj : error LNK2019: unresolved external symbol pg_mm_int1_str1_ referenced in function pgf90_matmul_int1
[00:07:40] mmulint2.c.obj : error LNK2019: unresolved external symbol pg_mm_int2_str1_mxv_ referenced in function pgf90_matmul_int2
[00:07:40] mmulint2.c.obj : error LNK2019: unresolved external symbol pg_mm_int2_str1_vxm_ referenced in function pgf90_matmul_int2
[00:07:40] mmulint2.c.obj : error LNK2019: unresolved external symbol pg_mm_int2_str1_ referenced in function pgf90_matmul_int2
[00:07:40] mmulint4.c.obj : error LNK2019: unresolved external symbol pg_mm_int4_str1_mxv_ referenced in function pgf90_matmul_int4
[00:07:40] mmulint4.c.obj : error LNK2019: unresolved external symbol pg_mm_int4_str1_vxm_ referenced in function pgf90_matmul_int4
[00:07:40] mmulint4.c.obj : error LNK2019: unresolved external symbol pg_mm_int4_str1_ referenced in function pgf90_matmul_int4
[00:07:40] mmulint8.c.obj : error LNK2019: unresolved external symbol pg_mm_int8_str1_mxv_ referenced in function pgf90_matmul_int8
[00:07:40] mmulint8.c.obj : error LNK2019: unresolved external symbol pg_mm_int8_str1_vxm_ referenced in function pgf90_matmul_int8
[00:07:40] mmulint8.c.obj : error LNK2019: unresolved external symbol pg_mm_int8_str1_ referenced in function pgf90_matmul_int8
[00:07:40] mmulreal4.c.obj : error LNK2019: unresolved external symbol pg_mm_real4_str1_mxv_ referenced in function pgf90_matmul_real4
[00:07:40] mmulreal4.c.obj : error LNK2019: unresolved external symbol pg_mm_real4_str1_vxm_ referenced in function pgf90_matmul_real4
[00:07:40] mmulreal4.c.obj : error LNK2019: unresolved external symbol pg_mm_real4_str1_ referenced in function pgf90_matmul_real4
[00:07:40] mmulreal4_t.c.obj : error LNK2019: unresolved external symbol pg_mm_real4_str1_mxv_t_ referenced in function pgf90_matmul_real4mxv_t
[00:07:40] mmulreal8.c.obj : error LNK2019: unresolved external symbol pg_mm_real8_str1_mxv_ referenced in function pgf90_matmul_real8
[00:07:40] mmulreal8.c.obj : error LNK2019: unresolved external symbol pg_mm_real8_str1_vxm_ referenced in function pgf90_matmul_real8
[00:07:40] mmulreal8.c.obj : error LNK2019: unresolved external symbol pg_mm_real8_str1_ referenced in function pgf90_matmul_real8
[00:07:40] mmulreal8_t.c.obj : error LNK2019: unresolved external symbol pg_mm_real8_str1_mxv_t_ referenced in function pgf90_matmul_real8mxv_t
[00:07:40] mtaxtb_cmplx16.F95.obj : error LNK2019: unresolved external symbol f90_alloc04_chk referenced in function ftn_mtaxtb_cmplx16_
[00:07:40] mtaxtb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mtaxtb_real4.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mtaxtb_real8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mtaxnb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mtaxnb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mtaxnb_real4.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mtaxnb_real8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxtb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxtb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxtb_real4.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxtb_real8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxnb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxnb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxnb_real4.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mnaxnb_real8.F95.obj : error LNK2001: unresolved external symbol f90_alloc04_chk
[00:07:40] mtaxtb_cmplx16.F95.obj : error LNK2019: unresolved external symbol f90_dealloc03 referenced in function ftn_mtaxtb_cmplx16_
[00:07:40] mtaxtb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mtaxtb_real4.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mtaxtb_real8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mtaxnb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mtaxnb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mtaxnb_real4.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mtaxnb_real8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxtb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxtb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxtb_real4.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxtb_real8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxnb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxnb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxnb_real4.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mnaxnb_real8.F95.obj : error LNK2001: unresolved external symbol f90_dealloc03
[00:07:40] mtaxtb_cmplx16.F95.obj : error LNK2019: unresolved external symbol f90_allocated referenced in function ftn_mtaxtb_cmplx16_
[00:07:40] mtaxtb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mtaxtb_real4.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mtaxtb_real8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mtaxnb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mtaxnb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mtaxnb_real4.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mtaxnb_real8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxtb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxtb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxtb_real4.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxtb_real8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxnb_cmplx16.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxnb_cmplx8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxnb_real4.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] mnaxnb_real8.F95.obj : error LNK2001: unresolved external symbol f90_allocated
[00:07:40] ..\..\bin\flang.dll : fatal error LNK1120: 31 unresolved externals

ghost avatar Oct 25 '17 18:10 ghost

@sscalpone Do you know where the allocated symbols are defined?

ghost avatar Oct 25 '17 23:10 ghost

See my comments on #287.

ghost avatar Oct 26 '17 00:10 ghost

@sscalpone Can we schedule a slack time?

ghost avatar Oct 26 '17 13:10 ghost

I've just opened a pull request at flang-compiler/clang#37 that applies additional changes to the compiler driver. These changes add additional linker arguments so that the correct runtime libraries are linked.

Calling flang main.f90 on a simple hello world program now gives me

warning: overriding the module target triple with x86_64-pc-windows-msvc19.11.25547 [-Woverride-module]
1 warning generated.
libcmt.lib(initializers.obj) : warning LNK4098: defaultlib 'msvcrt.lib' conflicts with use of other libs; use /NODEFAULTLIB:library
main-99545d.o : error LNK2019: unresolved external symbol fort_init referenced in function _MAIN_
main-99545d.o : error LNK2019: unresolved external symbol f90io_src_info03 referenced in function _MAIN_
main-99545d.o : error LNK2019: unresolved external symbol f90io_print_init referenced in function _MAIN_
main-99545d.o : error LNK2019: unresolved external symbol f90io_sc_ch_ldw referenced in function _MAIN_
main-99545d.o : error LNK2019: unresolved external symbol f90io_ldw_end referenced in function _MAIN_
flangmain.lib(flangmain.c.obj) : error LNK2019: unresolved external symbol _pgimain referenced in function main
flangmain.lib(flangmain.c.obj) : error LNK2019: unresolved external symbol MAIN_ referenced in function main
flangmain.lib(flangmain.c.obj) : error LNK2019: unresolved external symbol f90_exit referenced in function main
a.exe : fatal error LNK1120: 8 unresolved externals
flang.exe: error: linker command failed with exit code 1120 (use -v to see invocation)

so there are still some basic symbols missing. If I take a look at flangmain.c, it looks as if this file has not yet been adjusted correctly since it has been taken from PGI.

After these symbol errors would be resolved, I would start to look into making the test-suite work on windows, so that we can get a clearer image of what is really working and what is not.

albertziegenhagel avatar Oct 26 '17 15:10 albertziegenhagel

f90io_ldw_end should be in flang.dll. Is it being linked?

isuruf avatar Oct 26 '17 15:10 isuruf

It was a missing __declspec(dllexport) again. WINDOWS_EXPORT_ALL_SYMBOLS solved that.

Now the executable links successfully but does not produce any output when being executed. I will dig deeper into that!

albertziegenhagel avatar Oct 26 '17 15:10 albertziegenhagel

I compiled a hello world application yesterday and linked to the static libs manually. Hello world was printed and then there was a crash.

isuruf avatar Oct 26 '17 15:10 isuruf

I can reproduce the same behavior when linking to the static flang runtime.

albertziegenhagel avatar Oct 26 '17 16:10 albertziegenhagel

PGI does export-all for the libraries.

sscalpone avatar Oct 26 '17 17:10 sscalpone

@sscalpone Can you answer my question on #287?

ghost avatar Oct 26 '17 17:10 ghost

So I think we removed the signal handlers because they don't work with MSVC. I'm going to attempt to install a signal handler that will work for us.

ghost avatar Oct 26 '17 18:10 ghost

I don't know which of the above incremental changes fixed it for me, but a simple hello world works as intended now. Hooray!

Couple of issues, https://github.com/isuruf/flang/pull/15#pullrequestreview-72685585 and need https://github.com/flang-compiler/clang/pull/37 backported for llvm 4.0 branch so that we can run it on appveyor.

isuruf avatar Oct 29 '17 02:10 isuruf

We also need to get the tests working so that we have some idea of where we are.

ghost avatar Oct 29 '17 02:10 ghost

@xoviat, conda package is available in my channel isuruf/label/flangdev

isuruf avatar Oct 29 '17 21:10 isuruf

Okay.

ghost avatar Oct 29 '17 21:10 ghost

Using the latest conda package from this I haven't been able to get a minimal working example yet because things like flang -cpp -E hello.f90 -o hello.f90-pp.f90 don't actually do anything. That command should output a preprocessed file. Am I missing something in the command line interface or is there a bug that needs to be addressed here?

@insertinterestingnamehere, see https://github.com/flang-compiler/flang/issues/222

isuruf avatar Nov 01 '17 18:11 isuruf

Got it. That makes sense. Is there some way to get around needing to run that command on testFortranCompiler.f when using CMake or is that something that still needs to be done?

Don't use the ninja generator. Use the nmake makefiles generator.

ghost avatar Nov 01 '17 18:11 ghost

Thanks. Good find. A minimal hello world example is working with CMake for me. I'm using NMake in the MSVC 2015 native x64 terminal and had to set the LIB environment variable to include the Anaconda Library/lib directory.

Try to compile OpenBLAS with DYNAMIC_ARCH.

ghost avatar Nov 01 '17 18:11 ghost

That also configures correctly. Compilation will take a while. Note I'm also using the patches from all three of the PR's listed at https://gitlab.kitware.com/cmake/cmake/issues/17384.

@insertinterestingnamehere, you need to give -DBUILD_WITHOUT_LAPACK=Off because it is off by default with MSVC.

isuruf avatar Nov 01 '17 22:11 isuruf

Right. It looks like there is some additional work to be done in their CMakeLists files. I'll see what I can do.