[MacPorts] #51516: MacPorts should use a bundled copy of a newer libcurl and SSL library rather than the OS X version

MacPorts noreply at macports.org
Sun Jun 2 13:47:09 UTC 2024


#51516: MacPorts should use a bundled copy of a newer libcurl and SSL library
rather than the OS X version
--------------------------+--------------------------------
  Reporter:  ryandesign   |      Owner:  macports-tickets@…
      Type:  enhancement  |     Status:  new
  Priority:  Normal       |  Milestone:  MacPorts Future
 Component:  base         |    Version:
Resolution:               |   Keywords:
      Port:               |
--------------------------+--------------------------------

Comment (by RJVB):

 Replying to [comment:115 kencu]:
 > your enthusiasm is commendable.

 If I didn't know this wasn't pure altruism I'd be blushing ;)

 Since I also like *easy* lowlevel hacks I started tinkering with the glue
 library idea, which allows me to test an unmodified Pextlib (= still
 linking to the system libcurl) with the tested private copy of `libcurl-
 gnutls` I've been using, through a runtime equivalent of
 `DYLD_INSERT_LIBRARIES`. Or rather, `LD_PRELOAD` because I'm on my Linux
 rig.

 This code snippet gives promising behaviour when built into a shared
 library:
 (I've called my private libcurl copy `pextcurl.so.4` there)

 {{{
 #include <dlfcn.h>

 static void* curl_handle = 0;
 static void* curl_global_init = 0;

 #ifndef LIBCURL
 #   define LIBCURL
 "/opt/local/libexec/macports/lib/pextlib1.0/pextcurl.so.4"
 #endif

 /* A stub Tcl package init function (hence the unused ptr argument that
  * would normally point to a Tcl_Interp instance).
  * Attempts to load libcurl from a designated location and fetch the
  * curl_global_init() function address from it. Returns 0 (aka TCL_OK)
  * on success, 1 (aka TCL_ERROR) on failure.
  */
 int Curlglue_Init(void *dummy)
 {
 #pragma unused(dummy)
     if (curl_handle || curl_global_init) {
         return 1;
     }
     int flags = RTLD_NOW | RTLD_GLOBAL;
 #ifdef RTLD_DEEPBIND
     // not really certain if we need this but it seems a good idea to use
     // when available to make a dynamic load work as much as possible as a
     // DYLD_INSERT_LIBRARIES (Darwin) or LD_PRELOAD (Linux).
     flags |= RTLD_DEEPBIND;
 #endif
     if (!(curl_handle = dlopen(LIBCURL, flags))) {
         return 1;
     }
     if (!(curl_global_init = dlsym(curl_handle, "curl_global_init"))) {
         return 1;
     }
     // success
     return 0;
 }
 }}}

 For now I tried this:
 {{{
 > port-tclsh
 % load /path/to/libcurlglue.so
 % package require Pextlib 1.0
 1.0
 % curl
 wrong # args: should be "curl option ?arg ...?"
 % ^Z
 [4]  +   29607 Suspended                     port-tclsh
 > ll /proc/29607/map_files/ | fgrep curl
 29717233 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c7a4000-7f542c7b1000 ->
 /opt/local/libexec/macports/lib/pextlib1.0/pextcurl.so.4*
 29717234 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c7b1000-7f542c826000 ->
 /opt/local/libexec/macports/lib/pextlib1.0/pextcurl.so.4*
 29717235 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c826000-7f542c845000 ->
 /opt/local/libexec/macports/lib/pextlib1.0/pextcurl.so.4*
 29717236 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c845000-7f542c848000 ->
 /opt/local/libexec/macports/lib/pextlib1.0/pextcurl.so.4*
 29717237 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c848000-7f542c84b000 ->
 /opt/local/libexec/macports/lib/pextlib1.0/pextcurl.so.4*
 29717243 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c8a7000-7f542c8a8000 -> /path/to/libcurlglue.so*
 29717244 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c8a8000-7f542c8a9000 -> /path/to/libcurlglue.so*
 29717245 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c8a9000-7f542c8aa000 -> /path/to/libcurlglue.so*
 29717246 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c8aa000-7f542c8ab000 -> /path/to/libcurlglue.so*
 29717247 0 lr-------- 1 bertin bertin 64 Jun  2 15:25
 7f542c8ab000-7f542c8ac000 -> /path/to/libcurlglue.so*
 }}}

 No trace of the system libcurl (that would be `/usr/lib/x86_64-linux-
 gnu/libcurl.so.4.3.0`) to be seen, so a priori Pextlib is using my
 dedicated copy here.

-- 
Ticket URL: <https://trac.macports.org/ticket/51516#comment:116>
MacPorts <https://www.macports.org/>
Ports system for macOS


More information about the macports-tickets mailing list