aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/kernel/src/code.erl74
-rw-r--r--lib/kernel/src/code_server.erl8
-rw-r--r--lib/kernel/src/kernel.erl8
3 files changed, 31 insertions, 59 deletions
diff --git a/lib/kernel/src/code.erl b/lib/kernel/src/code.erl
index b2940dc479..6529a78034 100644
--- a/lib/kernel/src/code.erl
+++ b/lib/kernel/src/code.erl
@@ -60,7 +60,7 @@
del_path/1,
replace_path/2,
rehash/0,
- start_link/0, start_link/1,
+ start_link/0,
which/1,
where_is_file/1,
where_is_file/2,
@@ -309,11 +309,7 @@ call(Req) ->
-spec start_link() -> {'ok', pid()} | {'error', 'crash'}.
start_link() ->
- start_link([stick]).
-
--spec start_link(Flags :: [atom()]) -> {'ok', pid()} | {'error', 'crash'}.
-start_link(Flags) ->
- do_start(Flags).
+ do_start().
%%-----------------------------------------------------------------
%% In the init phase, code must not use any modules not yet loaded,
@@ -325,36 +321,21 @@ start_link(Flags) ->
%% us, so the module is loaded.
%%-----------------------------------------------------------------
-do_start(Flags) ->
+do_start() ->
maybe_warn_for_cache(),
load_code_server_prerequisites(),
- Mode = get_mode(Flags),
- case init:get_argument(root) of
- {ok,[[Root0]]} ->
- Root = filename:join([Root0]), % Normalize. Use filename
- case code_server:start_link([Root,Mode]) of
- {ok,_Pid} = Ok2 ->
- if
- Mode =:= interactive ->
- case lists:member(stick, Flags) of
- true -> do_stick_dirs();
- _ -> ok
- end;
- true ->
- ok
- end,
- %% Quietly load native code for all modules loaded so far
- Architecture = erlang:system_info(hipe_architecture),
- load_native_code_for_all_loaded(Architecture),
- Ok2;
- Other ->
- Other
- end;
- Other ->
- error_logger:error_msg("Can not start code server ~w ~n", [Other]),
- {error, crash}
- end.
+ {ok,[[Root0]]} = init:get_argument(root),
+ Mode = start_get_mode(),
+ Root = filename:join([Root0]), % Normalize.
+ Res = code_server:start_link([Root,Mode]),
+
+ maybe_stick_dirs(Mode),
+
+ %% Quietly load native code for all modules loaded so far.
+ Architecture = erlang:system_info(hipe_architecture),
+ load_native_code_for_all_loaded(Architecture),
+ Res.
%% Make sure that all modules that the code_server process calls
%% (directly or indirectly) are loaded. Otherwise the code_server
@@ -374,6 +355,16 @@ load_code_server_prerequisites() ->
_ = [M = M:module_info(module) || M <- Needed],
ok.
+maybe_stick_dirs(interactive) ->
+ case init:get_argument(nostick) of
+ {ok,[[]]} ->
+ ok;
+ _ ->
+ do_stick_dirs()
+ end;
+maybe_stick_dirs(_) ->
+ ok.
+
do_stick_dirs() ->
do_s(compiler),
do_s(stdlib),
@@ -391,19 +382,12 @@ do_s(Lib) ->
ok
end.
-get_mode(Flags) ->
- case lists:member(embedded, Flags) of
- true ->
+start_get_mode() ->
+ case init:get_argument(mode) of
+ {ok,[["embedded"]]} ->
embedded;
- _Otherwise ->
- case init:get_argument(mode) of
- {ok,[["embedded"]]} ->
- embedded;
- {ok,[["minimal"]]} ->
- minimal;
- _Else ->
- interactive
- end
+ _ ->
+ interactive
end.
%% Find out which version of a particular module we would
diff --git a/lib/kernel/src/code_server.erl b/lib/kernel/src/code_server.erl
index 6f2ed737f7..83b14a6ee4 100644
--- a/lib/kernel/src/code_server.erl
+++ b/lib/kernel/src/code_server.erl
@@ -58,7 +58,7 @@ start_link(Args) ->
%% Init the code_server process.
%% -----------------------------------------------------------
-init(Ref, Parent, [Root,Mode0]) ->
+init(Ref, Parent, [Root,Mode]) ->
register(?MODULE, self()),
process_flag(trap_exit, true),
@@ -69,12 +69,6 @@ init(Ref, Parent, [Root,Mode0]) ->
end, erlang:pre_loaded()),
ets:insert(Db, init:fetch_loaded()),
- Mode =
- case Mode0 of
- minimal -> interactive;
- _ -> Mode0
- end,
-
IPath =
case Mode of
interactive ->
diff --git a/lib/kernel/src/kernel.erl b/lib/kernel/src/kernel.erl
index 5f33f25a0d..40544da6c3 100644
--- a/lib/kernel/src/kernel.erl
+++ b/lib/kernel/src/kernel.erl
@@ -98,7 +98,7 @@ init([]) ->
{kernel_config, start_link, []},
permanent, 2000, worker, [kernel_config]},
Code = {code_server,
- {code, start_link, get_code_args()},
+ {code, start_link, []},
permanent, 2000, worker, [code]},
File = {file_server_2,
{file_server, start_link, []},
@@ -158,12 +158,6 @@ init(safe) ->
{ok, {SupFlags, Boot ++ DiskLog ++ Pg2}}.
-get_code_args() ->
- case init:get_argument(nostick) of
- {ok, [[]]} -> [[nostick]];
- _ -> []
- end.
-
start_dist_ac() ->
Spec = [{dist_ac,{dist_ac,start_link,[]},permanent,2000,worker,[dist_ac]}],
case application:get_env(kernel, start_dist_ac) of