Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libpgmath build fails on windows #1373

Open
harishch4 opened this issue Jun 15, 2023 · 4 comments
Open

libpgmath build fails on windows #1373

harishch4 opened this issue Jun 15, 2023 · 4 comments

Comments

@harishch4
Copy link

I'm following this link to build flang for windows and facing build issues during libpgmath build. Any idea on this?

cmake command:

C:\Users\hchambet\work\flang\runtime\libpgmath\build>cmake -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_C_COMPILER="C:/Users/hchambet/work/classic-flang-llvm-project/install/bin/clang-cl.exe" -DCMAKE_CXX_COMPILER="C:/Users/hchambet/work/classic-flang-llvm-project/install/bin/clang-cl.exe" ..
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22000.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.36.32534.0
-- The CXX compiler identification is MSVC 19.36.32534.0
-- The ASM compiler identification is MSVC
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python3: C:/Users/hchambet/AppData/Local/Programs/Python/Python311/python.exe (found version "3.11.3") found components: Interpreter
-- Looking for sqrt in m
-- Looking for sqrt in m - not found
-- Configuring done (12.0s)
-- Generating done (2.6s)
-- Build files have been written to: C:/Users/hchambet/work/flang/runtime/libpgmath/build

Errors:

image

@kaadam
Copy link
Collaborator

kaadam commented Jun 15, 2023

Hi, As far as I see the CMake hasn't picked up your clang-cl compiler setting, and cl.exe is used instead. CL is not supported in Flang project. CMake will select VS generator automatically in Windows platform, the VS generators don't use CMAKE_C/CXX_COMPILER variables. You should set the generator explicitly for example '-G Ninja' in command line to use clang-cl.

@harishch4
Copy link
Author

You should set the generator explicitly for example '-G Ninja' in command line to use clang-cl.

After explicitly changing the generator, it is taking clang-cl as compiler but failing at a later point

C:\Users\hchambet\work\flang\runtime\libpgmath\build>"C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvarsall.bat" x64


** Visual Studio 2022 Developer Command Prompt v17.6.3
** Copyright (c) 2022 Microsoft Corporation


[vcvarsall.bat] Environment initialized for: 'x64'

C:\Users\hchambet\work\flang\runtime\libpgmath\build>cmake -G Ninja -DCMAKE_INSTALL_PREFIX=../install -DCMAKE_C_COMPILER="clang-cl.exe" -DCMAKE_CXX_COMPILER="clang-cl.exe" ..
-- The C compiler identification is Clang 15.0.1 with MSVC-like command-line
-- The CXX compiler identification is Clang 15.0.1 with MSVC-like command-line
-- The ASM compiler identification is Clang with MSVC-like command-line
-- Found assembler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/bin/clang-cl.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/x64/bin/clang-cl.exe
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/x64/bin/clang-cl.exe - broken
CMake Error at C:/Program Files/Microsoft Visual Studio/2022/Professional/Common7/IDE/CommonExtensions/Microsoft/CMake/CMake/share/cmake-3.26/Modules/CMakeTestCCompiler.cmake:67 (message):
The C compiler

"C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/Llvm/x64/bin/clang-cl.exe"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: C:/Users/hchambet/work/flang/runtime/libpgmath/build/CMakeFiles/CMakeScratch/TryCompile-sqlk3w

Run Build Command(s):C:/PROGRA~1/MIB055~1/2022/PROFES~1/Common7/IDE/COMMON~1/MICROS~1/CMake/Ninja/ninja.exe -v cmTC_cc701 && [1/2] C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\Llvm\x64\bin\clang-cl.exe  /nologo   /DWIN32 /D_WINDOWS /W3  /MDd /Zi /Ob0 /Od /RTC1 /showIncludes /FoCMakeFiles\cmTC_cc701.dir\testCCompiler.c.obj /FdCMakeFiles\cmTC_cc701.dir\ -c -- C:\Users\hchambet\work\flang\runtime\libpgmath\build\CMakeFiles\CMakeScratch\TryCompile-sqlk3w\testCCompiler.c
[2/2] cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_cc701.dir --rc=C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\Llvm\bin\llvm-rc.exe --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\Llvm\bin\lld-link.exe /nologo CMakeFiles\cmTC_cc701.dir\testCCompiler.c.obj  /out:cmTC_cc701.exe /implib:cmTC_cc701.lib /pdb:cmTC_cc701.pdb /version:0.0 /machine:X86  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
FAILED: cmTC_cc701.exe
cmd.exe /C "cd . && "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" -E vs_link_exe --intdir=CMakeFiles\cmTC_cc701.dir --rc=C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\Llvm\bin\llvm-rc.exe --mt=CMAKE_MT-NOTFOUND --manifests  -- C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\Llvm\bin\lld-link.exe /nologo CMakeFiles\cmTC_cc701.dir\testCCompiler.c.obj  /out:cmTC_cc701.exe /implib:cmTC_cc701.lib /pdb:cmTC_cc701.pdb /version:0.0 /machine:X86  /debug /INCREMENTAL /subsystem:console  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ."
LINK Pass 1: command "C:\PROGRA~1\MIB055~1\2022\PROFES~1\VC\Tools\Llvm\bin\lld-link.exe /nologo CMakeFiles\cmTC_cc701.dir\testCCompiler.c.obj /out:cmTC_cc701.exe /implib:cmTC_cc701.lib /pdb:cmTC_cc701.pdb /version:0.0 /machine:X86 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTFILE:CMakeFiles\cmTC_cc701.dir/intermediate.manifest CMakeFiles\cmTC_cc701.dir/manifest.res" failed (exit code 1) with the following output:
lld-link: error: CMakeFiles\cmTC_cc701.dir\testCCompiler.c.obj: machine type x64 conflicts with x86
lld-link: error: could not open 'kernel32.lib': no such file or directory
lld-link: error: could not open 'user32.lib': no such file or directory
lld-link: error: could not open 'gdi32.lib': no such file or directory
lld-link: error: could not open 'winspool.lib': no such file or directory
lld-link: error: could not open 'shell32.lib': no such file or directory
lld-link: error: could not open 'ole32.lib': no such file or directory
lld-link: error: could not open 'oleaut32.lib': no such file or directory
lld-link: error: could not open 'uuid.lib': no such file or directory
lld-link: error: could not open 'comdlg32.lib': no such file or directory
lld-link: error: could not open 'advapi32.lib': no such file or directory
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
CMakeLists.txt:31 (project)

-- Configuring incomplete, errors occurred!

@kaadam
Copy link
Collaborator

kaadam commented Jun 15, 2023

It could be a native tools configuration issue, please make sure about you're using x64 native tools command prompt.
Please: https://github.com/flang-compiler/flang/wiki/Building-Flang-for-Windows#other-pre-requirement

@harishch4
Copy link
Author

I'm using x64 Native Tools Command Prompt for VS 2022 to run all the commands. Still facing the issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants