wangp / bower

A curses terminal client for the Notmuch email system
Other
119 stars 11 forks source link

Compile fail on Arch (libmer_std.a, libmer_rt.a missing) #107

Closed xxxserxxx closed 1 year ago

xxxserxxx commented 1 year ago

The error during build is:

** Error making `bower'.
/usr/bin/ld: cannot find /usr/lib/mercury/lib/asm_fast.gc/libmer_std.a: No such file or directory
/usr/bin/ld: cannot find /usr/lib/mercury/lib/asm_fast.gc/libmer_rt.a: No such file or directory
/usr/bin/ld: cannot find /usr/lib/mercury/lib/libgc.a: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:9: bower] Error 1
make[1]: Leaving directory '/home/ser/Software/bower-clean/src'
make: *** [Makefile:5: bower] Error 2

Mercury on Arch is broken; it can be made to build with a tweak to GCC -- Mercury at some point became unbuildable without this tweak:

  ./configure --prefix=/usr --mandir=/usr/share/man \
              --infodir=/usr/share/info \
              --disable-inefficient-grades
  echo "EXTRA_CFLAGS += -Wno-error=array-parameter" >> Mmake.params

I mention this as it may contribute to the problem. Without the --disable-inefficient-grades, Mercury takes 7 hours to compile on a modern laptop, which is a bit much for a package that (for me) is only installed to compile this one program.

Mercury: 22.01.3
Bower: c75e87d89a (HEAD), Sun May 8 17:44:37 2022 +1000
OS: Arch Linux 5.19.2 x86_64

I'm trying to recompile because, after an upgrade, bower started segfaulting trying to open threads.

This has been a recurring problem on Arch; is there any chance to build statically linked binaries in the releases?

wangp commented 1 year ago

The error during build is:

** Error making `bower'.
/usr/bin/ld: cannot find /usr/lib/mercury/lib/asm_fast.gc/libmer_std.a: No such file or directory
/usr/bin/ld: cannot find /usr/lib/mercury/lib/asm_fast.gc/libmer_rt.a: No such file or directory
/usr/bin/ld: cannot find /usr/lib/mercury/lib/libgc.a: No such file or directory
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:9: bower] Error 1
make[1]: Leaving directory '/home/ser/Software/bower-clean/src'
make: *** [Makefile:5: bower] Error 2

Ok, it looks like asm_fast.gc grade wasn't installed but it's still set as the default (but somehow got this far?). I recommend using the hlc.gc grade instead. Add this to your src/Mercury.options file:

MCFLAGS += --grade hlc.gc

I'll probably make this change.

Mercury on Arch is broken; it can be made to build with a tweak to GCC -- Mercury at some point became unbuildable without this tweak:

  ./configure --prefix=/usr --mandir=/usr/share/man \
              --infodir=/usr/share/info \
              --disable-inefficient-grades
  echo "EXTRA_CFLAGS += -Wno-error=array-parameter" >> Mmake.params

Thanks, didn't know about -Wno-error=array-parameter. Is Arch using GCC 12?

I mention this as it may contribute to the problem. Without the --disable-inefficient-grades, Mercury takes 7 hours to compile on a modern laptop, which is a bit much for a package that (for me) is only installed to compile this one program.

That's far too long. Here's the script I use to install Mercury on my system:

#!/bin/bash
set -e

libgrades=${1:-"asm_fast.gc,asm_fast.gc.debug.stseg,asm_fast.gc.decldebug.stseg,hlc.gc,hlc.gc.memprof,hlc.gc.prof,hlc.par.gc,asm_fast.gc.profdeep.stseg"}
cat <<EOF
PATH=/usr/bin:/bin
./configure --prefix=$HOME/local/stow/$(basename "$PWD") \\
  --enable-libgrades=$libgrades \\
  --with-default-grade=hlc.gc \\
  --with-cc=$HOME/bin/ccache/gcc
time nice make PARALLEL=-j"$(nproc)" install
EOF

That takes about 25-30 minutes on my desktop machine (4 core, 8 thread), which is nothing special.

If you're only installing Mercury to build bower, you don't need all those grades. hlc.gc is all you need.

Mercury: 22.01.3 Bower: c75e87d89a (HEAD), Sun May 8 17:44:37 2022 +1000 OS: Arch Linux 5.19.2 x86_64

I'm trying to recompile because, after an upgrade, bower started segfaulting trying to open threads.

This has been a recurring problem on Arch; is there any chance to build statically linked binaries in the releases?

I'll consider it, but it sounds too much like work :/

xxxserxxx commented 1 year ago

This really isn't my area of expertise, however: the Mercury build does create the static (.a) libs bower is looking for, but the current Mercury install target only installs dynamic libs. This causes problems with the bower build, because it's not dynamically linking these.

EDIT This was broken (for me) by commit 12978b70, which changed to linking statically by default in Mercury.options. Anyone who's having this issue, just re-comment that line back out.

I'm guessing this affects anyone who's only using Mercury to compile Bower, because the default Mercury make system -- if you follow the README instructions -- does not install the static Mercury libs.

xxxserxxx commented 1 year ago

Ok, it looks like asm_fast.gc grade wasn't installed but it's still set as the default (but somehow got this far?). I recommend using the hlc.gc grade instead. Add this to your src/Mercury.options file:

I think (I'm repeating my other comment, sorry) that it's because in 12978b7 you changed to building static by default; the default Mercury build/install process doesn't install the static Mercury libs, only the dynamic ones. Someone would have to enable installing the static libs in the configure step of the Mercury build, which Arch doesn't do, so people who only get Mercury pulled as a dependency to build bower probably will miss this.

Mercury on Arch is broken; it can be made to build with a tweak to GCC -- Mercury at some point became unbuildable without this tweak: ... Thanks, didn't know about -Wno-error=array-parameter. Is Arch using GCC 12?

Yes, it has been for a while; however, I lied: the packager of Mercury on Arch saw my comment in AUR and updated the package to add this, so Mercury should install for users now.

That's far too long. Here's the script I use to install Mercury on my system: ... libgrades=${1:-"asm_fast.gc,asm_fast.gc.debug.stseg,asm_fast.gc.decldebug.stseg,hlc.gc,hlc.gc.memprof,hlc.gc.prof,hlc.par.gc,asm_fast.gc.profdeep.stseg"}

So, you're selecting specific grades? The packager used --disable-inefficient-grades and later just selects LIBGRADES=asm_fast.gc. I don't know anything about Mercury, but that's what people who install Mercury on Arch via AUR get.

That takes about 25-30 minutes on my desktop machine (4 core, 8 thread), which is nothing special.

Dang. I haven't programmed in anything seriously but Go for the past decade, so I start to get annoyed if anything takes longer than a couple of minutes to compile. It's why I won't touch Rust any more. I'm sure Python people balk at even the word "compile," so perspective is everything.

This has been a recurring problem on Arch; is there any chance to build statically linked binaries in the releases?

I'll consider it, but it sounds too much like work :/

It might be; it depends on how many target architectures you support. Whatever faults github has, the automated build system is pretty easy. Most of the fiddly part is setting up private keys and stuff to upload built assets.

In any case, I suggested to the package maintainer on Arch to undo the static build change in Mercury.options with:

sed '/mercury-linkage static/s/^/#/' src/Mercury.options

which fixes the issue and gets bower building on Arch again. Hopefully they'll pick it up.

Thanks!

xxxserxxx commented 1 year ago

Closing, as I found a solution.