[m-rev.] for review: mmc --make for external foreign files improvements
Simon Taylor
stayl at cs.mu.OZ.AU
Thu Dec 19 16:18:05 AEDT 2002
On 18-Dec-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> Estimated hours taken: 24
> Branches: main
>
> Change `mmc --make' so that it no longer builds the external foreign
> object files at the same time as it builds the target object file.
>
> This allows one to build on the IL backend where building an external
> foreign file assembly depends on having all the imported Mercury
> assemblies built first.
>
> Various fixes were also added so that `mmc --make --grade il' could make
> an executable.
> compiler/make.module_target.m:
> Always create a directory to hold the target file before
> building the target file.
Why?
> Index: compiler/make.dependencies.m
> ===================================================================
> +%
> +% If the current module we are compiling is not in the standard library
> +% and the module we are importing is then remove it, otherwise keep it.
> +% This is because in the removal case we need to import mercury.dll instead.
> +%
> +:- pred maybe_keep_std_lib_module(module_name::in,
> + module_name::in) is semidet.
I'd suggest replacing the last sentence of the comment with
`When compiling with `--target il', if the current module is not
in the standard library, we link with mercury.dll rather than
the DLL file for the imported module.'
> Index: compiler/make.m
> ===================================================================
> @@ -154,6 +157,9 @@
> ; java_code
> ; asm_code(pic)
> ; object_code(pic)
> + ; foreign_asm(foreign_language)
> + ; foreign_object(pic, foreign_language)
> + ; factt_object(pic)
s/foreign_asm/foreign_il_asm/
> Index: compiler/make.module_target.m
> ===================================================================
> +:- pred foreign_code_file(module_name::in, pic::in, foreign_language::in,
> + foreign_code_file::out, io::di, io::uo) is det.
> +
> +%-----------------------------------------------------------------------------%
> +
> +:- pred maybe_make_directory_for_target_file(target_file::in,
> + io::di, io::uo) is det.
> +
> +maybe_make_directory_for_target_file(_ModuleName - TargetType) -->
> + globals__io_get_globals(Globals),
> + { Extension = target_extension(Globals, TargetType) },
> + { string__first_char(Extension, '.', Ext0) ->
> + Ext = Ext0
> + ;
> + unexpected(this_file, "extension doesn't have leading '.'")
> + },
> + make_directory("Mercury/" ++ Ext ++ "s").
> +
> +%-----------------------------------------------------------------------------%
> +
> +foreign_code_file(ModuleName, PIC, Lang, ForeignCodeFile) -->
> + globals__io_get_globals(Globals),
Fix the order of the code here.
> +:- func get_object_extension(globals, pic) = string.
> +
> +get_object_extension(Globals, PIC) = Ext :-
> + globals__get_target(Globals, CompilationTarget),
> + ( CompilationTarget = c,
> + ( PIC = non_pic,
> + globals__lookup_string_option(Globals,
> + object_file_extension, Ext)
> + ; PIC = pic,
> + globals__lookup_string_option(Globals,
> + pic_object_file_extension, Ext)
> + )
Use compile_target_code__maybe_pic_object_file_extension.
> + ; CompilationTarget = asm,
> + ( PIC = non_pic,
> + globals__lookup_string_option(Globals,
> + object_file_extension, Ext)
> + ; PIC = pic,
> + globals__lookup_string_option(Globals,
> + pic_object_file_extension, Ext)
> + )
And here.
> Index: compiler/make.util.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/make.util.m,v
> retrieving revision 1.10
> diff -u -r1.10 make.util.m
> --- compiler/make.util.m 30 Oct 2002 13:31:49 -0000 1.10
> +++ compiler/make.util.m 18 Dec 2002 14:04:42 -0000
> @@ -625,6 +625,46 @@
> globals__lookup_string_option(Globals, object_file_extension, Ext).
> target_extension(Globals, object_code(pic)) = Ext :-
> globals__lookup_string_option(Globals, pic_object_file_extension, Ext).
> +target_extension(Globals, foreign_object(PIC, c)) = Ext :-
> + ( PIC = non_pic,
> + globals__lookup_string_option(Globals,
> + object_file_extension, Ext)
> + ; PIC = pic,
> + globals__lookup_string_option(Globals,
> + pic_object_file_extension, Ext)
> + ).
And here.
> +target_extension(Globals, foreign_object(PIC, csharp)) = Ext :-
> + ( PIC = non_pic,
> + globals__lookup_string_option(Globals,
> + object_file_extension, Ext)
> + ; PIC = pic,
> + globals__lookup_string_option(Globals,
> + pic_object_file_extension, Ext)
> + ).
> +target_extension(Globals, foreign_object(PIC, managed_cplusplus)) = Ext :-
> + ( PIC = non_pic,
> + globals__lookup_string_option(Globals,
> + object_file_extension, Ext)
> + ; PIC = pic,
> + globals__lookup_string_option(Globals,
> + pic_object_file_extension, Ext)
> + ).
> +target_extension(Globals, foreign_object(PIC, il)) = Ext :-
> + ( PIC = non_pic,
> + globals__lookup_string_option(Globals,
> + object_file_extension, Ext)
> + ; PIC = pic,
> + globals__lookup_string_option(Globals,
> + pic_object_file_extension, Ext)
> + ).
These cases should never happen, so abort.
Simon.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list