Skip to content

Commit 7fcdecd

Browse files
author
José Valim
committed
Turn off dependency tracking for compilation on release, closes #1982
1 parent bc852a6 commit 7fcdecd

File tree

3 files changed

+16
-3
lines changed

3 files changed

+16
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [ExUnit] `:include` in ExUnit only has effect if a test was previously excluded with `:exclude`
1111
* [ExUnit] Only run `setup_all` and `teardown_all` if there are tests in the case
1212
* [Kernel] Ensure bitstring modifier arguments are expanded
13+
* [Kernel] Ensure compiler does not block on missing modules
1314

1415
* Deprecations
1516
* [Kernel] `is_alive/0` is deprecated in favor of `Node.alive?`

lib/elixir/lib/kernel/error_handler.ex

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,15 @@ defmodule Kernel.ErrorHandler do
2222
parent <- { :waiting, self(), ref, module }
2323
:erlang.garbage_collect(self)
2424
receive do
25-
{ ^ref, :release } -> :ok
25+
{ ^ref, :ready } ->
26+
:ok
27+
{ ^ref, :release } ->
28+
# On release, get rid of the compiler pid,
29+
# no further allow elixir_ensure_compiled directives
30+
# and revert to the original error handler.
31+
:erlang.erase(:elixir_compiler_pid)
32+
:erlang.erase(:elixir_ensure_compiled)
33+
:erlang.process_flag(:error_handler, :error_handler)
2634
end
2735
end
2836
end

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ defmodule Kernel.ParallelCompiler do
6565
# Release waiting processes
6666
defp spawn_compilers([h|t], original, output, callbacks, waiting, queued, schedulers, result) when is_pid(h) do
6767
{ ^h, ref, _ } = List.keyfind(waiting, h, 0)
68-
h <- { ref, :release }
68+
h <- { ref, :ready }
6969
waiting = List.keydelete(waiting, h, 0)
7070
spawn_compilers(t, original, output, callbacks, waiting, queued, schedulers, result)
7171
end
@@ -76,8 +76,12 @@ defmodule Kernel.ParallelCompiler do
7676

7777
{ pid, ref } =
7878
:erlang.spawn_monitor fn ->
79-
:erlang.put(:elixir_compiler_pid, parent)
79+
# Notify Code.ensure_compiled/2 that we should
80+
# attempt to compile the module by doing a dispatch.
8081
:erlang.put(:elixir_ensure_compiled, true)
82+
83+
# Set the elixir_compiler_pid used by our custom Kernel.ErrorHandler.
84+
:erlang.put(:elixir_compiler_pid, parent)
8185
:erlang.process_flag(:error_handler, Kernel.ErrorHandler)
8286

8387
exit(try do

0 commit comments

Comments
 (0)