tonybaloney / Pyjion

Pyjion - A JIT for Python based upon CoreCLR
https://www.trypyjion.com
MIT License
1.42k stars 59 forks source link

Windows build fails #103

Closed oroppas closed 3 years ago

oroppas commented 3 years ago

Basically, it fails to link _pyjion.cp39-win_amd64.pyd

Here's system info

C:\msys64\home\ryuta\packages\coolprop>"C:\Program Files\dotnet\dotnet.exe" --info
.NET SDK (reflecting any global.json):
 Version:   5.0.101
 Commit:    d05174dc5a

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.18363
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\5.0.101\

Host (useful for support):
  Version: 5.0.1
  Commit:  b02e13abab

.NET SDKs installed:
  5.0.100 [C:\Program Files\dotnet\sdk]
  5.0.101 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 5.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

and here's the log

C:\msys64\home\ryuta\packages\pyjion\pyjion>python -m pip install .
Processing c:\msys64\home\ryuta\packages\pyjion\pyjion
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Building wheels for collected packages: pyjion
  Building wheel for pyjion (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\ryuta\AppData\Local\Programs\Python\Python39\python.exe' 'C:\Users\ryuta\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\ryuta\AppData\Local\Temp\tmpn2ay373x'
       cwd: C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa
  Complete output (163 lines):
  Not searching for unused variables given on the command line.
  -- The C compiler identification is MSVC 19.28.29335.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx86/x64/cl.exe - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- The CXX compiler identification is MSVC 19.28.29335.0
  CMake Warning (dev) at C:/Users/ryuta/AppData/Local/Temp/pip-build-env-c55_pfcs/overlay/Lib/site-packages/cmake/data/share/cmake-3.18/Modules/CMakeDetermineCXXCompiler.cmake:157 (if):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "MSVC" will no longer be dereferenced when the policy
    is set to NEW.  Since the policy is not set the OLD behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:4 (ENABLE_LANGUAGE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  CMake Warning (dev) at C:/Users/ryuta/AppData/Local/Temp/pip-build-env-c55_pfcs/overlay/Lib/site-packages/cmake/data/share/cmake-3.18/Modules/CMakeDetermineCXXCompiler.cmake:177 (elseif):
    Policy CMP0054 is not set: Only interpret if() arguments as variables or
    keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
    details.  Use the cmake_policy command to set the policy and suppress this
    warning.

    Quoted variables like "MSVC" will no longer be dereferenced when the policy
    is set to NEW.  Since the policy is not set the OLD behavior will be used.
  Call Stack (most recent call first):
    CMakeLists.txt:4 (ENABLE_LANGUAGE)
  This warning is for project developers.  Use -Wno-dev to suppress it.

  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx86/x64/cl.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done
  -- Generating done
  -- Build files have been written to: C:/Users/ryuta/AppData/Local/Temp/pip-req-build-bhgcm7wa/_cmake_test_compile/build
  -- The C compiler identification is MSVC 19.28.29335.0
  -- The CXX compiler identification is MSVC 19.28.29335.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx86/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 (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx86/x64/cl.exe - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found PythonInterp: C:/Users/ryuta/AppData/Local/Programs/Python/Python39/python.exe (found version "3.9")
  -- Found PythonLibs: C:/Users/ryuta/AppData/Local/Programs/Python/Python39/libs/python39.lib (found version "3.9.0")
  -- Using Python libraries for skbuild C:/Users/ryuta/AppData/Local/Programs/Python/Python39/libs/python39.lib
  -- Using Python headers for skbuild C:/Users/ryuta/AppData/Local/Programs/Python/Python39/Include
  -- Using Python libraries C:/Users/ryuta/AppData/Local/Programs/Python/Python39/libs/python39.lib
  -- Using Python headers C:/Users/ryuta/AppData/Local/Programs/Python/Python39/Include
  -- Enabling AMD64
  -- Found .NET 5 in C:\Program Files\dotnet/shared/Microsoft.NETCore.App/5.0.0C:\Program Files\dotnet/shared/Microsoft.NETCore.App/5.0.1
  -- The ASM_MASM compiler identification is MSVC
  -- Found assembler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29333/bin/Hostx86/x64/ml64.exe
  -- Performing Test Weak Link MODULE -> SHARED (gnu_ld_ignore) - Failed
  -- Performing Test Weak Link MODULE -> SHARED (osx_dynamic_lookup) - Failed
  -- Performing Test Weak Link MODULE -> SHARED (no_flag) - Failed
  _modinit_prefix:PyInit_
  -- Configuring done
  -- Generating done
  -- Build files have been written to: C:/Users/ryuta/AppData/Local/Temp/pip-req-build-bhgcm7wa/_skbuild/win-amd64-3.9/cmake-build
  [1/12] Building ASM_MASM object CMakeFiles\pyjionlib.dir\src\pyjion\helpers.asm.obj
  Microsoft (R) Macro Assembler (x64) Version 14.28.29335.0
  Copyright (C) Microsoft Corporation.  All rights reserved.

   Assembling: ..\..\..\src\pyjion\helpers.asm
  [2/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\jitinit.cpp.obj
  [3/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\stack.cpp.obj
  [4/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\block.cpp.obj
  [5/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\exceptionhandling.cpp.obj
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): warning C4099: 'ExceptionHandler': type name first seen using 'class' now seen using 'struct'
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): note: see declaration of 'ExceptionHandler'
  [6/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\absvalue.cpp.obj
  [7/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\intrins.cpp.obj
  ..\..\..\src\pyjion\intrins.cpp(121): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\intrins.cpp(601): warning C4101: 'args': unreferenced local variable
  [8/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\pyjit.cpp.obj
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\jitinfo.h(160): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\ilgen.h(217): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): warning C4099: 'ExceptionHandler': type name first seen using 'class' now seen using 'struct'
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): note: see declaration of 'ExceptionHandler'
  ..\..\..\src\pyjion\pyjit.cpp(546): warning C4244: 'argument': conversion from 'unsigned long' to 'unsigned short', possible loss of data
  [9/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\absint.cpp.obj
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): warning C4099: 'ExceptionHandler': type name first seen using 'class' now seen using 'struct'
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): note: see declaration of 'ExceptionHandler'
  ..\..\..\src\pyjion\absint.cpp(113): warning C4267: 'argument': conversion from 'size_t' to 'const int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(121): warning C4267: 'argument': conversion from 'size_t' to 'const int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(224): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(908): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(910): warning C4267: '=': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(1202): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(1556): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(1844): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(1845): warning C4267: 'argument': conversion from 'size_t' to 'const int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(1936): warning C4267: 'argument': conversion from 'size_t' to 'unsigned long', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(1941): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(1948): warning C4267: 'argument': conversion from 'size_t' to 'const int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(2261): warning C4101: 'e': unreferenced local variable
  ..\..\..\src\pyjion\absint.cpp(2374): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(2466): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(2483): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(2578): warning C4267: 'argument': conversion from 'size_t' to 'const int', possible loss of data
  ..\..\..\src\pyjion\absint.cpp(2579): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  [10/12] Building CXX object CMakeFiles\pyjionlib.dir\src\pyjion\pycomp.cpp.obj
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\jitinfo.h(160): warning C4267: 'return': conversion from 'size_t' to 'unsigned int', possible loss of data
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\ilgen.h(217): warning C4267: 'argument': conversion from 'size_t' to 'int', possible loss of data
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): warning C4099: 'ExceptionHandler': type name first seen using 'class' now seen using 'struct'
  C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\src\pyjion\exceptionhandling.h(66): note: see declaration of 'ExceptionHandler'
  [11/12] Linking C shared module _pyjion.cp39-win_amd64.pyd
  FAILED: _pyjion.cp39-win_amd64.pyd
  cmd.exe /C "cd . && C:\Users\ryuta\AppData\Local\Temp\pip-build-env-c55_pfcs\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E vs_link_dll --intdir=CMakeFiles\_pyjion.dir --rc=C:\PROGRA~2\WINDOW~4\10\bin\100183~1.0\x86\rc.exe --mt=C:\PROGRA~2\WINDOW~4\10\bin\100183~1.0\x86\mt.exe --manifests  -- C:\PROGRA~2\MICROS~4\2019\COMMUN~1\VC\Tools\MSVC\1428~1.293\bin\Hostx86\x64\link.exe /nologo CMakeFiles\pyjionlib.dir\src\pyjion\absint.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\absvalue.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\intrins.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\jitinit.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\pycomp.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\pyjit.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\exceptionhandling.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\stack.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\block.cpp.obj CMakeFiles\pyjionlib.dir\src\pyjion\helpers.asm.obj  /out:_pyjion.cp39-win_amd64.pyd /implib:_pyjion.lib /pdb:_pyjion.pdb /dll /version:0.0 /machine:x64 /INCREMENTAL:NO /EXPORT:PyInit__pyjion  C:\Users\ryuta\AppData\Local\Programs\Python\Python39\libs\python39.lib  kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib  && cmd.exe /C "cd /D C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\_skbuild\win-amd64-3.9\cmake-build && C:\Users\ryuta\AppData\Local\Temp\pip-build-env-c55_pfcs\overlay\Lib\site-packages\cmake\data\bin\cmake.exe -E copy "C:\Program Files\dotnet/shared/Microsoft.NETCore.App/5.0.0" "C:\Program Files\dotnet/shared/Microsoft.NETCore.App/5.0.1/clrjit.dll" C:/Users/ryuta/AppData/Local/Temp/pip-req-build-bhgcm7wa/_skbuild/win-amd64-3.9/cmake-build/clrjit.dll""
     Creating library _pyjion.lib and object _pyjion.exp
  Error: Target (for copy command) "C:/Users/ryuta/AppData/Local/Temp/pip-req-build-bhgcm7wa/_skbuild/win-amd64-3.9/cmake-build/clrjit.dll" is not a directory.
  ninja: build stopped: subcommand failed.
    File "C:\Users\ryuta\AppData\Local\Temp\pip-build-env-c55_pfcs\overlay\Lib\site-packages\skbuild\setuptools_wrap.py", line 590, in setup
      cmkr.make(make_args, env=env)
    File "C:\Users\ryuta\AppData\Local\Temp\pip-build-env-c55_pfcs\overlay\Lib\site-packages\skbuild\cmaker.py", line 496, in make
      raise SKBuildError(

  --------------------------------------------------------------------------------
  -- Trying "Ninja (Visual Studio 16 2019 Win64 v142)" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Ninja (Visual Studio 16 2019 Win64 v142)" generator - success
  --------------------------------------------------------------------------------

  Configuring Project
    Working directory:
      C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\_skbuild\win-amd64-3.9\cmake-build
    Command:
      cmake 'C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa' -G Ninja '-DCMAKE_INSTALL_PREFIX:PATH=C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\_skbuild\win-amd64-3.9\cmake-install' '-DPYTHON_EXECUTABLE:FILEPATH=C:\Users\ryuta\AppData\Local\Programs\Python\Python39\python.exe' -DPYTHON_VERSION_STRING:STRING=3.9.0 '-DPYTHON_INCLUDE_DIR:PATH=C:\Users\ryuta\AppData\Local\Programs\Python\Python39\Include' '-DPYTHON_LIBRARY:FILEPATH=C:\Users\ryuta\AppData\Local\Programs\Python\Python39\libs\python39.lib' -DSKBUILD:INTERNAL=TRUE '-DCMAKE_MODULE_PATH:PATH=C:\Users\ryuta\AppData\Local\Temp\pip-build-env-c55_pfcs\overlay\Lib\site-packages\skbuild\resources\cmake' -DCMAKE_BUILD_TYPE:STRING=Release

  Traceback (most recent call last):

  An error occurred while building with CMake.
    Command:
      cmake --build . --target install --config Release --
    Source directory:
      C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa
    Working directory:
      C:\Users\ryuta\AppData\Local\Temp\pip-req-build-bhgcm7wa\_skbuild\win-amd64-3.9\cmake-build
  Please see CMake's output for more information.
  ----------------------------------------
  ERROR: Failed building wheel for pyjion
Failed to build pyjion
ERROR: Could not build wheels for pyjion which use PEP 517 and cannot be installed directly
tonybaloney commented 3 years ago

Looks like it can't locate clrjit.dll, can you check that exists inside C:\Program Files\dotnet/shared/Microsoft.NETCore.App/5.0.1

oroppas commented 3 years ago

Yeah, I've been scratching my head since clrjit.dll exists under C:\Program Files\dotnet/shared/Microsoft.NETCore.App/5.0.1

dir "C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.1\clrjit.*"
 Volume in drive C is System
 Volume Serial Number is F63D-D612

 Directory of C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.1

11/26/2020  02:18 AM         1,324,424 clrjit.dll
               1 File(s)      1,324,424 bytes
               0 Dir(s)  743,387,054,080 bytes free
oroppas commented 3 years ago

pyjion/CMakeLists.txt looks like

if (WIN32)
    add_custom_command(
        TARGET _pyjion POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy
        ${DOTNETPATH}/clrjit.dll
        ${CMAKE_CURRENT_BINARY_DIR}/clrjit.dll
    )
endif(WIN32)

Shouldn't the last line of add_custom_command be ${CMAKE_CURRENT_BINARY_DIR} instead of ${CMAKE_CURRENT_BINARY_DIR}/clrjit.dll?

oroppas commented 3 years ago

This works on my Windows

diff --git a/CMakeLists.txt b/CMakeLists.txt
index e442b0f..6358af6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -186,7 +186,7 @@ if (WIN32)
         TARGET _pyjion POST_BUILD
         COMMAND ${CMAKE_COMMAND} -E copy
         ${DOTNETPATH}/clrjit.dll
-        ${CMAKE_CURRENT_BINARY_DIR}/clrjit.dll
+        ${CMAKE_CURRENT_BINARY_DIR}
     )
 endif(WIN32)