aboutsummaryrefslogtreecommitdiffstats
path: root/lib/compiler/src
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2011-11-28 15:05:23 +0100
committerBjörn Gustavsson <[email protected]>2011-11-28 15:05:23 +0100
commitaa6824a16ba83c35ad35f9dde40c5a198c7002a2 (patch)
treecbd05ba751d4ea69f3b5caec2fdae0c9ba68265e /lib/compiler/src
parent5c3dbd080f27f683f2d30c9c7072547c68d715b3 (diff)
parent9ac7e19e35b02c02e15abd3abc4e7b5c8b62752d (diff)
downloadotp-aa6824a16ba83c35ad35f9dde40c5a198c7002a2.tar.gz
otp-aa6824a16ba83c35ad35f9dde40c5a198c7002a2.tar.bz2
otp-aa6824a16ba83c35ad35f9dde40c5a198c7002a2.zip
Merge branch 'bjorn/compiler/options/OTP-9752'
* bjorn/compiler/options/OTP-9752: filename documentation: Recommend against using filename:find_src/1,2 Teach filename:find_src/1,2 to handle slim or stripped BEAM files filename: Eliminate failing call to Mod:module_info(source_file) filename.erl:filter_options/1: Remove handling of dead options compiler: Don't include {cwd,_} in module_info(compile) compiler: Don't include source code options in module_info(compile) hipe: Teach hipe to handle slim or stripped BEAM files
Diffstat (limited to 'lib/compiler/src')
-rw-r--r--lib/compiler/src/compile.erl39
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl
index b4aa8f04bf..8815cfb26f 100644
--- a/lib/compiler/src/compile.erl
+++ b/lib/compiler/src/compile.erl
@@ -237,7 +237,8 @@ format_error({module_name,Mod,Filename}) ->
code=[],
core_code=[],
abstract_code=[], %Abstract code for debugger.
- options=[] :: [option()],
+ options=[] :: [option()], %Options for compilation
+ mod_options=[] :: [option()], %Options for module_info
errors=[],
warnings=[]}).
@@ -248,10 +249,11 @@ internal(Master, Input, Opts) ->
internal({forms,Forms}, Opts) ->
{_,Ps} = passes(forms, Opts),
- internal_comp(Ps, "", "", #compile{code=Forms,options=Opts});
+ internal_comp(Ps, "", "", #compile{code=Forms,options=Opts,
+ mod_options=Opts});
internal({file,File}, Opts) ->
{Ext,Ps} = passes(file, Opts),
- Compile = #compile{options=Opts},
+ Compile = #compile{options=Opts,mod_options=Opts},
internal_comp(Ps, File, Ext, Compile).
internal_comp(Passes, File, Suffix, St0) ->
@@ -1230,12 +1232,13 @@ beam_unused_labels(#compile{code=Code0}=St) ->
Code = beam_jump:module_labels(Code0),
{ok,St#compile{code=Code}}.
-beam_asm(#compile{ifile=File,code=Code0,abstract_code=Abst,options=Opts0}=St) ->
+beam_asm(#compile{ifile=File,code=Code0,
+ abstract_code=Abst,mod_options=Opts0}=St) ->
Source = filename:absname(File),
Opts1 = lists:map(fun({debug_info_key,_}) -> {debug_info_key,'********'};
(Other) -> Other
end, Opts0),
- Opts2 = [O || O <- Opts1, is_informative_option(O)],
+ Opts2 = [O || O <- Opts1, effects_code_generation(O)],
case beam_asm:module(Code0, Abst, Source, Opts2) of
{ok,Code} -> {ok,St#compile{code=Code,abstract_code=[]}}
end.
@@ -1305,15 +1308,23 @@ embed_native_code(St, {Architecture,NativeCode}) ->
{ok, BeamPlusNative} = beam_lib:build_module(Chunks),
St#compile{code=BeamPlusNative}.
-%% Returns true if the option is informative and therefore should be included
-%% in the option list of the compiled module.
-
-is_informative_option(beam) -> false;
-is_informative_option(report_warnings) -> false;
-is_informative_option(report_errors) -> false;
-is_informative_option(binary) -> false;
-is_informative_option(verbose) -> false;
-is_informative_option(_) -> true.
+%% effects_code_generation(Option) -> true|false.
+%% Determine whether the option could have any effect on the
+%% generated code in the BEAM file (as opposed to how
+%% errors will be reported).
+
+effects_code_generation(Option) ->
+ case Option of
+ beam -> false;
+ report_warnings -> false;
+ report_errors -> false;
+ return_errors-> false;
+ return_warnings-> false;
+ binary -> false;
+ verbose -> false;
+ {cwd,_} -> false;
+ _ -> true
+ end.
save_binary(#compile{code=none}=St) -> {ok,St};
save_binary(#compile{module=Mod,ofile=Outfile,