Building ada_language_server on OpenBSD

Hey, I have gnat-15.2 and gprbuild-18 working. I was able to build Alire as well (from master branch).

$ alr get ada_language_server

Fails with:

◴ Solving dependencies: 81.48% solved (22/27 deps, 1/72 solutions left)… Looking for external crate: make… make: unknown option – -
usage: make \[-BeiknpqrSst\] \[-C directory\] \[-D variable\] \[-d flags\] \[-f mk\]
\[-I directory\] \[-j max_jobs\] \[-m directory\] \[-V variable\]
\[NAME=value …\] \[target …\]
warn:
warn:    New solution is incomplete.
warn:    +        adasat            26.0.0 (new,indirect)
warn:    +📦      gnat              15.2.0 (new,gnat_external,indirect,executable in path)
warn:    +        gnatcoll          26.0.0 (new)
warn:    +        gnatcoll_gmp      26.0.0 (new,indirect)
warn:    +        gnatcoll_iconv    26.0.0 (new,indirect)
warn:    +        gnatcoll_minimal  26.0.0 (new,indirect)
warn:    +        gnatcoll_projects 26.0.0 (new,indirect)
warn:    +📦      gprconfig_kb      26.0.0 (new,indirect,binary)
warn:    +        langkit_support   26.0.0 (new,indirect)
warn:    +        libadalang        26.0.0 (new)
warn:    +        libadalang_tools  26.0.0 (new)
warn:    +        libgnatdoc        26.0.0 (new)
warn:    +        libgnatformat     26.0.0 (new)
warn:    +        libgpr            26.0.0 (new,indirect)
warn:    +        libgpr2           26.0.0 (new,indirect)
warn:    +        liblal_refactor   26.0.0 (new)
warn:    +        markdown          26.0.0 (new,indirect)
warn:    +        prettier_ada      26.0.0 (new)
warn:    +        spawn             26.0.0 (new)
warn:    +        templates_parser  26.0.0 (new,indirect)
warn:    +        vss_extra         26.0.0 (new)
warn:    +        vss_text          26.0.0 (new)
warn:    +        xdiff             26.0.0 (new)
warn:    +        xmlada            26.0.0 (new,indirect)
warn:    Missing:
warn:    +❗      libgmp            \*      (new,indirect,missing)
warn:    +❗      make              \*      (new,indirect,missing)
warn:
warn: Could not find a complete solution for ada_language_server=26.0.0
Build will fail unless externals are made available, do you want to continue?
\[Y\] Yes  \[N\] No  (default is No)

Building using ./scripts/build_als.sh fails with:

Bootstrap Liblktlang needs to be built
Building the generated source code
Building for config (BuildMode.dev, LibraryType.relocatable)
GPRBUILD Pro 18.0w (19940713) (x86_64-unknown-openbsd)
Copyright (C) 2004-2016, AdaCore
 211 lines: No errors
TMPDIR = "/tmp/GPR.90956"
/usr/local/bin/gprconfig --batch -o /tmp/GPR.90956/GNAT-TEMP-000001.TMP --target=x86_64-unknown-openbsd --fallback-targets --config=c,,,, --config=ada,,,,
Checking configuration /tmp/GPR.90956/GNAT-TEMP-000001.TMP
Setting the default project search directories
   Adding directory "/usr/local/x86_64-unknown-openbsd/share/gpr"
   Adding directory "/usr/local/x86_64-unknown-openbsd/lib/gnat"
   Adding directory "/usr/local/share/gpr"
   Adding directory "/usr/local/lib/gnat"

==============Messages for file: /home/tomek/depot/ada_language_server/subprojects/langkit_support/lkt/bootstrap/liblktlang.gpr
     6. with "gnatcoll_core";
             |
        >>> imported project file "gnatcoll_core" not found

==============Messages for file: /home/tomek/depot/ada_language_server/subprojects/gnatcoll/gnatcoll.gpr
    23. with "gnatcoll_core";
             |
        >>> imported project file "gnatcoll_core" not found
        >>> imported by "/home/tomek/depot/ada_language_server/subprojects/gnatcoll/gnatcoll.gpr"
        >>> imported by "/home/tomek/depot/ada_language_server/alire/cache/dependencies/gnatcoll_gmp_24.0.0_e90c5b4d/gmp/gnatcoll_gmp.gpr"
        >>> imported by "/home/tomek/depot/ada_language_server/subprojects/langkit_support/lkt/bootstrap/liblktlang.gpr"

    24. with "gnatcoll_projects";
             |
        >>> imported project file "gnatcoll_projects" not found
        >>> imported by "/home/tomek/depot/ada_language_server/subprojects/gnatcoll/gnatcoll.gpr"
        >>> imported by "/home/tomek/depot/ada_language_server/alire/cache/dependencies/gnatcoll_gmp_24.0.0_e90c5b4d/gmp/gnatcoll_gmp.gpr"
        >>> imported by "/home/tomek/depot/ada_language_server/subprojects/langkit_support/lkt/bootstrap/liblktlang.gpr"

==============Messages for file: /home/tomek/depot/ada_language_server/subprojects/prettier_ada/prettier_ada.gpr
     6. with "gnatcoll_core";
             |
        >>> imported project file "gnatcoll_core" not found
        >>> imported by "/home/tomek/depot/ada_language_server/subprojects/prettier_ada/prettier_ada.gpr"
        >>> imported by "/home/tomek/depot/ada_language_server/subprojects/langkit_support/lkt/bootstrap/liblktlang.gpr"

 211 lines: 12 errors
gprbuild: "/home/tomek/depot/ada_language_server/subprojects/langkit_support/lkt/bootstrap/././liblktlang.gpr" processing failed
Build failed: error while running gprbuild -p -j2 -P/home/tomek/depot/ada_language_server/subprojects/langkit_support/lkt/bootstrap/././liblktlang.gpr -XBUILD_MODE=dev -XLIBRARY_TYPE=relocatable -XGPR_BUILD=relocatable -XXMLADA_BUILD=relocatable -m -j0 -vh:
    Command '['gprbuild', '-p', '-j2', '-P/home/tomek/depot/ada_language_server/subprojects/langkit_support/lkt/bootstrap/././liblktlang.gpr', '-XBUILD_MODE=dev', '-XLIBRARY_TYPE=relocatable', '-XGPR_BUILD=relocatable', '-XXMLADA_BUILD=relocatable', '-m', '-j0', '-vh']' returned non-zero exit status 5.
error: Command ["bash", "-x", "./scripts/build_als.sh", "build_langkit_raw"] exited with code 1

Any hints how to approach this?

I’ve made some script edits to pick up correct bash and python3 paths, I know BSD’s make is different. Any help would be appreciated :folded_hands:

1 Like

Well, build with alr get ada_language_server does not actually fails. It just ask you if you want to continue. If you provide make wrapper for gnu make in the PATH, will build success?

Wrapped make and tar and made some progress. Hopefully it will work now (it’s crunching):

tomek@openbsd ~/bin> cat make
#!/bin/sh
if [ "$1" = "--version" ] || [ "$1" = "-v" ]; then
  echo "GNU Make 4.3"
  echo "This program built for x86_64-unknown-openbsd"
  exit 0
fi
exec /usr/local/bin/gmake "$@"
tomek@openbsd ~/bin> cat tar
#!/bin/sh
# Inject -z for .tar.gz/.tgz if not already present
case "$*" in
  *-z*) ;;
  *.tar.gz*|*.tgz*) exec /bin/tar -z "$@" ;;
esac
exec /bin/tar "$@"
1 Like

Oh…

   [C]            libc-wrappers.c
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c: In function '__gnatcoll_posix_fadvise':
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:275:29: error: 'POSIX_FADV_NORMAL' undeclared (first use in this function)
  275 |          effective_advice = POSIX_FADV_NORMAL; break;
      |                             ^~~~~~~~~~~~~~~~~
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:275:29: note: each undeclared identifier is reported only once for each function it appears in
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:277:29: error: 'POSIX_FADV_SEQUENTIAL' undeclared (first use in this function)
  277 |          effective_advice = POSIX_FADV_SEQUENTIAL; break;
      |                             ^~~~~~~~~~~~~~~~~~~~~
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:279:29: error: 'POSIX_FADV_RANDOM' undeclared (first use in this function)
  279 |          effective_advice = POSIX_FADV_RANDOM; break;
      |                             ^~~~~~~~~~~~~~~~~
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:281:29: error: 'POSIX_FADV_NOREUSE' undeclared (first use in this function)
  281 |          effective_advice = POSIX_FADV_NOREUSE; break;
      |                             ^~~~~~~~~~~~~~~~~~
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:283:29: error: 'POSIX_FADV_WILLNEED' undeclared (first use in this function)
  283 |          effective_advice = POSIX_FADV_WILLNEED; break;
      |                             ^~~~~~~~~~~~~~~~~~~
/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:288:11: error: implicit declaration of function 'posix_fadvise' [-Wimplicit-function-declaration]
  288 |    return posix_fadvise(fd, (off_t) offset, (off_t) length, effective_advice);
      |           ^~~~~~~~~~~~~

   compilation of libc-wrappers.c failed

gprbuild: *** compilation phase failed
error: Command ["gprbuild", "-s", "-j0", "-p", "-P", "/home/tomek/depot/ada_language_server_26.0.0_46c28e2c/alire/cache/dependencies/libadalang_tools_26.0.0_5e58b568/src/lal_tools.gpr"] exited with code 4
error: Compilation failed.

Still fighting!

1 Like

Regarding the last error. Prior to starting compilation try this:

export CFLAGS='-Wno-error=implicit-function-declaration -Wno-error=int-conversion'

in order to prevent GCC from treating warnings about legal C code as errors. Enhance the list as necessary.

2 Likes

Solved this with editing alire/cache/dependencies/gnatcoll_26.0.0_cc5dd0a1/core/src/os/unix/libc-wrappers.c:

#if defined(__OpenBSD__)
int __gnatcoll_posix_fadvise(int fd, long offset, long length, int advice) {
   return 0;
}
#else
....
1 Like

Ugh, I made it build, but it segfaults when starting:

(gdb) run --version
Starting program: /home/tomek/depot/ada_language_server_26.0.0_46c28e2c/.obj/server/ada_language_server --version
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 5, should be 2) [in module /home/tomek/depot/ada_language_server_26.0.0_46c28e2c/.obj/server/ada_language_server]
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 5, should be 2) [in module /usr/local/lib/libestdc++.so.21.0]
Error while reading shared library symbols:
Dwarf Error: wrong version in compilation unit header (is 4, should be 2) [in module /usr/libexec/ld.so]

Program received signal SIGSEGV, Segmentation fault.

I’m not sure if I want to continue this rabbit hole :frowning:

Are you using the default gdb that comes with the OS? If so you may find better luck with the gdb from the ports tree which is up to date. The default gdb is very old. To run the new one, it is egdb that you have to use.

1 Like

My recommendation with Ada is always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always, always… Mmmm… I may be forgetting an always somewhere, but whatever.

Ah, yes, ALWAYS say catch assert and catch exception. Really, just run your Ada code with assertions and debugging symbols compiled in, and see the debugger tell you exactly where things went bad. It really is that simple.

In your case, also maybe catch signal and others may be useful.

Best regards,
Fer

1 Like