From 70e44417259e47cc1b170f8c6758771c626ddc6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= Date: Fri, 9 Sep 2011 10:22:40 +0200 Subject: compiler: Don't include source code options in module_info(compile) As far as I know, the purpose of the compiler options included in Mod:module_info(compile) has never been documented. An educated guess is that they are there in case you want to re-compile the module with the same options, and also to aid in debugging when you need to know how a module was compiled. In neither case is there any need to include options given in the source itself in options included in Mod:module_info(compile). Including those options will only waste memory. Therefore, only include in the BEAM file the options that were given to compile:file/2. --- lib/compiler/src/compile.erl | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/compiler/src') diff --git a/lib/compiler/src/compile.erl b/lib/compiler/src/compile.erl index bfa7c6cedd..e737ead023 100644 --- a/lib/compiler/src/compile.erl +++ b/lib/compiler/src/compile.erl @@ -235,7 +235,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=[]}). @@ -246,10 +247,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) -> @@ -1228,7 +1230,8 @@ 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 -- cgit v1.2.3