Skip to content

Commit bb028b9

Browse files
authored
Always consider Elixir modules on inference (#14000)
1 parent 84b5db7 commit bb028b9

File tree

12 files changed

+182
-135
lines changed

12 files changed

+182
-135
lines changed

Makefile

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ GIT_TAG = $(strip $(shell head="$(call GIT_REVISION)"; git tag --points-at $$hea
2121
SOURCE_DATE_EPOCH_PATH = lib/elixir/tmp/ebin_reproducible
2222
SOURCE_DATE_EPOCH_FILE = $(SOURCE_DATE_EPOCH_PATH)/SOURCE_DATE_EPOCH
2323

24-
.PHONY: install compile erlang elixir unicode app build_plt clean_plt dialyze test check_reproducible clean clean_residual_files format install_man clean_man docs Docs.zip Precompiled.zip zips
24+
.PHONY: install install_man build_plt clean_plt dialyze test check_reproducible clean clean_elixir clean_man format docs Docs.zip Precompiled.zip zips
2525
.NOTPARALLEL:
2626

2727
#==> Functions
@@ -65,39 +65,42 @@ endef
6565
#==> Compilation tasks
6666

6767
APP := lib/elixir/ebin/elixir.app
68+
EEX := lib/eex/ebin/Elixir.EEx.beam
69+
ELIXIR := lib/elixir/ebin/elixir.beam
6870
PARSER := lib/elixir/src/elixir_parser.erl
6971
KERNEL := lib/elixir/ebin/Elixir.Kernel.beam
7072
UNICODE := lib/elixir/ebin/Elixir.String.Unicode.beam
7173

7274
default: compile
7375

74-
compile: erlang $(APP) elixir
76+
compile: erlang elixir
7577

76-
erlang: $(PARSER)
78+
erlang: $(ELIXIR)
79+
$(ELIXIR): $(PARSER) lib/elixir/src/*
7780
$(Q) if [ ! -f $(APP) ]; then $(call CHECK_ERLANG_RELEASE); fi
7881
$(Q) cd lib/elixir && mkdir -p ebin && $(ERL_MAKE)
82+
$(Q) $(GENERATE_APP) $(VERSION)
7983

8084
$(PARSER): lib/elixir/src/elixir_parser.yrl
8185
$(Q) erlc -o $@ +'{verbose,true}' +'{report,true}' $<
8286

8387
# Since Mix depends on EEx and EEx depends on Mix,
8488
# we first compile EEx without the .app file,
8589
# then Mix, and then compile EEx fully
86-
elixir: stdlib lib/eex/ebin/Elixir.EEx.beam mix ex_unit logger eex iex
90+
elixir: stdlib $(EEX) mix ex_unit logger eex iex
91+
stdlib: $(KERNEL) $(UNICODE) $(APP)
8792

88-
stdlib: lib/elixir/lib/*.ex lib/elixir/lib/*/*.ex lib/elixir/lib/*/*/*.ex VERSION
93+
$(KERNEL): lib/elixir/src/* lib/elixir/lib/*.ex lib/elixir/lib/*/*.ex lib/elixir/lib/*/*/*.ex VERSION
8994
$(Q) if [ ! -f $(KERNEL) ]; then \
9095
echo "==> bootstrap (compile)"; \
9196
$(ERL) -s elixir_compiler bootstrap -s erlang halt; \
97+
"$(MAKE)" unicode; \
9298
fi
93-
$(Q) "$(MAKE)" unicode
9499
@ echo "==> elixir (compile)";
95100
$(Q) cd lib/elixir && ../../$(ELIXIRC) "lib/**/*.ex" -o ebin;
96-
$(Q) "$(MAKE)" app
97101

98-
app: $(APP)
99102
$(APP): lib/elixir/src/elixir.app.src lib/elixir/ebin VERSION $(GENERATE_APP)
100-
$(Q) $(GENERATE_APP) $< $@ $(VERSION)
103+
$(Q) $(GENERATE_APP) $(VERSION)
101104

102105
unicode: $(UNICODE)
103106
$(UNICODE): lib/elixir/unicode/*
@@ -143,6 +146,7 @@ check_reproducible: compile
143146
$(Q) mv lib/iex/ebin/* lib/iex/tmp/ebin_reproducible/
144147
$(Q) mv lib/logger/ebin/* lib/logger/tmp/ebin_reproducible/
145148
$(Q) mv lib/mix/ebin/* lib/mix/tmp/ebin_reproducible/
149+
$(Q) rm -rf lib/*/ebin
146150
SOURCE_DATE_EPOCH=$(call READ_SOURCE_DATE_EPOCH) "$(MAKE)" compile
147151
$(Q) echo "Diffing..."
148152
$(Q) bin/elixir lib/elixir/scripts/diff.exs lib/elixir/ebin/ lib/elixir/tmp/ebin_reproducible/
@@ -153,16 +157,10 @@ check_reproducible: compile
153157
$(Q) bin/elixir lib/elixir/scripts/diff.exs lib/mix/ebin/ lib/mix/tmp/ebin_reproducible/
154158
$(Q) echo "Builds are reproducible"
155159

156-
clean:
160+
clean: clean_man
157161
rm -rf ebin
158162
rm -rf lib/*/ebin
159163
rm -rf $(PARSER)
160-
$(Q) "$(MAKE)" clean_residual_files
161-
162-
clean_elixir:
163-
$(Q) rm -f lib/*/ebin/Elixir.*.beam
164-
165-
clean_residual_files:
166164
rm -rf lib/*/_build/
167165
rm -rf lib/*/tmp/
168166
rm -rf lib/elixir/test/ebin/
@@ -172,7 +170,9 @@ clean_residual_files:
172170
rm -rf lib/mix/test/fixtures/git_sparse_repo/
173171
rm -rf lib/mix/test/fixtures/archive/ebin/
174172
rm -f erl_crash.dump
175-
$(Q) "$(MAKE)" clean_man
173+
174+
clean_elixir:
175+
$(Q) rm -f lib/*/ebin/Elixir.*.beam
176176

177177
#==> Documentation tasks
178178

lib/elixir/lib/kernel/parallel_compiler.ex

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ defmodule Kernel.ParallelCompiler do
3131
dest = :erlang.get(:elixir_compiler_dest)
3232

3333
{:error_handler, error_handler} = :erlang.process_info(self(), :error_handler)
34-
{_parent, checker} = Module.ParallelChecker.get()
34+
{_parent, cache} = Module.ParallelChecker.get()
3535

3636
task =
3737
Task.async(fn ->
38-
Module.ParallelChecker.put(compiler_pid, checker)
38+
Module.ParallelChecker.put(compiler_pid, cache)
3939
:erlang.put(:elixir_compiler_info, {compiler_pid, file_pid})
4040
:erlang.put(:elixir_compiler_file, file)
4141
dest != :undefined and :erlang.put(:elixir_compiler_dest, dest)
@@ -253,11 +253,11 @@ defmodule Kernel.ParallelCompiler do
253253
max(:erlang.system_info(:schedulers_online), 2)
254254
end)
255255

256-
{:ok, checker} = Module.ParallelChecker.start_link(schedulers)
256+
{:ok, cache} = Module.ParallelChecker.start_link(schedulers)
257257

258258
{status, modules_or_errors, info} =
259259
try do
260-
outcome = spawn_workers(schedulers, checker, files, output, options)
260+
outcome = spawn_workers(schedulers, cache, files, output, options)
261261
{outcome, Keyword.get(options, :warnings_as_errors, false)}
262262
else
263263
{{:ok, _, %{runtime_warnings: r_warnings, compile_warnings: c_warnings} = info}, true}
@@ -281,7 +281,7 @@ defmodule Kernel.ParallelCompiler do
281281
{{:error, errors, info}, _} ->
282282
{:error, errors, info}
283283
after
284-
Module.ParallelChecker.stop(checker)
284+
Module.ParallelChecker.stop(cache)
285285
end
286286

287287
# TODO: Require this to be set from Elixir v1.19
@@ -428,13 +428,13 @@ defmodule Kernel.ParallelCompiler do
428428
end
429429

430430
defp spawn_workers([file | queue], spawned, waiting, files, result, warnings, errors, state) do
431-
%{output: output, dest: dest, checker: checker} = state
431+
%{output: output, dest: dest, checker: cache} = state
432432
parent = self()
433433
file = Path.expand(file)
434434

435435
{pid, ref} =
436436
:erlang.spawn_monitor(fn ->
437-
Module.ParallelChecker.put(parent, checker)
437+
Module.ParallelChecker.put(parent, cache)
438438
:erlang.put(:elixir_compiler_info, {parent, self()})
439439
:erlang.put(:elixir_compiler_file, file)
440440

0 commit comments

Comments
 (0)