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

Build failure in alire/macOS #1150

Open simonjwright opened 1 year ago

simonjwright commented 1 year ago

After alr get ada_language_server, this happens:

Running post_fetch actions for ada_language_server=23.0.0...
sed: 1: "gnat/lsp_server.gpr": extra characters at the end of g command
error: A post-fetch action failed, re-run with -vv -d for details

I’ve found a working fix: it seems that this action needs the -E or -r switch.

[[actions]]
command = [
"sed",
"-i",                                 <<< here
"-e/gpr2/s/^/--  /",
"gnat/lsp_server.gpr",
]
directory = "."
type = "post-fetch"

The man page for -E says

Interpret regular expressions as extended (modern) regular expressions rather than basic regular expressions (BRE's). The re_format(7) manual page fully describes both formats.

The man page for -r says

Same as -E for compatibility with GNU sed.

There’s a note: "The -E option[ is a] non-standard FreeBSD extension[s] and may not be available on other operating systems."

reznikmm commented 1 year ago

Thank you @simonjwright to trying ALS on Mac OS X (apple silicon?). This sed invocation is a quick fix to drop dependency on libgpr2, not used in ALS 23.0.0. I execute

sed -i "-e/gpr2/s/^/--  /" gnat/lsp_server.gpr

The -i switch in GNU sed means in-place:

  -i[SUFFIX], --in-place[=SUFFIX]

          edit files in place (makes backup if SUFFIX supplied)

If sed in Mac OS doesn't support -i then -E nor -r won't help, unfortunately. You can comment out that line in gnat/lsp_server.gpr in any editor then continue. Just find with "gpr2.gpr"; and comment it out.

This trick won't be needed in next version of ALS, but libgpr2 needed as a dependency. So I'm closing this issue, unless you can propose other simple way to comment this line.

reznikmm commented 1 year ago

Found this discussion. Could you try

[[actions]]
command = [
"sed",
"-i.bak",
"-e/gpr2/s/^/--  /",
"gnat/lsp_server.gpr",
]
directory = "."
type = "post-fetch"

Or

[[actions]]
command = [
"sed",
"-i",
"",
"-e/gpr2/s/^/--  /",
"gnat/lsp_server.gpr",
]
directory = "."
type = "post-fetch"
simonjwright commented 1 year ago

Both of those suggestions worked. My previous tries worked because I’d accidentally set the backup prefix to -r!

And yes, this is Apple silicon.

One problem I came up against was

   [Ada]          tagada_marshalling_lib.adb
   [Ada]          tgen-types.adb
tagada_marshalling_lib.adb:633:19: warning: types for unchecked conversion have different sizes [-gnatwz]
tagada_marshalling_lib.adb:738:19: warning: types for unchecked conversion have different sizes [-gnatwz]

which is because, on aarch64 (at any rate, gcc 13.1.0’s system.ads), Long_Long_Float is a mere 64 bits long. This is in libadalang, but seems to have been dropped from the current commits.

Also the objcopy issue, here & in libadalang_tools.

reznikmm commented 1 year ago

May be you can suppress -gnatwe with

alr build -- -gnatwn