flang-compiler/flang

[pgmath] Building with clang-cl supported?

Neumann-A opened this issue · 2 comments

Is building of pgmath with clang-cl supported? I get a bunch of warnings due to the -march and -mtune flags being ignored. Still it compiles successfully. I tried using -Xclang to pass those arguments but clang complains that it does not know them (funny the -mavx(2|512) -mfma flags don't print any warnings).
Patching all the -mtune: to /tune: and -march to the appropiate /arch: flags however throws the following:
clang-cl-flags.txt
install-x64-windows-static-dbg-out.log
vcpkg PR: microsoft/vcpkg#24622 (does not have the flag patch)


FAILED: lib/pgmath.dll lib/pgmath.lib 
cmd.exe /C "cmd.exe /C "G:\vcpkg_common\downloads\tools\cmake-3.22.2-windows\cmake-3.22.2-windows-i386\bin\cmake.exe -E __create_def E:\vcpkg_folders\master\buildtrees\pgmath\x64-windows-static-dbg\lib\CMakeFiles\pgmath.dir\.\exports.def E:\vcpkg_folders\master\buildtrees\pgmath\x64-windows-static-dbg\lib\CMakeFiles\pgmath.dir\.\exports.def.objs --nm=E:\vcpkg_folders\master\installed\x64-windows\manual-tools\vcpkg-tool-llvm\bin\llvm-nm.exe && cd E:\vcpkg_folders\master\buildtrees\pgmath\x64-windows-static-dbg" && G:\vcpkg_common\downloads\tools\cmake-3.22.2-windows\cmake-3.22.2-windows-i386\bin\cmake.exe -E vs_link_dll --intdir=lib\CMakeFiles\pgmath.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100203~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\link.exe  @CMakeFiles\pgmath.rsp  /out:lib\pgmath.dll /implib:lib\pgmath.lib /pdb:lib\pgmath.pdb /dll /version:0.0 /machine:x64 /nologo    /debug /INCREMENTAL  /DEF:lib\CMakeFiles\pgmath.dir\.\exports.def  && cd ."
LINK Pass 1: command "C:\PROGRA~1\MIB055~1\2022\COMMUN~1\VC\Tools\MSVC\1431~1.311\bin\Hostx64\x64\link.exe @CMakeFiles\pgmath.rsp /out:lib\pgmath.dll /implib:lib\pgmath.lib /pdb:lib\pgmath.pdb /dll /version:0.0 /machine:x64 /nologo /debug /INCREMENTAL /DEF:lib\CMakeFiles\pgmath.dir\.\exports.def /MANIFEST /MANIFESTFILE:lib\CMakeFiles\pgmath.dir/intermediate.manifest lib\CMakeFiles\pgmath.dir/manifest.res" failed
 (exit code 1120) with the following output:
vdacos8.cpp.obj : error LNK2005: __fvd_acos_fma3_512 already defined in vdacos8.cpp.obj
vsacos16.cpp.obj : error LNK2005: __fvs_acos_fma3_512 already defined in vsacos16.cpp.obj
vdasin8.cpp.obj : error LNK2005: __fvd_asin_fma3_512 already defined in vdasin8.cpp.obj
vsasin16.cpp.obj : error LNK2005: __fvs_asin_fma3_512 already defined in vsasin16.cpp.obj
vdexp8.cpp.obj : error LNK2005: __fvd_exp_fma3_512 already defined in vdexp8.cpp.obj
vsexp16.cpp.obj : error LNK2005: __fvs_exp_fma3_512 already defined in vsexp16.cpp.obj
fdlog8.cpp.obj : error LNK2005: __fvd_log_fma3_512 already defined in fdlog8.cpp.obj
fslog16.cpp.obj : error LNK2005: __fvs_log_fma3_512 already defined in fslog16.cpp.obj
rslog16.cpp.obj : error LNK2005: __rvs_log_fma3_512 already defined in rslog16.cpp.obj
vdpow8.cpp.obj : error LNK2005: __fvd_pow_fma3_512 already defined in vdpow8.cpp.obj
vspow16.cpp.obj : error LNK2005: __fvs_pow_fma3_512 already defined in vspow16.cpp.obj
fd_sincos_vector.cpp.obj : error LNK2005: __fd_sincos_8_avx512 already defined in fd_sincos_vector.cpp.obj
fd_sincos_vector.cpp.obj : error LNK2005: __fd_cos_8_avx512 already defined in fd_sincos_vector.cpp.obj
fd_sincos_vector.cpp.obj : error LNK2005: __fd_sin_8_avx512 already defined in fd_sincos_vector.cpp.obj
fs_sincos_vector.cpp.obj : error LNK2005: __fs_sincos_16_avx512 already defined in fs_sincos_vector.cpp.obj
fs_sincos_vector.cpp.obj : error LNK2005: __fs_cos_16_avx512 already defined in fs_sincos_vector.cpp.obj
fs_sincos_vector.cpp.obj : error LNK2005: __fs_sin_16_avx512 already defined in fs_sincos_vector.cpp.obj
vsatan16.cpp.obj : error LNK2005: __fvs_atan_fma3_512 already defined in vsatan16.cpp.obj
   Creating library lib\pgmath.lib and object lib\pgmath.exp
dispatch.c.obj : error LNK2001: unresolved external symbol __fvs_acos_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvd_acos_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvs_asin_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvd_asin_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvs_exp_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvd_exp_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __rvs_log_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvd_log_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvs_pow_fma3_knl
dispatch.c.obj : error LNK2001: unresolved external symbol __fvd_pow_fma3_knl
lib\pgmath.dll : fatal error LNK1120: 10 unresolved externals
ninja: build stopped: subcommand failed.

Using lld-link gives better errors:

lld-link: error: duplicate symbol: __fvd_acos_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\acos\fma3\vdacos8.cpp:21
>>>            lib\common\acos\fma3\CMakeFiles\acos-avx512.dir\vdacos8.cpp.obj
>>> defined at lib\common\acos\fma3\CMakeFiles\acos-knl.dir\vdacos8.cpp.obj

lld-link: error: duplicate symbol: __fvs_acos_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\acos\fma3\vsacos16.cpp:21
>>>            lib\common\acos\fma3\CMakeFiles\acos-avx512.dir\vsacos16.cpp.obj
>>> defined at lib\common\acos\fma3\CMakeFiles\acos-knl.dir\vsacos16.cpp.obj

lld-link: error: duplicate symbol: __fvd_asin_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\asin\fma3\vdasin8.cpp:22
>>>            lib\common\asin\fma3\CMakeFiles\asin-avx512.dir\vdasin8.cpp.obj
>>> defined at lib\common\asin\fma3\CMakeFiles\asin-knl.dir\vdasin8.cpp.obj

lld-link: error: duplicate symbol: __fvs_asin_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\asin\fma3\vsasin16.cpp:23
>>>            lib\common\asin\fma3\CMakeFiles\asin-avx512.dir\vsasin16.cpp.obj
>>> defined at lib\common\asin\fma3\CMakeFiles\asin-knl.dir\vsasin16.cpp.obj

lld-link: error: duplicate symbol: __fvd_exp_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\exp\fma3\vdexp8.cpp:66
>>>            lib\common\exp\fma3\CMakeFiles\exp-avx512.dir\vdexp8.cpp.obj
>>> defined at lib\common\exp\fma3\CMakeFiles\exp-knl.dir\vdexp8.cpp.obj

lld-link: error: duplicate symbol: __fvs_exp_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\exp\fma3\vsexp16.cpp:21
>>>            lib\common\exp\fma3\CMakeFiles\exp-avx512.dir\vsexp16.cpp.obj
>>> defined at lib\common\exp\fma3\CMakeFiles\exp-knl.dir\vsexp16.cpp.obj

lld-link: error: duplicate symbol: __fvd_log_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\log\fma3\fdlog8.cpp:62
>>>            lib\common\log\fma3\CMakeFiles\log-avx512.dir\fdlog8.cpp.obj
>>> defined at lib\common\log\fma3\CMakeFiles\log-knl.dir\fdlog8.cpp.obj

lld-link: error: duplicate symbol: __fvs_log_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\log\fma3\fslog16.cpp:21
>>>            lib\common\log\fma3\CMakeFiles\log-avx512.dir\fslog16.cpp.obj
>>> defined at lib\common\log\fma3\CMakeFiles\log-knl.dir\fslog16.cpp.obj

lld-link: error: duplicate symbol: __rvs_log_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\log\fma3\rslog16.cpp:24
>>>            lib\common\log\fma3\CMakeFiles\log-avx512.dir\rslog16.cpp.obj
>>> defined at lib\common\log\fma3\CMakeFiles\log-knl.dir\rslog16.cpp.obj

lld-link: error: duplicate symbol: __fvd_pow_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\pow\fma3\vdpow8.cpp:279
>>>            lib\common\pow\fma3\CMakeFiles\pow-avx512.dir\vdpow8.cpp.obj
>>> defined at lib\common\pow\fma3\CMakeFiles\pow-knl.dir\vdpow8.cpp.obj

lld-link: error: duplicate symbol: __fvs_pow_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\pow\fma3\vspow16.cpp:178
>>>            lib\common\pow\fma3\CMakeFiles\pow-avx512.dir\vspow16.cpp.obj
>>> defined at lib\common\pow\fma3\CMakeFiles\pow-knl.dir\vspow16.cpp.obj

lld-link: error: duplicate symbol: __fd_sincos_8_avx512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\sincos\fd_sincos_vector.cpp:93
>>>            lib\common\sincos\CMakeFiles\fd_sincos_16_avx2.dir\fd_sincos_vector.cpp.obj
>>> defined at lib\common\sincos\CMakeFiles\fd_sincos_16_knl.dir\fd_sincos_vector.cpp.obj

lld-link: error: duplicate symbol: __fd_cos_8_avx512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\sincos\fd_sincos_vector.cpp:93
>>>            lib\common\sincos\CMakeFiles\fd_cos_16_avx2.dir\fd_sincos_vector.cpp.obj
>>> defined at lib\common\sincos\CMakeFiles\fd_cos_16_knl.dir\fd_sincos_vector.cpp.obj

lld-link: error: duplicate symbol: __fd_sin_8_avx512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\sincos\fd_sincos_vector.cpp:93
>>>            lib\common\sincos\CMakeFiles\fd_sin_16_avx2.dir\fd_sincos_vector.cpp.obj
>>> defined at lib\common\sincos\CMakeFiles\fd_sin_16_knl.dir\fd_sincos_vector.cpp.obj

lld-link: error: duplicate symbol: __fs_sincos_16_avx512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\sincosf\fs_sincos_vector.cpp:207
>>>            lib\common\sincosf\CMakeFiles\fs_sincos_16_avx2.dir\fs_sincos_vector.cpp.obj
>>> defined at lib\common\sincosf\CMakeFiles\fs_sincos_16_knl.dir\fs_sincos_vector.cpp.obj

lld-link: error: duplicate symbol: __fs_cos_16_avx512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\sincosf\fs_sincos_vector.cpp:207
>>>            lib\common\sincosf\CMakeFiles\fs_cos_16_avx2.dir\fs_sincos_vector.cpp.obj
>>> defined at lib\common\sincosf\CMakeFiles\fs_cos_16_knl.dir\fs_sincos_vector.cpp.obj

lld-link: error: duplicate symbol: __fs_sin_16_avx512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\common\sincosf\fs_sincos_vector.cpp:207
>>>            lib\common\sincosf\CMakeFiles\fs_sin_16_avx2.dir\fs_sincos_vector.cpp.obj
>>> defined at lib\common\sincosf\CMakeFiles\fs_sin_16_knl.dir\fs_sincos_vector.cpp.obj

lld-link: error: duplicate symbol: __fvs_atan_fma3_512
>>> defined at E:\vcpkg_folders\fortran_new\buildtrees\pgmath\src\5afd702e45-948097f6c1.clean\runtime\libpgmath\lib\x86_64\atan\fma3\vsatan16.cpp:28
>>>            lib\x86_64\atan\fma3\CMakeFiles\atan-avx512.dir\vsatan16.cpp.obj

>>> defined at lib\x86_64\atan\fma3\CMakeFiles\atan-knl.dir\vsatan16.cpp.obj

Ok got it also needed /D__knl for that to work correctly.