File 2561-First-attempt-at-extending-static-nif-setup.patch of Package erlang

From 5f98b6bf847d1fd67191ad29038c3f9db828dc0e Mon Sep 17 00:00:00 2001
From: Benedikt Reinartz <filmor@gmail.com>
Date: Fri, 21 Mar 2025 17:58:30 +0100
Subject: [PATCH 1/2] First attempt at extending static nif setup

---
 erts/emulator/Makefile.in           |  8 +++++---
 erts/emulator/utils/make_driver_tab | 16 +++++++++++++++-
 2 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in
index 9b6bbf06d3..31b200d7da 100644
--- a/erts/emulator/Makefile.in
+++ b/erts/emulator/Makefile.in
@@ -209,6 +209,7 @@ LIBS += $(TYPE_LIBS)
 ORIG_LIBS:= $(LIBS)
 
 comma:=,
+colon:=:
 space:=
 space+=
 
@@ -662,7 +663,7 @@ GENERATE += $(TARGET)/erl_version.h
 
 # driver table
 $(TTF_DIR)/driver_tab.c: Makefile.in utils/make_driver_tab
-	$(gen_verbose)LANG=C $(PERL) utils/make_driver_tab -o $@ -nifs $(NIF_OBJS) $(STATIC_NIF_LIBS) -drivers $(DRV_OBJS) $(STATIC_DRIVER_LIBS)
+	$(gen_verbose)LANG=C $(PERL) utils/make_driver_tab -o $@ -nifs $(NIF_OBJS) $(STATIC_NIF_SYMBOLS) -drivers $(DRV_OBJS) $(STATIC_DRIVER_LIBS)
 GENERATE += $(TTF_DIR)/driver_tab.c
 
 
@@ -1204,11 +1205,12 @@ DRV_OBJS = \
 endif
 
 ifneq ($(STATIC_NIFS),no)
-STATIC_NIF_LIBS = $(STATIC_NIFS)
+STATIC_NIF_LIBS = $(foreach n,$(STATIC_NIFS),$(word 1, $(subst $(colon),$(space),$(n))))
+STATIC_NIF_SYMBOLS = $(STATIC_NIFS)
 DEPLIBS += $(STATIC_NIF_LIBS)
 COMPILE_STATIC_LIBS = yes
 else
-STATIC_NIF_LIBS=
+STATIC_NIF_SYMBOLS=
 endif
 
 ifneq ($(STATIC_DRIVERS),no)
diff --git a/erts/emulator/utils/make_driver_tab b/erts/emulator/utils/make_driver_tab
index 567b7aad60..a963d7e023 100755
--- a/erts/emulator/utils/make_driver_tab
+++ b/erts/emulator/utils/make_driver_tab
@@ -49,7 +49,21 @@ while (@ARGV) {
 	$mode = 1;
 	next;
     }
-    if ( $d =~ /^.*\.a$/ ) {
+    if ( $d =~ /^(.*\.a)(:[A-Za-z_][A-Za-z0-9_]*)+$/ ) {
+        # Only implemented for NIFs
+        if ($mode != 2) {
+            next;
+        }
+
+        my @nifs = split(/:/, $2);
+        shift(@nifs);
+
+        foreach my $nif_symbol ( @nifs ) {
+            push(@static_nifs, $nif_symbol)
+        }
+        next;
+    }
+    elsif ( $d =~ /\.a$/ ) {
 	$d = basename $d;
 	$d =~ s/\.a$//;	# strip .a
 	$d =~ s/\.gprof$//;	# strip .gprof
-- 
2.43.0

openSUSE Build Service is sponsored by