Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always adding :debug_info on erlc_options #9348

Merged
merged 6 commits into from
Sep 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/elixir/lib/code.ex
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ defmodule Code do

* `:debug_info` - when `true`, retain debug information in the compiled
module. This allows a developer to reconstruct the original source
code. Defaults to `false`.
code. Defaults to `true`.

* `:ignore_module_conflict` - when `true`, override modules that were
already defined without raising errors. Defaults to `false`.
Expand Down
2 changes: 1 addition & 1 deletion lib/mix/lib/mix/project.ex
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,7 @@ defmodule Mix.Project do
elixirc_paths: ["lib"],
erlc_paths: ["src"],
erlc_include_path: "include",
erlc_options: [:debug_info],
erlc_options: [],
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be empty since we already add it everytime when compiling erlang.

lockfile: "mix.lock",
preferred_cli_env: [],
start_permanent: false
Expand Down
11 changes: 6 additions & 5 deletions lib/mix/lib/mix/tasks/compile.erlang.ex
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ defmodule Mix.Tasks.Compile.Erlang do
Defaults to `"include"`.

* `:erlc_options` - compilation options that apply to Erlang's
compiler. Defaults to `[:debug_info]`.
compiler. Defaults to `[]`.

For a complete list of options, see `:compile.file/2`.

For example, to configure the `erlc_options` for your Erlang project you
may run:
The option `:debug_info` is always added to the end of it. You can
disable that using:

erlc_options: [:debug_info, {:i, 'path/to/include'}]
erlc_options: [debug_info: false]

"""

Expand All @@ -74,7 +74,8 @@ defmodule Mix.Tasks.Compile.Erlang do
Mix.raise(":erlc_options should be a list of options, got: #{inspect(erlc_options)}")
end

erlc_options = erlc_options ++ [:return, :report, outdir: compile_path, i: include_path]
erlc_options =
erlc_options ++ [:debug_info, :return, :report, outdir: compile_path, i: include_path]

erlc_options =
Enum.map(erlc_options, fn
Expand Down
14 changes: 14 additions & 0 deletions lib/mix/test/mix/tasks/compile.erlang_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -174,4 +174,18 @@ defmodule Mix.Tasks.Compile.ErlangTest do
assert output == ""
end)
end

@tag erlc_options: [{:warnings_as_errors, true}]
test "adds :debug_info to erlc_options by default" do
in_fixture("compile_erlang", fn ->
Mix.Tasks.Compile.Erlang.run([])

binary = File.read!("_build/dev/lib/sample/ebin/b.beam")

{:ok, {_, [debug_info: {:debug_info_v1, _, {debug_info, _}}]}} =
:beam_lib.chunks(binary, [:debug_info])

assert debug_info != :none
end)
end
end