File rabbitmq-server-3.6.16-hipe.patch of Package rabbitmq-server

diff -Ndurp rabbitmq-server-3.6.16/docs/rabbitmq.config.example rabbitmq-server-3.6.16-hipe/docs/rabbitmq.config.example
--- rabbitmq-server-3.6.16/docs/rabbitmq.config.example	2018-05-28 22:10:54.000000000 +0300
+++ rabbitmq-server-3.6.16-hipe/docs/rabbitmq.config.example	2023-08-06 02:55:05.243572861 +0300
@@ -383,10 +383,6 @@
    %%
    %% {trace_vhosts, []},
 
-   %% Explicitly enable/disable HiPE compilation.
-   %%
-   %% {hipe_compile, false},
-
    %% Number of delegate processes to use for intra-cluster communication.
    %% On a node which is part of cluster, has more than 16 cores and plenty of network bandwidth,
    %% it may make sense to increase this value.
diff -Ndurp rabbitmq-server-3.6.16/docs/rabbitmqctl.1.xml rabbitmq-server-3.6.16-hipe/docs/rabbitmqctl.1.xml
--- rabbitmq-server-3.6.16/docs/rabbitmqctl.1.xml	2018-05-28 22:10:54.000000000 +0300
+++ rabbitmq-server-3.6.16-hipe/docs/rabbitmqctl.1.xml	2023-08-06 02:55:35.678911018 +0300
@@ -312,33 +312,6 @@
             </para>
           </listitem>
         </varlistentry>
-
-        <varlistentry>
-          <term><cmdsynopsis><command>hipe_compile</command> <arg choice="req"><replaceable>directory</replaceable></arg></cmdsynopsis></term>
-          <listitem>
-            <para>
-              Performs HiPE-compilation and caches resulting
-              .beam-files in the given directory.
-            </para>
-            <para>
-              Parent directories are created if necessary. Any
-              existing <command>.beam</command> files from the
-              directory are automatically deleted prior to
-              compilation.
-            </para>
-            <para>
-              To use this precompiled files, you should set
-              <command>RABBITMQ_SERVER_CODE_PATH</command> environment
-              variable to directory specified in
-              <command>hipe_compile</command> invokation.
-            </para>
-            <para role="example-prefix">For example:</para>
-            <screen role="example">rabbitmqctl hipe_compile /tmp/rabbit-hipe/ebin</screen>
-            <para role="example">
-              HiPE-compiles modules and stores them to /tmp/rabbit-hipe/ebin directory.
-            </para>
-          </listitem>
-        </varlistentry>
       </variablelist>
     </refsect2>
 
diff -Ndurp rabbitmq-server-3.6.16/Makefile rabbitmq-server-3.6.16-hipe/Makefile
--- rabbitmq-server-3.6.16/Makefile	2018-05-28 22:10:54.000000000 +0300
+++ rabbitmq-server-3.6.16-hipe/Makefile	2023-08-06 02:54:40.556109704 +0300
@@ -64,24 +64,6 @@ define PROJECT_ENV
 	                          {exit_on_close, false}
 	                         ]},
 	    {halt_on_upgrade_failure, true},
-	    {hipe_compile, false},
-	    %% see bug 24513 [in legacy Bugzilla] for how this list was created
-	    {hipe_modules,
-	     [rabbit_reader, rabbit_channel, gen_server2, rabbit_exchange,
-	      rabbit_command_assembler, rabbit_framing_amqp_0_9_1, rabbit_basic,
-	      rabbit_event, lists, queue, priority_queue, rabbit_router,
-	      rabbit_trace, rabbit_misc, rabbit_binary_parser,
-	      rabbit_exchange_type_direct, rabbit_guid, rabbit_net,
-	      rabbit_amqqueue_process, rabbit_variable_queue,
-	      rabbit_binary_generator, rabbit_writer, delegate, gb_sets, lqueue,
-	      sets, orddict, rabbit_amqqueue, rabbit_limiter, gb_trees,
-	      rabbit_queue_index, rabbit_exchange_decorator, gen, dict, ordsets,
-	      file_handle_cache, rabbit_msg_store, array,
-	      rabbit_msg_store_ets_index, rabbit_msg_file,
-	      rabbit_exchange_type_fanout, rabbit_exchange_type_topic, mnesia,
-	      mnesia_lib, rpc, mnesia_tm, qlc, sofs, proplists, credit_flow,
-	      pmon, ssl_connection, tls_connection, ssl_record, tls_record,
-	      gen_fsm, ssl]},
 	    {ssl_apps, [asn1, crypto, public_key, ssl]},
 	    %% see rabbitmq-server#114
 	    {mirroring_flow_control, true},
diff -Ndurp rabbitmq-server-3.6.16/scripts/rabbitmq-server rabbitmq-server-3.6.16-hipe/scripts/rabbitmq-server
--- rabbitmq-server-3.6.16/scripts/rabbitmq-server	2018-05-28 22:10:54.000000000 +0300
+++ rabbitmq-server-3.6.16-hipe/scripts/rabbitmq-server	2023-08-06 02:57:27.480479794 +0300
@@ -152,9 +152,7 @@ ensure_thread_pool_size() {
 
 start_rabbitmq_server() {
     # "-pa ${RABBITMQ_SERVER_CODE_PATH}" should be the very first
-    # command-line argument. In case of using cached HiPE-compilation,
-    # this will allow for compiled versions of erlang built-in modules
-    # (e.g. lists) to be loaded.
+    # command-line argument.
     ensure_thread_pool_size
     check_start_params &&
     RABBITMQ_CONFIG_FILE=$RABBITMQ_CONFIG_FILE \
diff -Ndurp rabbitmq-server-3.6.16/src/rabbit_control_main.erl rabbitmq-server-3.6.16-hipe/src/rabbit_control_main.erl
--- rabbitmq-server-3.6.16/src/rabbit_control_main.erl	2018-05-28 22:10:54.000000000 +0300
+++ rabbitmq-server-3.6.16-hipe/src/rabbit_control_main.erl	2023-08-06 02:58:38.838928047 +0300
@@ -38,7 +38,6 @@
          reset,
          force_reset,
          rotate_logs,
-         hipe_compile,
 
          {join_cluster, [?RAM_DEF]},
          change_cluster_node_type,
@@ -123,7 +122,7 @@
         [stop, shutdown, stop_app, start_app, wait, reset, force_reset, rotate_logs,
          join_cluster, change_cluster_node_type, update_cluster_nodes,
          forget_cluster_node, rename_cluster_node, cluster_status, status,
-         environment, eval, force_boot, help, hipe_compile, encode, decode,
+         environment, eval, force_boot, help, encode, decode,
          list_ciphers, list_hashes]).
 
 %% [Command | {Command, DefaultTimeoutInMilliSeconds}]
@@ -444,16 +443,6 @@ action(rotate_logs, Node, Args = [Suffix
     Inform("Rotating logs to files with suffix \"~s\"", [Suffix]),
     call(Node, {rabbit, rotate_logs, Args});
 
-action(hipe_compile, _Node, [TargetDir], _Opts, _Inform) ->
-    ok = application:load(rabbit),
-    case rabbit_hipe:can_hipe_compile() of
-        true ->
-            {ok, _, _} = rabbit_hipe:compile_to_directory(TargetDir),
-            ok;
-        false ->
-            {error, "HiPE compilation is not supported"}
-    end;
-
 action(close_connection, Node, [PidStr, Explanation], _Opts, Inform) ->
     Inform("Closing connection \"~s\"", [PidStr]),
     rpc_call(Node, rabbit_networking, close_connection,
diff -Ndurp rabbitmq-server-3.6.16/src/rabbit.erl rabbitmq-server-3.6.16-hipe/src/rabbit.erl
--- rabbitmq-server-3.6.16/src/rabbit.erl	2018-05-28 22:10:54.000000000 +0300
+++ rabbitmq-server-3.6.16-hipe/src/rabbit.erl	2023-08-06 02:58:14.443458548 +0300
@@ -260,7 +260,7 @@
 %%----------------------------------------------------------------------------
 
 ensure_application_loaded() ->
-    %% We end up looking at the rabbit app's env for HiPE and log
+    %% We end up looking at the rabbit app's env for log
     %% handling, so it needs to be loaded. But during the tests, it
     %% may end up getting loaded twice, so guard against that.
     case application:load(rabbit) of
@@ -273,9 +273,7 @@ start() ->
                      %% We do not want to upgrade mnesia after just
                      %% restarting the app.
                      ok = ensure_application_loaded(),
-                     HipeResult = rabbit_hipe:maybe_hipe_compile(),
                      ok = ensure_working_log_handlers(),
-                     rabbit_hipe:log_hipe_result(HipeResult),
                      rabbit_node_monitor:prepare_cluster_status_files(),
                      rabbit_mnesia:check_cluster_consistency(),
                      broker_start()
@@ -284,9 +282,7 @@ start() ->
 boot() ->
     start_it(fun() ->
                      ok = ensure_application_loaded(),
-                     HipeResult = rabbit_hipe:maybe_hipe_compile(),
                      ok = ensure_working_log_handlers(),
-                     rabbit_hipe:log_hipe_result(HipeResult),
                      rabbit_node_monitor:prepare_cluster_status_files(),
                      ok = rabbit_upgrade:maybe_upgrade_mnesia(),
                      %% It's important that the consistency check happens after
diff -Ndurp rabbitmq-server-3.6.16/src/rabbit_hipe.erl rabbitmq-server-3.6.16-hipe/src/rabbit_hipe.erl
--- rabbitmq-server-3.6.16/src/rabbit_hipe.erl	2018-05-28 22:10:54.000000000 +0300
+++ rabbitmq-server-3.6.16-hipe/src/rabbit_hipe.erl	1970-01-01 03:00:00.000000000 +0300
@@ -1,146 +0,0 @@
--module(rabbit_hipe).
-
-%% HiPE compilation uses multiple cores anyway, but some bits are
-%% IO-bound so we can go faster if we parallelise a bit more. In
-%% practice 2 processes seems just as fast as any other number > 1,
-%% and keeps the progress bar realistic-ish.
--define(HIPE_PROCESSES, 2).
-
--export([maybe_hipe_compile/0, log_hipe_result/1]).
--export([compile_to_directory/1]).
--export([can_hipe_compile/0]).
-
-%% Compile and load during server startup sequence
-maybe_hipe_compile() ->
-    {ok, Want} = application:get_env(rabbit, hipe_compile),
-    case {Want, can_hipe_compile()} of
-        {true,  true}  -> hipe_compile();
-        {true,  false} -> false;
-        {false, _}     -> {ok, disabled}
-    end.
-
-log_hipe_result({ok, disabled}) ->
-    ok;
-log_hipe_result({ok, already_compiled}) ->
-    rabbit_log:info(
-      "HiPE in use: modules already natively compiled.~n", []);
-log_hipe_result({ok, Count, Duration}) ->
-    rabbit_log:info(
-      "HiPE in use: compiled ~B modules in ~Bs.~n", [Count, Duration]);
-log_hipe_result(false) ->
-    io:format(
-      "~nNot HiPE compiling: HiPE not found in this Erlang installation.~n"),
-    rabbit_log:warning(
-      "Not HiPE compiling: HiPE not found in this Erlang installation.~n").
-
-hipe_compile() ->
-    hipe_compile(fun compile_and_load/1, false).
-
-compile_to_directory(Dir0) ->
-    Dir = rabbit_file:filename_as_a_directory(Dir0),
-    ok = prepare_ebin_directory(Dir),
-    hipe_compile(fun (Mod) -> compile_and_save(Mod, Dir) end, true).
-
-needs_compilation(Mod, Force) ->
-    Exists = code:which(Mod) =/= non_existing,
-    %% We skip modules already natively compiled. This
-    %% happens when RabbitMQ is stopped (just the
-    %% application, not the entire node) and started
-    %% again.
-    NotYetCompiled = not already_hipe_compiled(Mod),
-    NotVersioned = not compiled_with_version_support(Mod),
-    Exists andalso (Force orelse (NotYetCompiled andalso NotVersioned)).
-
-%% HiPE compilation happens before we have log handlers and can take a
-%% long time, so make an exception to our no-stdout policy and display
-%% progress via stdout.
-hipe_compile(CompileFun, Force) ->
-    {ok, HipeModulesAll} = application:get_env(rabbit, hipe_modules),
-    HipeModules = lists:filter(fun(Mod) -> needs_compilation(Mod, Force) end, HipeModulesAll),
-    case HipeModules of
-        [] -> {ok, already_compiled};
-        _  -> do_hipe_compile(HipeModules, CompileFun)
-    end.
-
-already_hipe_compiled(Mod) ->
-    try
-    %% OTP 18.x or later
-        Mod:module_info(native) =:= true
-    %% OTP prior to 18.x
-    catch error:badarg ->
-        code:is_module_native(Mod) =:= true
-    end.
-
-compiled_with_version_support(Mod) ->
-    proplists:get_value(erlang_version_support, Mod:module_info(attributes))
-        =/= undefined.
-
-do_hipe_compile(HipeModules, CompileFun) ->
-    Count = length(HipeModules),
-    io:format("~nHiPE compiling:  |~s|~n                 |",
-              [string:copies("-", Count)]),
-    T1 = time_compat:monotonic_time(),
-    %% We use code:get_object_code/1 below to get the beam binary,
-    %% instead of letting hipe get it itself, because hipe:c/{1,2}
-    %% expects the given filename to actually exist on disk: it does not
-    %% work with an EZ archive (rabbit_common is one).
-    %%
-    %% Then we use the mode advanced hipe:compile/4 API because the
-    %% simpler hipe:c/3 is not exported (as of Erlang 18.1.4). This
-    %% advanced API does not load automatically the code, except if the
-    %% 'load' option is set.
-    PidMRefs = [spawn_monitor(fun () -> [begin
-                                             CompileFun(M),
-                                             io:format("#")
-                                         end || M <- Ms]
-                              end) ||
-                   Ms <- split(HipeModules, ?HIPE_PROCESSES)],
-    [receive
-         {'DOWN', MRef, process, _, normal} -> ok;
-         {'DOWN', MRef, process, _, Reason} -> exit(Reason)
-     end || {_Pid, MRef} <- PidMRefs],
-    T2 = time_compat:monotonic_time(),
-    Duration = time_compat:convert_time_unit(T2 - T1, native, seconds),
-    io:format("|~n~nCompiled ~B modules in ~Bs~n", [Count, Duration]),
-    {ok, Count, Duration}.
-
-split(L, N) -> split0(L, [[] || _ <- lists:seq(1, N)]).
-
-split0([],       Ls)       -> Ls;
-split0([I | Is], [L | Ls]) -> split0(Is, Ls ++ [[I | L]]).
-
-prepare_ebin_directory(Dir) ->
-    ok = rabbit_file:ensure_dir(Dir),
-    ok = delete_beam_files(Dir),
-    ok.
-
-delete_beam_files(Dir) ->
-    {ok, Files} = file:list_dir(Dir),
-    lists:foreach(fun(File) ->
-                          case filename:extension(File) of
-                              ".beam" ->
-                                  ok = file:delete(filename:join([Dir, File]));
-                              _ ->
-                                  ok
-                          end
-                  end,
-                  Files).
-
-compile_and_load(Mod) ->
-    {Mod, Beam, _} = code:get_object_code(Mod),
-    {ok, _} = hipe:compile(Mod, [], Beam, [o3, load]).
-
-compile_and_save(Module, Dir) ->
-    {Module, BeamCode, _} = code:get_object_code(Module),
-    BeamName = filename:join([Dir, atom_to_list(Module) ++ ".beam"]),
-    {ok, {Architecture, NativeCode}} = hipe:compile(Module, [], BeamCode, [o3]),
-    {ok, _, Chunks0} = beam_lib:all_chunks(BeamCode),
-    ChunkName = hipe_unified_loader:chunk_name(Architecture),
-    Chunks1 = lists:keydelete(ChunkName, 1, Chunks0),
-    Chunks = Chunks1 ++ [{ChunkName,NativeCode}],
-    {ok, BeamPlusNative} = beam_lib:build_module(Chunks),
-    ok = file:write_file(BeamName, BeamPlusNative),
-    BeamName.
-
-can_hipe_compile() ->
-    code:which(hipe) =/= non_existing.
openSUSE Build Service is sponsored by