[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Gavin D. Smith |
Date: |
Wed, 20 Nov 2024 16:29:00 -0500 (EST) |
branch: master
commit e045cc62f0d888b9b6f8b253a180293883bab66a
Author: Gavin Smith <gavinsmith0123@gmail.com>
AuthorDate: Wed Nov 20 21:11:35 2024 +0000
* tp/Texinfo/XSLoader.pm (init, load_libtool_library):
Split out sub to handle everything up to loading the library
with dl_load_file, but not any further. This could potentially
be used with library files that do not have an XS bootstrap
function (such as libtexinfo or libtexinfoxs).
(init): Comment out code handling additional libraries argument.
---
ChangeLog | 9 ++++
tp/Texinfo/XSLoader.pm | 129 ++++++++++++++++++++++++++-----------------------
2 files changed, 77 insertions(+), 61 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9ecdc8b265..488ca67ba0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2024-11-20 Gavin Smith <gavinsmith0123@gmail.com>
+
+ * tp/Texinfo/XSLoader.pm (init, load_libtool_library):
+ Split out sub to handle everything up to loading the library
+ with dl_load_file, but not any further. This could potentially
+ be used with library files that do not have an XS bootstrap
+ function (such as libtexinfo or libtexinfoxs).
+ (init): Comment out code handling additional libraries argument.
+
2024-11-20 Patrice Dumas <pertusus@free.fr>
* tp/Texinfo/XSLoader.pm (init), tp/Texinfo/DocumentXS.pm (BEGIN),
diff --git a/tp/Texinfo/XSLoader.pm b/tp/Texinfo/XSLoader.pm
index b782f26bd5..3b821a88b5 100644
--- a/tp/Texinfo/XSLoader.pm
+++ b/tp/Texinfo/XSLoader.pm
@@ -98,52 +98,13 @@ sub _find_file($) {
return undef;
}
-# Load module $MODULE, either from XS implementation in
-# Libtool file $MODULE_NAME and Perl file $PERL_EXTRA_FILE,
-# or non-XS implementation $FALLBACK_MODULE.
-# The package loaded is returned or undef if there is no fallback and the
-# XS package was not loaded.
-sub init {
- my ($module,
- $fallback_module,
- $module_name,
- $perl_extra_file,
- #$additional_libraries,
- ) = @_;
-
- # Possible values for TEXINFO_XS environment variable:
- #
- # TEXINFO_XS=omit # don't try loading xs at all
- # TEXINFO_XS=default # try xs, libtool, silent fallback
- # TEXINFO_XS=warn # try xs, libtool warn on failure
- # TEXINFO_XS=required # abort if not loadable, no fallback
- # TEXINFO_XS=debug # voluminuous debugging
- #
- # Other values are treated at the moment as 'default'.
-
- $TEXINFO_XS = $ENV{'TEXINFO_XS'};
- if (!defined($TEXINFO_XS)) {
- $TEXINFO_XS = '';
- }
-
- if ($TEXINFO_XS eq 'omit') {
- # Don't try to use the XS module
- goto FALLBACK;
- }
-
- if ($disable_XS) {
- _fatal("use of XS modules was disabled when Texinfo was built");
- goto FALLBACK;
- }
-
- if (!$module_name) {
- goto FALLBACK;
- }
+sub load_libtool_library {
+ my ($module_name) = @_;
my ($libtool_dir, $libtool_archive) = _find_file("$module_name.la");
if (!$libtool_archive) {
_fatal("$module_name: couldn't find Libtool archive file");
- goto FALLBACK;
+ return 0;
}
my $dlname = undef;
@@ -152,7 +113,7 @@ sub init {
open $fh, $libtool_archive;
if (!$fh) {
_fatal("$module_name: couldn't open Libtool archive file");
- goto FALLBACK;
+ return 0;
}
# Look for the line in XS*.la giving the name of the loadable object.
@@ -164,7 +125,7 @@ sub init {
}
if (!defined($dlname) or $dlname eq '') {
_fatal("$module_name: couldn't find name of shared object");
- goto FALLBACK;
+ return 0;
}
# The *.so file is under .libs in the source directory.
@@ -174,35 +135,83 @@ sub init {
my @found_files = DynaLoader::dl_findfile($dlname);
if (scalar(@found_files) == 0) {
_fatal("$module_name: couldn't find $dlname");
- goto FALLBACK;
+ return 0;
}
my $dlpath = $found_files[0];
- # After testing, it seems that putting libraries files in
- # @DynaLoader::dl_resolve_using does not ensure that they are found when
- # dlopen'ing.
- #if ($additional_libraries and scalar(@$additional_libraries)) {
- # my @found_additional_libraries
- # = DynaLoader::dl_findfile(@$additional_libraries);
- # _debug("additional libraries: ".join('|', @$additional_libraries));
- # _debug("found additional: ".join('|', @found_additional_libraries));
- # push @DynaLoader::dl_resolve_using, @found_additional_libraries;
- #}
-
#my $flags = dl_load_flags $module; # This is 0 in DynaLoader
my $flags = 0;
my $libref = DynaLoader::dl_load_file($dlpath, $flags);
if (!defined($libref)) {
- # dl_error messages ends with a spurious NULL ^@
my $message = DynaLoader::dl_error();
_fatal("$module_name: couldn't load file $dlpath: $message");
- goto FALLBACK;
+ return 0;
}
_debug("$dlpath loaded");
+ push @DynaLoader::dl_shared_objects, $dlpath; # record files loaded
+
my @undefined_symbols = DynaLoader::dl_undef_symbols();
if (scalar(@undefined_symbols) != 0) {
_fatal("$module_name: still have undefined symbols after dl_load_file");
}
+ return $libref;
+}
+
+# Load module $MODULE, either from XS implementation in
+# Libtool file $MODULE_NAME and Perl file $PERL_EXTRA_FILE,
+# or non-XS implementation $FALLBACK_MODULE.
+# The package loaded is returned or undef if there is no fallback and the
+# XS package was not loaded.
+sub init {
+ my ($module,
+ $fallback_module,
+ $module_name,
+ $perl_extra_file,
+ #$additional_libraries,
+ ) = @_;
+
+ # Possible values for TEXINFO_XS environment variable:
+ #
+ # TEXINFO_XS=omit # don't try loading xs at all
+ # TEXINFO_XS=default # try xs, libtool, silent fallback
+ # TEXINFO_XS=warn # try xs, libtool warn on failure
+ # TEXINFO_XS=required # abort if not loadable, no fallback
+ # TEXINFO_XS=debug # voluminuous debugging
+ #
+ # Other values are treated at the moment as 'default'.
+
+ $TEXINFO_XS = $ENV{'TEXINFO_XS'};
+ if (!defined($TEXINFO_XS)) {
+ $TEXINFO_XS = '';
+ }
+
+ if ($TEXINFO_XS eq 'omit') {
+ # Don't try to use the XS module
+ goto FALLBACK;
+ }
+
+ if ($disable_XS) {
+ _fatal("use of XS modules was disabled when Texinfo was built");
+ goto FALLBACK;
+ }
+
+ if (!$module_name) {
+ goto FALLBACK;
+ }
+
+ # if ($additional_libraries and scalar(@$additional_libraries)) {
+ # my @found_additional_libraries
+ # = DynaLoader::dl_findfile(@$additional_libraries);
+ # _debug("additional libraries: ".join('|', @$additional_libraries));
+ # _debug("found additional: ".join('|', @found_additional_libraries));
+ # push @DynaLoader::dl_resolve_using, @found_additional_libraries;
+ # }
+
+ my $libref = load_libtool_library($module_name);
+ if (!$libref) {
+ goto FALLBACK;
+ }
+
my $bootname = "boot_$module";
$bootname =~ s/:/_/g;
_debug("looking for $bootname");
@@ -213,7 +222,7 @@ sub init {
}
_debug("trying to call $bootname...");
my $boot_fn = DynaLoader::dl_install_xsub("${module}::bootstrap",
- $symref, $dlname);
+ $symref); #, $dlname);
if (!defined($boot_fn)) {
_fatal("$module_name: couldn't bootstrap");
@@ -221,8 +230,6 @@ sub init {
}
_debug(" ...succeeded");
- push @DynaLoader::dl_shared_objects, $dlpath; # record files loaded
-
# This is the module bootstrap function, which causes all the other
# functions (XSUB's) provided by the module to become available to
# be called from Perl code, after a check that the version argument