elbywan / crystalline

A Language Server Protocol implementation for Crystal. 🔮
MIT License
448 stars 24 forks source link

Unable to build on windows #77

Open dsisnero opened 1 year ago

dsisnero commented 1 year ago
f:\programming\source\repos\git\crystal_repos\crystalline>shards build --release
Dependencies are satisfied
Building: crystalline
LINK : warning LNK4044: unrecognized option '/Lf:/msys64/mingw64/lib'; ignored
LINK : warning LNK4044: unrecognized option '/lLLVM-16'; ignored
LINK : fatal error LNK1181: cannot open input file 'F:\windows\scoop\apps\crystal\current\src\llvm\ext\llvm_ext.obj'
Error target crystalline failed to compile:
Error: execution of command failed with exit status 2: F:\windows\visual_studio\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64\cl.exe /nologo _main.obj /Fef:\programming\source\repos\git\crystal_repos\crystalline\bin\crystalline.exe /link /LIBPATH:F:\windows\visual_studio\VC\Too
ls\MSVC\14.35.32215\atlmfc\lib\x64 /LIBPATH:F:\windows\visual_studio\VC\Tools\MSVC\14.35.32215\lib\x64 "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64" /DEBUG:FULL /PDBALTPA
TH:%_PDB% /INCREMENTAL:NO /STACK:0x800000 /LIBPATH:F:\windows\scoop\apps\crystal\current\lib F:\windows\scoop\apps\crystal\current\src\llvm/ext/llvm_ext.obj -Lf:/msys64/mingw64/lib -lLLVM-16 /ENTRY:wmainCRTStartup F:\windows\scoop\apps\crystal\current\lib\yaml.lib F:\window
s\scoop\apps\crystal\current\lib\pcre2-8.lib F:\windows\scoop\apps\crystal\current\lib\gc.lib F:\windows\visual_studio\VC\Tools\MSVC\14.35.32215\lib\x64\libcmt.lib F:\windows\scoop\apps\crystal\current\lib\iconv.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\u
m\x64\advapi32.lib" F:\windows\visual_studio\VC\Tools\MSVC\14.35.32215\lib\x64\libvcruntime.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64\shell32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64\ole32.lib" "C:\Program Files (x86)\Wi
ndows Kits\10\Lib\10.0.22000.0\um\x64\WS2_32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\um\x64\kernel32.lib" F:\windows\visual_studio\VC\Tools\MSVC\14.35.32215\lib\x64\legacy_stdio_definitions.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\u
m\x64\DbgHelp.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22000.0\ucrt\x64\libucrt.lib"
djongepier commented 1 year ago

Since Windows support is coming along nicely, an effort getting crystalline to work/build on Windows would be appriciated.

dsisnero commented 1 year ago

another try with visual studio developer prompt

********************************************************************** ** Visual Studio 2022 Developer Command Prompt v17.7.5 ** Copyright (c) 2022 Microsoft Corporation ********************************************************************** F:\windows\visual_studio>cd f:\programming\source\repos\git\crystal_repos\crystalline f:\programming\source\repos\git\crystal_repos\crystalline>shards build --release Dependencies are satisfied Building: crystalline LINK : warning LNK4044: unrecognized option '/Lf:/msys64/mingw64/lib'; ignored LINK : warning LNK4044: unrecognized option '/lLLVM-17'; ignored LINK : fatal error LNK1181: cannot open input file 'F:\windows\scoop\apps\crystal\current\src\llvm\ext\llvm_ext.obj' Error target crystalline failed to compile: Error: execution of command failed with exit status 2: F:\windows\visual_studio\VC\Tools\MSVC\14.37.32822\bin\Hostx64\x64\cl.exe /nologo _main.obj /Fef:\programming\source\repos\git\crystal_repos\crystalline\bin\crystalline.exe /link /LIBPATH:F:\windows\visual_studio\VC\Tools\MSVC\14.37.32822\atlmfc\lib\x64 /LIBPATH:F:\windows\visual_studio\VC\Tools\MSVC\14.37.32822\lib\x64 "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64" "/LIBPATH:C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64" /DEBUG:FULL /PDBALTPATH:%_PDB% /INCREMENTAL:NO /STACK:0x800000 /LIBPATH:F:\windows\scoop\apps\crystal\current\lib F:\windows\scoop\apps\crystal\current\src\llvm/ext/llvm_ext.obj -Lf:/msys64/mingw64/lib -lLLVM-17 /ENTRY:wmainCRTStartup F:\windows\scoop\apps\crystal\current\lib\yaml.lib F:\windows\scoop\apps\crystal\current\lib\pcre2-8.lib F:\windows\scoop\apps\crystal\current\lib\gc.lib F:\windows\visual_studio\VC\Tools\MSVC\14.37.32822\lib\x64\libcmt.lib F:\windows\scoop\apps\crystal\current\lib\iconv.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\advapi32.lib" F:\windows\visual_studio\VC\Tools\MSVC\14.37.32822\lib\x64\libvcruntime.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\shell32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\ole32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\WS2_32.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\kernel32.lib" F:\windows\visual_studio\VC\Tools\MSVC\14.37.32822\lib\x64\legacy_stdio_definitions.lib "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\um\x64\DbgHelp.lib" "C:\Program Files (x86)\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64\libucrt.lib"

dsisnero commented 10 months ago

so I built llvm-17.0.6 and set LLVM_CONFIG to the file. It builds the library but errors on the linking because since https://github.com/crystal-lang/crystal/issues/13946, llvm_ext.cc is no longer built so no llvm_ext.obj is under ext

e:\programming\source\repos\git\crystal_repos\crystalline>shards build --release > output 2>&1

e:\programming\source\repos\git\crystal_repos\crystalline>more output
Dependencies are satisfied
Building: crystalline
LINK : fatal error LNK1181: cannot open input file 'E:\windows_home\.local\share\scoop\apps\crystal\current\src\llvm\ext\llvm_ext.obj'
Error target crystalline failed to compile:
Error: execution of command failed with exit status 2: E:\windows_home\.local\share\visual_studio\versions\17.8\VC\Tools\MSVC\14.38.33130\bin\Hostx64\x64\cl.exe /nologo _main.o3.obj /Fee:\programming\source\repos\git\crystal_repos\crystalline\bin\crystalline.exe /link /LIBPATH:E:\windows_home\.local\sha
re\visual_studio\versions\17.8\VC\Tools\MSVC\14.38.33130\atlmfc\lib\x64 /LIBPATH:E:\windows_home\.local\share\visual_studio\versions\17.8\VC\Tools\MSVC\14.38.33130\lib\x64 "/LIBPATH:E:\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64" "/LIBPATH:E:\Windows Kits\10\Lib\10.0.22621.0\um\x64" /DEBUG:FULL /PDBALTPAT
H:%_PDB% /INCREMENTAL:NO /STACK:0x800000 /LIBPATH:E:\windows_home\.local\share\scoop\apps\crystal\current\lib E:\windows_home\.local\share\scoop\apps\crystal\current\src\llvm/ext/llvm_ext.obj -LIBPATH:e:\llvm\llvm-17.0.6\lib /ENTRY:wmainCRTStartup E:\windows_home\.local\share\scoop\apps\crystal\current\
lib\yaml.lib e:\llvm\llvm-17.0.6\lib\LLVMWindowsManifest.lib e:\llvm\llvm-17.0.6\lib\LLVMXRay.lib e:\llvm\llvm-17.0.6\lib\LLVMLibDriver.lib e:\llvm\llvm-17.0.6\lib\LLVMDlltoolDriver.lib e:\llvm\llvm-17.0.6\lib\LLVMCoverage.lib e:\llvm\llvm-17.0.6\lib\LLVMLineEditor.lib e:\llvm\llvm-17.0.6\lib\LLVMX86Tar
getMCA.lib e:\llvm\llvm-17.0.6\lib\LLVMX86Disassembler.lib e:\llvm\llvm-17.0.6\lib\LLVMX86AsmParser.lib e:\llvm\llvm-17.0.6\lib\LLVMX86CodeGen.lib e:\llvm\llvm-17.0.6\lib\LLVMX86Desc.lib e:\llvm\llvm-17.0.6\lib\LLVMX86Info.lib e:\llvm\llvm-17.0.6\lib\LLVMARMDisassembler.lib e:\llvm\llvm-17.0.6\lib\LLVMA
RMAsmParser.lib e:\llvm\llvm-17.0.6\lib\LLVMARMCodeGen.lib e:\llvm\llvm-17.0.6\lib\LLVMARMDesc.lib e:\llvm\llvm-17.0.6\lib\LLVMARMUtils.lib e:\llvm\llvm-17.0.6\lib\LLVMARMInfo.lib e:\llvm\llvm-17.0.6\lib\LLVMOrcJIT.lib e:\llvm\llvm-17.0.6\lib\LLVMWindowsDriver.lib e:\llvm\llvm-17.0.6\lib\LLVMMCJIT.lib e
:\llvm\llvm-17.0.6\lib\LLVMJITLink.lib e:\llvm\llvm-17.0.6\lib\LLVMInterpreter.lib e:\llvm\llvm-17.0.6\lib\LLVMExecutionEngine.lib e:\llvm\llvm-17.0.6\lib\LLVMRuntimeDyld.lib e:\llvm\llvm-17.0.6\lib\LLVMOrcTargetProcess.lib e:\llvm\llvm-17.0.6\lib\LLVMOrcShared.lib e:\llvm\llvm-17.0.6\lib\LLVMDWP.lib e:
\llvm\llvm-17.0.6\lib\LLVMDebugInfoLogicalView.lib e:\llvm\llvm-17.0.6\lib\LLVMDebugInfoGSYM.lib e:\llvm\llvm-17.0.6\lib\LLVMOption.lib e:\llvm\llvm-17.0.6\lib\LLVMObjectYAML.lib e:\llvm\llvm-17.0.6\lib\LLVMObjCopy.lib e:\llvm\llvm-17.0.6\lib\LLVMMCA.lib e:\llvm\llvm-17.0.6\lib\LLVMMCDisassembler.lib e:
\llvm\llvm-17.0.6\lib\LLVMLTO.lib e:\llvm\llvm-17.0.6\lib\LLVMPasses.lib e:\llvm\llvm-17.0.6\lib\LLVMCFGuard.lib e:\llvm\llvm-17.0.6\lib\LLVMCoroutines.lib e:\llvm\llvm-17.0.6\lib\LLVMipo.lib e:\llvm\llvm-17.0.6\lib\LLVMVectorize.lib e:\llvm\llvm-17.0.6\lib\LLVMLinker.lib e:\llvm\llvm-17.0.6\lib\LLVMIns
trumentation.lib e:\llvm\llvm-17.0.6\lib\LLVMFrontendOpenMP.lib e:\llvm\llvm-17.0.6\lib\LLVMFrontendOpenACC.lib e:\llvm\llvm-17.0.6\lib\LLVMFrontendHLSL.lib e:\llvm\llvm-17.0.6\lib\LLVMExtensions.lib e:\llvm\llvm-17.0.6\lib\LLVMDWARFLinkerParallel.lib e:\llvm\llvm-17.0.6\lib\LLVMDWARFLinker.lib e:\llvm\
llvm-17.0.6\lib\LLVMGlobalISel.lib e:\llvm\llvm-17.0.6\lib\LLVMMIRParser.lib e:\llvm\llvm-17.0.6\lib\LLVMAsmPrinter.lib e:\llvm\llvm-17.0.6\lib\LLVMSelectionDAG.lib e:\llvm\llvm-17.0.6\lib\LLVMCodeGen.lib e:\llvm\llvm-17.0.6\lib\LLVMTarget.lib e:\llvm\llvm-17.0.6\lib\LLVMObjCARCOpts.lib e:\llvm\llvm-17.
0.6\lib\LLVMCodeGenTypes.lib e:\llvm\llvm-17.0.6\lib\LLVMIRPrinter.lib e:\llvm\llvm-17.0.6\lib\LLVMInterfaceStub.lib e:\llvm\llvm-17.0.6\lib\LLVMFileCheck.lib e:\llvm\llvm-17.0.6\lib\LLVMFuzzMutate.lib e:\llvm\llvm-17.0.6\lib\LLVMScalarOpts.lib e:\llvm\llvm-17.0.6\lib\LLVMInstCombine.lib e:\llvm\llvm-17
.0.6\lib\LLVMAggressiveInstCombine.lib e:\llvm\llvm-17.0.6\lib\LLVMTransformUtils.lib e:\llvm\llvm-17.0.6\lib\LLVMBitWriter.lib e:\llvm\llvm-17.0.6\lib\LLVMAnalysis.lib e:\llvm\llvm-17.0.6\lib\LLVMProfileData.lib e:\llvm\llvm-17.0.6\lib\LLVMSymbolize.lib e:\llvm\llvm-17.0.6\lib\LLVMDebugInfoBTF.lib e:\l
lvm\llvm-17.0.6\lib\LLVMDebugInfoPDB.lib e:\llvm\llvm-17.0.6\lib\LLVMDebugInfoMSF.lib e:\llvm\llvm-17.0.6\lib\LLVMDebugInfoDWARF.lib e:\llvm\llvm-17.0.6\lib\LLVMObject.lib e:\llvm\llvm-17.0.6\lib\LLVMTextAPI.lib e:\llvm\llvm-17.0.6\lib\LLVMMCParser.lib e:\llvm\llvm-17.0.6\lib\LLVMIRReader.lib e:\llvm\ll
vm-17.0.6\lib\LLVMAsmParser.lib e:\llvm\llvm-17.0.6\lib\LLVMMC.lib e:\llvm\llvm-17.0.6\lib\LLVMDebugInfoCodeView.lib e:\llvm\llvm-17.0.6\lib\LLVMBitReader.lib e:\llvm\llvm-17.0.6\lib\LLVMFuzzerCLI.lib e:\llvm\llvm-17.0.6\lib\LLVMCore.lib e:\llvm\llvm-17.0.6\lib\LLVMRemarks.lib e:\llvm\llvm-17.0.6\lib\LL
VMBitstreamReader.lib e:\llvm\llvm-17.0.6\lib\LLVMBinaryFormat.lib e:\llvm\llvm-17.0.6\lib\LLVMTargetParser.lib e:\llvm\llvm-17.0.6\lib\LLVMTableGen.lib e:\llvm\llvm-17.0.6\lib\LLVMSupport.lib e:\llvm\llvm-17.0.6\lib\LLVMDemangle.lib "E:\Windows Kits\10\Lib\10.0.22621.0\um\x64\psapi.lib" "E:\Windows Kit
s\10\Lib\10.0.22621.0\um\x64\shell32.lib" "E:\Windows Kits\10\Lib\10.0.22621.0\um\x64\ole32.lib" "E:\Windows Kits\10\Lib\10.0.22621.0\um\x64\uuid.lib" "E:\Windows Kits\10\Lib\10.0.22621.0\um\x64\advapi32.lib" E:\windows_home\.local\share\scoop\apps\crystal\current\lib\pcre2-8.lib E:\windows_home\.local\
share\scoop\apps\crystal\current\lib\gc.lib E:\windows_home\.local\share\visual_studio\versions\17.8\VC\Tools\MSVC\14.38.33130\lib\x64\libcmt.lib E:\windows_home\.local\share\scoop\apps\crystal\current\lib\iconv.lib E:\windows_home\.local\share\visual_studio\versions\17.8\VC\Tools\MSVC\14.38.33130\lib\x
64\libvcruntime.lib "E:\Windows Kits\10\Lib\10.0.22621.0\um\x64\WS2_32.lib" "E:\Windows Kits\10\Lib\10.0.22621.0\um\x64\kernel32.lib" E:\windows_home\.local\share\visual_studio\versions\17.8\VC\Tools\MSVC\14.38.33130\lib\x64\legacy_stdio_definitions.lib "E:\Windows Kits\10\Lib\10.0.22621.0\um\x64\DbgHel
p.lib" "E:\Windows Kits\10\Lib\10.0.22621.0\ucrt\x64\libucrt.lib"
E:\windows_home\.local\share\scoop\apps\crystal\current\src\llvm\ext>dir
 Volume in drive E is f
 Volume Serial Number is 4CCE-F67D

 Directory of E:\windows_home\.local\share\scoop\apps\crystal\current\src\llvm\ext

01/19/2024  10:37 AM    <DIR>          .
01/19/2024  10:37 AM    <DIR>          ..
01/18/2024  02:54 PM               908 find-llvm-config
01/18/2024  02:54 PM                53 llvm-versions.txt
01/18/2024  02:54 PM             3,239 llvm_ext.cc
               3 File(s)          4,200 bytes
               2 Dir(s)  2,873,171,189,760 bytes free
Losses commented 5 months ago

bin.zip

Confirmed that for the latest crystal, this LSP could be compiled successfully (but the speed is killing me).

Losses commented 5 months ago

image But it is not working, btw

dleslie commented 2 months ago

Fails to do much of anything at all in Windows, for me. Using git at 7bd95d95144676e1ffc358673831c44bf2c93660

#> time bin/crystalline.exe --version

real    0m0.114s
user    0m0.000s
sys     0m0.000s

Crystal 1.13:

#> crystal --version
Crystal 1.13.2 [879ec12]

LLVM: 18.1.1
Default target: x86_64-pc-windows-msvc

Built with:

crystal build ./src/crystalline.cr -o ./bin/crystalline --release --no-debug --progress -Dpreview_mt

But I also tried:

crystal build ./src/crystalline.cr -o ./bin/crystalline --progress

jaka2005 commented 2 months ago

But it is not working, btw

after small research i think it's looks like fails when set non-blocking input channel in the server lsp

image https://github.com/elbywan/crystal-lsp/blob/41bc7b311ca314f9cc717f33f0a963415aa8008a/src/server.cr#L82

with the next call trace:

  1. Crystalline::init
  2. Controller::new
  3. Controller::initialize
  4. Server::start
  5. Server::handshake
  6. Server::read
  7. STDIN::blocking (setter)

so, as the documentation says, STDIN is always blocking in windows

I tried to remove this code and the crashes stopped, but the code still doesn't look working (or it's too slow)