New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix dependencies on PARI #19610
Comments
Author: Jeroen Demeyer |
Commit: |
New commits:
|
This comment has been minimized.
This comment has been minimized.
comment:4
Maybe I misunderstood the purpose of this ticket (cf. the description I added), but after pulling the branch here, (Probably you just intended a proper rebuild of it upon changes to libgmp, but the patch looks as if you intended to remove the libraries from the extension module.) IMHO at most PARI should get linked to it. |
comment:5
Ok, I see, in # distutils: libraries = gmp pari Do we really need |
comment:6
Certainly AFAICS, the declarations are only needed/used in |
comment:7
The following works for me to get rid of GMP (i.e., avoids overlinking diff --git a/src/sage/ext/interrupt/implementation.c b/src/sage/ext/interrupt/implementation.c
index 7b96199..55dac47 100644
--- a/src/sage/ext/interrupt/implementation.c
+++ b/src/sage/ext/interrupt/implementation.c
@@ -42,7 +42,18 @@ AUTHORS:
#ifdef __linux__
#include <sys/prctl.h>
#endif
-#include <pari/pari.h>
+
+#include <pari/paricfg.h>
+#include <pari/parisys.h> /* needed for THREAD and VOLATILE */
+#if 0
+/* further includes would be needed, see below */
+#include <pari/paricom.h> /* needed for PARI_SIGINT_* */
+#else
+/* It's hard to selectively include PARI headers (i.e., declarations), */
+/* so we *copy* them (from pari/paricom.h): */
+extern THREAD VOLATILE int PARI_SIGINT_block, PARI_SIGINT_pending;
+#endif
+
#include "interrupt/struct_signals.h"
#include "interrupt/interrupt.h"
diff --git a/src/sage/ext/interrupt/interrupt.pxd b/src/sage/ext/interrupt/interrupt.pxd
index 3818447..c1a3b54 100644
--- a/src/sage/ext/interrupt/interrupt.pxd
+++ b/src/sage/ext/interrupt/interrupt.pxd
@@ -1,4 +1,5 @@
# distutils: depends = INTERRUPT_DEPENDS
+# distutils: libraries = pari
#
# NOTE: these functions are actually defined in "macros.h".
# However, we intentionally do not mention that file here, because
diff --git a/src/sage/ext/interrupt/interrupt.pyx b/src/sage/ext/interrupt/interrupt.pyx
index ed4552a..97dd96d 100644
--- a/src/sage/ext/interrupt/interrupt.pyx
+++ b/src/sage/ext/interrupt/interrupt.pyx
@@ -23,9 +23,6 @@ from libc.signal cimport *
from libc.stdio cimport freopen, stdin
from cpython.exc cimport PyErr_Occurred
-# Needed for PARI_SIGINT_block in implementation.c:
-cimport sage.libs.pari.paridecl
-
cdef extern from "interrupt/implementation.c":
sage_signals_t _signals "_signals"
void setup_sage_signal_handler() nogil (preliminary hack) Probably another |
comment:8
P.S.: The copied declarations are IMHO unlikely to change. |
comment:9
Replying to @nexttime:
Anyway, I pushed a slightly cleaner version to u/leif/19610_reviewer-remove_libgmp_from_interrupt.so. |
comment:10
Replying to @nexttime:
You did. |
This comment has been minimized.
This comment has been minimized.
comment:11
Replying to @nexttime:
Yes, because PARI needs gmp:
|
comment:12
Replying to @jdemeyer:
Well, of course PARI needs GMP, but not (necessarily) modules using PARI; that's a transitive dependency. Unless you link statically, you don't have to explicitly specify GMP (and you shouldn't), because the dependency of PARI on GMP is recorded in If GMP changes, PARI will get rebuilt, and hence also modules depending on PARI. The reason |
comment:13
Replying to @nexttime:
Do you have a reference for this? It's the first time I hear somebody say this. |
comment:15
The linked documents are only about Linux (thanks for the links though). I'm not at all convinced that the same holds for all operating systems. |
comment:16
If we decide to stop "overlinking", that would be a major change in how we build Sage. It is something which should be discussed on |
comment:17
What you are proposing is not portable: see the first few slides of https://people.debian.org/~vorlon/dependency-hell/img0.html |
comment:18
Replying to @jdemeyer:
No. We've cleaned up Note that it's (only) the common case that you don't have to specify libraries used by the libraries you use. (In particular, building the whole Sage library with the linker option The main exceptions are:
|
comment:21
Replying to @jdemeyer:
ROFL, e.g. #18777? (The others date back much longer...) |
comment:23
Replying to @nexttime:
I doubt that the following statement is true on all operating systems:
|
comment:24
Anyway, can we please go back to the review of this ticket? If you want to discuss more general linking issues, open a thread on |
comment:25
Replying to @jdemeyer:
Well, you asked general questions.
I still don't like the IMHO redundant Perhaps cc some more reviewers, e.g. François. |
comment:26
Replying to @jdemeyer:
There are certainly OSs which don't have shared/dynamic libraries... But besides that their names/extensions vary, the above holds for all platforms supported by Sage, AFAIKTM. |
comment:27
Replying to @nexttime:
It does need GMP since it uses PARI which needs GMP. It's true that the Cython code doesn't use anything of PARI or GMP, but the C code in |
comment:28
OK, you wanted me in on this.
but
So
Equivalently on OS X everything will be fine so long as all the Yes it will break if your system only use static libraries. Static libraries don't know where to get their other needed bits - unless you bundle them in in the first place. I don't know if cygwin is properly equipped to deal with something like a Linking with |
comment:29
I should say I haven't read the whole thread, and now that I see more of it. there are some points that can be made:
A case in point is vanilla If libpari was underlinked like that you would have to provide your libgmp/libmpir all the time. Regarding your slides Gentoo applies "the chasing your tail method" (recompile on soname change). I think If your handling of soname is not done properly or your are overlinking you are exposing yourself to excessive rebuilding. Making sure your handling of soname is right is the hard bit. Only now do we have interesting mechanism that will trigger rebuild on soname change in Gentoo and I won't pretend that every gentoo dev understand them properly. |
comment:30
One more to be in rant mode: dev that thinks soname and install_name are not important or even ignorant of them should be sent in re-education before touching a library (I am looking at you Fredrick Johansson with your |
comment:31
Replying to @jdemeyer:
It is (tautologically) true on every operating system where you can link shared libraries to other shared libraries. I don't know of an OS where you can't link libraries to libraries, but I'd bet that some obscure platform did that back in the old days. Today certainly not. |
comment:32
Replying to @vbraun:
I don't understand why this would be tautologically true. It might be true whenever the linker is sufficiently clever, but I don't know if that's the fact on all operating systems. I have particular doubts about Cygwin, because I know that linker command lines often have to be changed for Cygwin. |
comment:34
We should get rid of |
comment:36
Argh yes, I did intend to post to the NTL ticket. |
comment:37
I'll check the recursive dep on Cygwin when I have some time. |
comment:38
This ticket has nothing to do with Cygwin, it's only about adding a dependency. |
comment:39
This is getting a bit too long, so let me try to summarize: Replying to @jdemeyer:
But the dependency is wrong (interrupt does not depend on gmp). Cygwin doesn't really have shared libraries, it uses a static library hack (the Cygwin import library) at link time. So the real question is should we
|
comment:40
Replying to @vbraun:
Sage has always chosen the first option, so there are probably many overlinked modules in Sage. So: can we please just focus on the bug that this ticket is about? If you want to discuss overlinking, please do it somewhere else. |
comment:41
Let me also summarize: this ticket is about adding a dependency of This ticket has absolutely nothing to do with linking and it does not change anything related to linking. |
comment:42
It seems that we have a branch for each approach already so we might just as well merge the one we want to pursue in the future. Jean-Pierre, do you have any thoughts on Cygwin? IMHO the "always overlink" approach is simpler and the cost of unnecessarily compiling an extension module is low (its just a single source file, no extra configure and recursive make). |
comment:43
Can we please stop this? This has NOTHING to do with linking, why is that so hard to understand? |
comment:44
Or maybe I should turn the question around: why do you think that this ticket is somehow related to linking? |
comment:45
I suggest to fix the dependency here and fix the overlinking issue elsewhere (e.g. using leif branch). As far as Cygwin is concerned, the situation is quite good actually: you just need to have at hand libs directly used by your executable/library and feed them to the linker with appropriate flags as I just tested on a VM. The main issue with cygwin is that the need above is mandatory: if you wanna use a gmp function (whatever it relies on, even further libraries) then you need to tell it to the linker whereas linux is more negligent about that and just bet that at runtime every undefined symbol will be resolved. |
Reviewer: Jean-Pierre Flori |
Changed branch from u/jdemeyer/fix_dependencies_on_pari to |
The extension modules linking against PARI should explicitly depend on the PARI headers. This is in particular true for
sage/ext/interrupt/interrupt.pyx
.Since every module cimporting something from PARI will cimport
sage.libs.pari.types
, we add the explicit dependency there.In order to have the correct distutils keywords for
sage/ext/interrupt/interrupt.pyx
, we cimportsage.libs.pari.paridecl
there.CC: @kiwifb @jpflori
Component: cython
Author: Jeroen Demeyer
Branch/Commit:
5d0e4d3
Reviewer: Jean-Pierre Flori
Issue created by migration from https://trac.sagemath.org/ticket/19610
The text was updated successfully, but these errors were encountered: