Opened 5 years ago

Last modified 5 years ago

#21174 new enhancement

MPIR: Do not install two (almost) identical libraries (with --enable-gmpcompat)

Reported by: leif Owned by:
Priority: major Milestone: sage-7.4
Component: packages: standard Keywords: libgmpxx libmpirxx gmp.h mpir.h
Cc: embray Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by leif)

When configuring MPIR with --enable-gmpcompat (which we do in Sage by default), (almost) the same files get installed under two different names:

  • mpir.h and gmp.h -- identical copies (no links)
  • mpirxx.h and gmpxx.h -- identical copies (no links)
  • libmpir.a and libgmp.a -- identical copies (no links)
  • libmpirxx.a and libgmpxx.a -- identical copies (no links)

More critical, as of MPIR 2.7.2, on ELF systems:

  • libmpir.so[.16[.6.2]] and libgmp.so[.16[.6.2]] -- only the soname differs
  • libmpirxx.so[.8[.4.2]] and libgmpxx.so[.8[.4.2]] -- only the soname differs

(Similar on Darwin and Cygwin.)

This can lead to weird and hard-to-debug errors if programs or libraries accidentally link to both libmpir and libgmp (which may also happen if a program or library links to libraries A and B where A just uses libmpir and B only libgmp); see for example this thread on sage-devel.


Related: #21188

Change History (12)

comment:1 Changed 5 years ago by leif

  • Description modified (diff)

Typo.

comment:2 Changed 5 years ago by leif

  • Description modified (diff)

comment:3 Changed 5 years ago by leif

For the first four instances, we could simply install symbolic links (on systems that support that) from *mpir* to their respective *gmp* counterparts (maybe also hard links, but symlinks seem more appropriate).

For the shared libraries, on ELF systems (and presumably analogously on Darwin) it would be sufficient to install just the GMP-named libraries and symbolic links from libmpir[xx].so to libgmp[xx].so, respectively.

Then the linker could (still) pick up -lmpir (aka libmpir.so, in a shared link) and would record libgmp.so.16 as the soname in the DT_NEEDED tag; analogous for -lmpirxx.

comment:4 Changed 5 years ago by leif

For the static libraries, it is less likely that accidentally (or unawarely) linking to both (as mentioned in the description, with libraries A and B for example) will cause trouble, although that's not impossible.

(Shared libraries could as well have linked to one of the static libraries, reexporting symbols from GMP/MPIR, but that would presumably be a mistake by itself.)

comment:5 Changed 5 years ago by leif

I'll probably suggest a patch upstream adding at least a configure option --only-gmpcompat which would not install any of the *mpir* files in addition.

comment:6 follow-up: Changed 5 years ago by embray

+1 to all of the above.

Though within Sage itself, if we have taken care to remove explicit "mpir" references then maybe even the symlinks shouldn't be necessary. I have a patch to Singular that I will post in a separate ticket that removes the dangling "mpir" references that caused the problem in the first place.

comment:7 in reply to: ↑ 6 ; follow-up: Changed 5 years ago by leif

Replying to embray:

+1 to all of the above.

Though within Sage itself, if we have taken care to remove explicit "mpir" references then maybe even the symlinks shouldn't be necessary.

I don't have a strong opinion on whether to install links or not; without them, we hopefully won't run into the mess you had again, but I'm open for different solutions on Cygwin anyway (I cannot test myself). IIRC on Cygwin it's harder to separate "Sage libraries" from the system's, and it's probably not uncommon for Cygwin users to have both MPIR and GMP installed "system-wide".


I have a patch to Singular that I will post in a separate ticket that removes the dangling "mpir" references that caused the problem in the first place.

CC me then.

comment:8 in reply to: ↑ 7 ; follow-up: Changed 5 years ago by embray

Replying to leif:

Replying to embray:

+1 to all of the above.

Though within Sage itself, if we have taken care to remove explicit "mpir" references then maybe even the symlinks shouldn't be necessary.

I don't have a strong opinion on whether to install links or not; without them, we hopefully won't run into the mess you had again, but I'm open for different solutions on Cygwin anyway (I cannot test myself). IIRC on Cygwin it's harder to separate "Sage libraries" from the system's, and it's probably not uncommon for Cygwin users to have both MPIR and GMP installed "system-wide".

I don't agree, no. It's not harder to separate, and there's no reason Cygwin users should have both installed any more than anyone else.

comment:9 in reply to: ↑ 8 Changed 5 years ago by leif

Replying to embray:

Replying to leif:

Replying to embray:

+1 to all of the above.

Though within Sage itself, if we have taken care to remove explicit "mpir" references then maybe even the symlinks shouldn't be necessary.

I don't have a strong opinion on whether to install links or not; without them, we hopefully won't run into the mess you had again, but I'm open for different solutions on Cygwin anyway (I cannot test myself). IIRC on Cygwin it's harder to separate "Sage libraries" from the system's, and it's probably not uncommon for Cygwin users to have both MPIR and GMP installed "system-wide".

I don't agree, no. It's not harder to separate, and there's no reason Cygwin users should have both installed any more than anyone else.

No idea, I thought I had read something like that a while ago.

So you're in favour of not installing links (which AFAIK wouldn't be possible on Cygwin anyway)?

comment:10 Changed 5 years ago by leif

  • Description modified (diff)

comment:11 follow-up: Changed 5 years ago by embray

No, links work in Cygwin. Hard links and symlinks.

comment:12 in reply to: ↑ 11 Changed 5 years ago by leif

Replying to embray:

No, links work in Cygwin. Hard links and symlinks.

Good to know, one thing less to care about (in general).

Note: See TracTickets for help on using tickets.