File 1223-erts-Ignore-undef-prim_socket-functions.patch of Package erlang
From 5efca85b1d749e3c648b84ffba1c29cf23e00373 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Wed, 8 Dec 2021 10:48:12 +0100
Subject: [PATCH 02/12] erts: Ignore undef prim_socket functions
If we compile with --disable-esock we should ignore
any calls to those functions.
---
 erts/test/otp_SUITE.erl | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/erts/test/otp_SUITE.erl b/erts/test/otp_SUITE.erl
index 7ce7f670dd..78f29d0a55 100644
--- a/erts/test/otp_SUITE.erl
+++ b/erts/test/otp_SUITE.erl
@@ -78,14 +78,15 @@ undefined_functions(Config) when is_list(Config) ->
                       "Undef - Undef | ExcludedFrom",
                       [UndefS,ExcludeFrom]),
     {ok,Undef0} = xref:q(Server, lists:flatten(Q)),
-    Undef1 = hipe_filter(Undef0),
-    Undef2 = ssl_crypto_filter(Undef1),
-    Undef3 = edoc_filter(Undef2),
-    Undef4 = eunit_filter(Undef3),
-    Undef5 = dialyzer_filter(Undef4),
-    Undef6 = wx_filter(Undef5),
-    Undef7 = gs_filter(Undef6),
-    Undef = diameter_filter(Undef7),
+    Undef1 = erts_filter(Undef0),
+    Undef2 = hipe_filter(Undef1),
+    Undef3 = ssl_crypto_filter(Undef2),
+    Undef4 = edoc_filter(Undef3),
+    Undef5 = eunit_filter(Undef4),
+    Undef6 = dialyzer_filter(Undef5),
+    Undef7 = wx_filter(Undef6),
+    Undef8 = gs_filter(Undef7),
+    Undef = diameter_filter(Undef8),
 
     case Undef of
         [] -> ok;
@@ -221,6 +222,20 @@ diameter_filter(Undef) ->
               (_) -> true
            end, Undef).
 
+erts_filter(Undef) ->
+    %% Filter away prim_socket calls if that module is not available
+    %% prim_socket is not available if system is compiled with --disable-esock
+    case code:is_loaded(prim_socket) of
+        {file,preloaded} ->
+            Undef;
+        _ ->
+            filter(fun({_,{prim_socket,_,_}}) ->
+                           false;
+                      (_) ->
+                           true
+                   end, Undef)
+    end.
+
 deprecated_not_in_obsolete(Config) when is_list(Config) ->
     Server = proplists:get_value(xref_server, Config),
     {ok,DeprecatedFunctions} = xref:q(Server, "DF"),
-- 
2.31.1