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

ghdl-ls Traceback on Windows #172

Open
gralco opened this issue Oct 25, 2023 · 7 comments
Open

ghdl-ls Traceback on Windows #172

gralco opened this issue Oct 25, 2023 · 7 comments

Comments

@gralco
Copy link

gralco commented Oct 25, 2023

Description
After installing ghdl using the latest commit, attempting to run ghdl-ls on Windows fails (tested on Fedora and it works fine).

Context

  • OS: Windows 10
  • Origin: Built from sources: 71287d46036e45f2bcafbc06e4b1ca1b37d48b85

Here's the traceback I get when trying to run ghdl-ls:

$ ghdl-ls
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "%LOCALAPPDATA%\Programs\Python\Python312\Scripts\ghdl-ls.exe\__main__.py", line 4, in <module>
  File "%LOCALAPPDATA%\Programs\Python\Python312\Lib\site-packages\pyGHDL\cli\lsp.py", line 58, in <module>
    from pyGHDL.lsp.vhdl_ls import VhdlLanguageServer
  File "%LOCALAPPDATA%\Programs\Python\Python312\Lib\site-packages\pyGHDL\lsp\vhdl_ls.py", line 4, in <module>
    from .workspace import Workspace
  File "%LOCALAPPDATA%\Programs\Python\Python312\Lib\site-packages\pyGHDL\lsp\workspace.py", line 12, in <module>
    import pyGHDL.libghdl.vhdl.nodes as nodes
  File "%LOCALAPPDATA%\Programs\Python\Python312\Lib\site-packages\pyGHDL\libghdl\vhdl\nodes.py", line 3662, in <module>
    @BindToLibGHDL("vhdl__nodes__get_mode_view_indication")
     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "%LOCALAPPDATA%\Programs\Python\Python312\Lib\site-packages\pyGHDL\libghdl\_decorator.py", line 161, in wrapper
    functionPointer = getattr(libghdl, subprogramName)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "%LOCALAPPDATA%\Programs\Python\Python312\Lib\ctypes\__init__.py", line 392, in __getattr__
    func = self.__getitem__(name)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "%LOCALAPPDATA%\Programs\Python\Python312\Lib\ctypes\__init__.py", line 397, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: function 'vhdl__nodes__get_mode_view_indication' not found. Did you mean: 'vhdl__nodes__get_subtype_indication'?
@tgingold
Copy link
Member

tgingold commented Oct 26, 2023 via email

@gralco
Copy link
Author

gralco commented Oct 26, 2023

I managed to build ghdl from source, but I first had to fix this:

$HOME/ghdl/src/grt/config/win32.c:183: undefined reference to `__intrinsic_setjmpex'
collect2.exe: error: ld returned 1 exit status
gnatlink: error when calling C:\msys64\mingw64\bin\gcc.exe
gnatmake: *** link failed.
make: *** [Makefile:217: ghdl_mcode.exe] Error 4

By changing #include <setjmp.h> with #include <setjmpex.h> in ghdl/src/grt/config/win32.c (as suggested here).

@gralco
Copy link
Author

gralco commented Oct 26, 2023

For reference, in order to make ghdl-ls to function within neovim I needed to add the following in my init.lua file:

if not require'lspconfig.configs'.ghdl_ls then
  require'lspconfig.configs'.ghdl_ls = {
    default_config = {
      cmd = {"ghdl-ls"};
      filetypes = {"vhdl"};
      root_dir = function(fname)
        local util = require'lspconfig'.util
        return vim.fs.dirname(vim.fs.find({'hdl-prj.json'}, {upward=true})[1]) or util.root_pattern('hdl-prj.json')(fname) or util.find_git_ancestor(fname) or vim.fn.getcwd() or util.path.dirname(fname) 
      end;
      settings = {};
    };
  }
end

require'lspconfig'.ghdl_ls.setup{}

Otherwise it the LSP will not be able to find / hook onto the root directory where the vhdl code is located. Doing single_file_mode = true is not enough to make it work.

@tgingold
Copy link
Member

tgingold commented Oct 26, 2023 via email

@gralco
Copy link
Author

gralco commented Oct 27, 2023

Is the dll path correct and does it exist? If yes, the error is probably due to a dependency (libgcc or libgnat). You need to update PATH.

I managed to fix that by building ghdl from source.

@gralco
Copy link
Author

gralco commented Nov 3, 2023

I somehow ran into this issue again. As it turns out, what I needed to do was to copy over my built libghdl-4_0_0_dev.dll into /c/msys64/mingw64/lib/libghdl-4_0_0_dev.dll, that's where it's looking for libghdl (where there was an old libghdl.dll that wasn't updated when doing make install).

@gralco
Copy link
Author

gralco commented Nov 7, 2023

On Fedora 38 the libghdl-4_0_0_dev.so that's built needs to be in ~/.local/lib/.

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