-
Notifications
You must be signed in to change notification settings - Fork 137
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
clean up linkage of libsecp256k1 into libwallycore and Python extension #417
clean up linkage of libsecp256k1 into libwallycore and Python extension #417
Conversation
AX_SUBDIRS_CONFIGURE
; don't alter ac_configure_args
@jgriffiths: I noticed one regression when switching from |
7654b9d
to
34fd67d
Compare
Indeed, there was a break in that |
5dc21e0
to
61584a1
Compare
I think this explicit call should be added to |
61584a1
to
69f35ee
Compare
f997f7d
to
0d3639f
Compare
cherry-picked e14ada8 to reduce rebase pain. |
69f35ee
to
e377be1
Compare
@whitslack can you rename |
@jgriffiths: Hmm, yes, but is that a clear name for what the variable controls? To me, that name suggests that the variable controls whether the wheel is to be shared, which doesn't entirely make sense. What we're actually talking about here is whether the Python native extension library (which is always a shared library included in the wheel) will link dynamically to libwally-core (or else will embed the libwally-core and libsecp256k1 code wholly within the Python native extension library). |
Naming things, always the hardest part of coding lol. How about |
Okay, sure. I have no strong objections to that name. It's a little verbose, but it's okay. |
e377be1
to
1ef4131
Compare
In the first commit you need to include the m4 file defining |
It's part of Autoconf Archive, which I think you're already using. |
I'm aware; we check in the macros we need from the archive under |
Do you monitor the Archive for bug fixes and feature enhancements in the macros you've copied from it, and do you promptly make new releases of libwally-core whenever the macros you're using have received such a bug fix or enhancement? This is the static linking versus dynamic linking debate all over again. 😅 Maybe one of your users has an unusual setup that causes an Autoconf Archive macro to misbehave. Upon researching it, they discover that the misbehavior has already been corrected in the Archive, but because you haven't been keeping up with fixes, your project is broken for them, whereas everything would have been fine if you hadn't made your own private copy that inevitably becomes outdated. (I'm sure this comes across as though I'm very perturbed, but I am not. It's a difference of philosophy as old as the concept of linking itself. I don't have any illusions of changing your mind.) I'll make a copy of the macro definition and check it in. 🤦♂️ |
1ef4131
to
84d2b50
Compare
This is done. |
Note the requirements for wally, exposed functionality, how it is expected to be used and the time available for me to work on it are all determined by my day job; my personal opinions on the correct way of doing things is irrelevant and I'm not arguing from my POV at all. I'm not adverse to explaining the rationale behind these decisions as I understand them but your views (however correct they may be) don't supersede my work obligations. I'll be removing some verbage from your commit descriptions before finalizing the build_updates branch, I will call for final review and get an ack from you before merging this branch (which may take some time given it needs further work and internal testing). |
Altering ac_configure_args to configure libsecp256k1 with options differing from those of libwally-core causes issues if the wally Makefile is out of date and needs to call autoreconf etc to regenerate itself. The secp arguments are passed back to the top level configure which changes and possibly breaks the original configuration. Instead, import and use AX_SUBDIRS_CONFIGURE from the autoconf-archive which supports sub-confiration with bespoke arguments. Because autoreconf does not recurse into subdirectories named by AX_SUBDIRS_CONFIGURE, we lose the automagic Autotools (re)generation in src/secp256k1, so add an explicit call to src/secp256k1/autogen.sh in tools/autogen.sh.
Extracted from a patch by Matt Whitlock <[email protected]>. Also reduce the include directories given for python wheel building.
0d3639f
to
476ac41
Compare
Since you removed the paragraph beginning "At the insistence of this project's maintainer," I would respectfully request that you |
We have two levels of library embedding: * libsecp256k1.la is linked into libwallycore.la via LIBADD. The FIXME comment in configure.ac contained an assertion that seems to be irrelevant: passing libsecp256k1.la to libtool when linking libwallycore.la indeed does not embed the objects from libsecp256k1.a into libwallycore.a, but it does add a dependency on libsecp256k1.la in libwallycore.la, so any future links against libwallycore.la will automagically pull in libsecp256k1.la. This is exactly the scenario that libtool was conceived to facilitate. Do note one caveat: if both --enable-shared and --enable-static are passed to configure, then libwallycore.la will *not* specify a dependency on libsecp256k1.la, but this is irrelevant since any future links against libwallycore.la will link against libwallycore.so, which *does* contain all of the symbols from libsecp256k1.a, so there is no additional dependency. * libwallycore.la is linked into the Python native extension library. Previously this wasn't really being done at all; rather, all of the libwally-core code was being recompiled into some "combined" objects that would then be linked into the Python extension. This was a needless duplication of work since the compiled objects already exist in libwallycore.a and libsecp256k1.a. Simply link those libraries into the extension. Note that libwally-core does need to be compiled as PIC for this to work, so setup.py passes --with-pic to configure. Additional cleanup: adjust several #include directives to reference libsecp256k1 headers in the configured header search path rather than explicitly specifying paths to the instances beneath src/secp256k1/.
Iff the environment contains WALLY_ABI_PY_WHEEL_USE_DSO=1, then: * setup.py will configure and build libwally-core as a shared library; * the Python native extension library will not contain any libwally-core or libsecp256k1 code; and * the dynamic linker will need to find and load libwallycore.so.1 whenever the Python native extension is loaded.
84d2b50
to
9b451a8
Compare
AX_SUBDIRS_CONFIGURE
; don't alter ac_configure_args
Will do. |
81ccbab
to
0df2d50
Compare
Superseded by #419. |
This PR has two remaining objectives:
configure.ac
relating to embedding the symbols fromlibsecp256k1.a
when buildinglibwallycore.so
.setup.py
to link the Python native extension dynamically with a libwally-core DSO.