diff --git a/lib/elixir/lib/code.ex b/lib/elixir/lib/code.ex index 41fc6e6b45a..c3ae3ba578c 100644 --- a/lib/elixir/lib/code.ex +++ b/lib/elixir/lib/code.ex @@ -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`. diff --git a/lib/mix/lib/mix/project.ex b/lib/mix/lib/mix/project.ex index 0b3f3ff418a..4240da05664 100644 --- a/lib/mix/lib/mix/project.ex +++ b/lib/mix/lib/mix/project.ex @@ -729,7 +729,7 @@ defmodule Mix.Project do elixirc_paths: ["lib"], erlc_paths: ["src"], erlc_include_path: "include", - erlc_options: [:debug_info], + erlc_options: [], lockfile: "mix.lock", preferred_cli_env: [], start_permanent: false diff --git a/lib/mix/lib/mix/tasks/compile.erlang.ex b/lib/mix/lib/mix/tasks/compile.erlang.ex index 465757e6bae..4111fe8a0e8 100644 --- a/lib/mix/lib/mix/tasks/compile.erlang.ex +++ b/lib/mix/lib/mix/tasks/compile.erlang.ex @@ -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] """ @@ -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 diff --git a/lib/mix/test/mix/tasks/compile.erlang_test.exs b/lib/mix/test/mix/tasks/compile.erlang_test.exs index bcd15ec0b26..414642ebada 100644 --- a/lib/mix/test/mix/tasks/compile.erlang_test.exs +++ b/lib/mix/test/mix/tasks/compile.erlang_test.exs @@ -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