AdaCore / ada_language_server

Server implementing the Microsoft Language Protocol for Ada and SPARK
GNU General Public License v3.0
226 stars 54 forks source link

What's the correct way to build ALS on Windows 10 with Alire ? #1103

Open NicoPy opened 1 year ago

NicoPy commented 1 year ago

I've created a new project with alr get ada_language_server. This created a new folder named ada_language_server_23.0.0_66f2e7fb.

alr build generates ada_language_server.exe in .obj/server folder. alr run does nothing (except running a build). alr run ada_language_server.exe neither.

Running ada_language_server.exe manually opens an error dialog box saying that libgmp-10.dll is not found.

image

In the dependencies, Alire installed and compiled gnatcoll_gmp_23.0.0_57de4a1a. However, there is no libgmp-10.dll generated.

Did I miss something ?

Fabien-Chouteau commented 1 year ago

Hi @NicoPy, libgmp-10.dll is provided by msys2 on Windows so you have to run you executable in an msys2 mingw64 shell. It's a big limitation of Alire on Windows at the moment, the Alire project is looking for way to improve that.

NicoPy commented 1 year ago

Thanks for your answer.

I didn't think about this. So, I tried running ada_language_server.exe from Msys2. The previous error is gone but :

ada_language_server.exe exits a few seconds after launch without any message.

When running ada_language_server.exe --help I get :

$ ./ada_language_server.exe --help
Command line interface for the Ada Language Server
Usage: ada_language_server.exe [switches] [arguments]

 --tracefile=ARG Full path to a file containing traces configuration
 --language-gpr  Handle GPR language instead of Ada
 --version       Display the program version
 --help          Display this help
Segmentation fault

Looks like there is still something wrong somewhere (please note the segmentation fault).

reznikmm commented 1 year ago

try to export LIBRARY_TYPE=static before running alr build. This way you could avoid messing with .dll loading/searching.

NicoPy commented 1 year ago

I used powershell syntax : $Env:LIBRARY_TYPE='static'

Unfortunately, the build did not finished successfully :

.
.
.
Bind
   [gprbind]      lsp-ada_driver.bexch
   [Ada]          lsp-ada_driver.ali
Link
   [link]         lsp-ada_driver.adb
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(lt20-get_str.o):(.text+0x2ad): undefined reference to `__stack_chk_fail'
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(lt20-get_str.o):(.rdata$.refptr.__stack_chk_guard[.refptr.__stack_chk_guard]+0x0): undefined reference to `__stack_chk_guard'
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(mod.o):(.text+0x10f): undefined reference to `__stack_chk_fail'
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(lt31-mul.o):(.text+0x37e): undefined reference to `__stack_chk_fail'
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(realloc.o):(.text+0x47): undefined reference to `__stack_chk_fail'
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(lt43-set_str.o):(.text+0x2d3): undefined reference to `__stack_chk_fail'
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(tdiv_q.o):(.text+0x22f): undefined reference to `__stack_chk_fail'
c:/users/nicolas/.config/alire/cache/dependencies/gnat_native_12.1.2_3126cd6f/bin/../lib/gcc/x86_64-w64-mingw32/12.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: C:/Users/Nicolas/.cache/alire/msys64/mingw64/lib/../lib\libgmp.a(tdiv_r.o):(.text+0x2ec): more undefined references to `__stack_chk_fail' follow
collect2.exe: error: ld returned 1 exit status
gprbuild: link of lsp-ada_driver.adb failed
gprbuild: failed command was: C:\Users\Nicolas\.config\alire\cache\dependencies\gnat_native_12.1.2_3126cd6f/bin\g++.exe lsp-ada_driver.o @C:\Users\Nicolas\AppData\Local\Temp\GNAT-TEMP-000057.TMP
ERROR: Command ["gprbuild", "-s", "-j0", "-p", "-P", "Z:\ada\alire_projects\ada_language_server_23.0.0_66f2e7fb\gnat/lsp_server.gpr"] exited with code 4
ERROR: Compilation failed.

It looks like a library is missing.

Notes :