[m-rev.] for review: fix foreign_decls in the LLDS grades
Peter Ross
pro at missioncriticalit.com
Mon Aug 5 23:16:24 AEST 2002
On Mon, Aug 05, 2002 at 02:47:01PM +1000, Simon Taylor wrote:
> On 01-Aug-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > Estimated hours taken: 5
> > Branches: main
> >
> > Record foreign_decls in the .mh file.
> > This fixes a bug where a definitions of pragma exported functions where
> > refereing to undefined pragma foreign_type names.
>
> > Index: mercury/compiler/mlds_to_c.m
> > ===================================================================
> > RCS file: /home/staff/zs/imp/mercury/compiler/mlds_to_c.m,v
> > retrieving revision 1.134
> > diff -u -r1.134 mlds_to_c.m
> > --- mercury/compiler/mlds_to_c.m 23 Jul 2002 16:35:36 -0000 1.134
> > +++ mercury/compiler/mlds_to_c.m 31 Jul 2002 15:11:18 -0000
> > @@ -547,11 +547,15 @@
> > io__state, io__state).
> > :- mode mlds_output_c_hdr_decls(in, in, in, di, uo) is det.
> >
> > -mlds_output_c_hdr_decls(_ModuleName, Indent, ForeignCode) -->
> > +mlds_output_c_hdr_decls(ModuleName, Indent, ForeignCode) -->
> > { ForeignCode = mlds__foreign_code(RevHeaderCode, _RevImports,
> > _RevBodyCode, _ExportDefns) },
> > { HeaderCode = list__reverse(RevHeaderCode) },
> > - io__write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent)).
> > + { DeclGuard = decl_guard(mlds_module_name_to_sym_name(ModuleName)) },
> > + io__write_strings(["#ifndef ", DeclGuard,
> > + "\n#define ", DeclGuard, "\n"]),
> > + io__write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent)),
> > + io__write_string("\n#endif\n").
>
> You haven't addressed the review comments about the previous
> version of this change.
>
Here is the lastest interdiff, which addresses the review comments from
Simon.
Is this find to check in now.
diff -u mercury/compiler/intermod.m mercury/compiler/intermod.m
--- mercury/compiler/intermod.m 31 Jul 2002 15:27:26 -0000
+++ mercury/compiler/intermod.m 2 Aug 2002 14:50:32 -0000
@@ -320,12 +320,6 @@
pred_info_clauses_info(PredInfo, ClauseInfo),
clauses_info_clauses(ClauseInfo, Clauses),
- % XXX until mmake can handle the extra dependencies introduced
- % in intermod__write_intermod_info_2 we cannot use
- % foreign_procs because they might depend on foreign decls
- % which are in the header file.
- \+ pred_info_pragma_goal_type(PredInfo),
-
pred_info_procids(PredInfo, [ProcId | _ProcIds]),
pred_info_procedures(PredInfo, Procs),
map__lookup(Procs, ProcId, ProcInfo),
@@ -1124,22 +1118,13 @@
% `:- pragma foreign_import_module("C", ModuleName).'
% to the `.opt' file.
%
- % XXX We should do this, but mmake can't handle
- % the extra dependencies properly yet, so building
- % the standard library fails (mmake attempts to build
- % tree234.o before std_util.h is built). Note that once
- % this is fixed the restriction on adding pragma
- % foreign_procs to the .opt file in
- % intermod__should_be_processed can be removed.
- %
% XXX Currently we only handle procedures
% exported to C.
{
% Check that the import could contain anything.
( PragmaExportedProcs \= []
; RevForeignDecls \= []
- ),
- semidet_fail
+ )
->
module_info_name(ModuleInfo, ModuleName),
ForeignImportThisModule = foreign_import_module(c,
diff -u mercury/compiler/mlds_to_c.m mercury/compiler/mlds_to_c.m
--- mercury/compiler/mlds_to_c.m 31 Jul 2002 15:11:18 -0000
+++ mercury/compiler/mlds_to_c.m 5 Aug 2002 12:43:08 -0000
@@ -309,6 +309,11 @@
io__write_string("/* :- implementation. */\n"),
mlds_output_src_bootstrap_defines, io__nl,
+ mlds_output_src_import(Indent,
+ mercury_import(
+ compiler_visible_interface,
+ mercury_module_name_to_mlds(ModuleName))),
+
%
% If there are `:- pragma export' declarations,
% #include the `.mh' file.
@@ -321,10 +326,6 @@
user_visible_interface,
mercury_module_name_to_mlds(ModuleName)))
),
- mlds_output_src_import(Indent,
- mercury_import(
- compiler_visible_interface,
- mercury_module_name_to_mlds(ModuleName))),
io__nl.
%
@@ -551,7 +552,12 @@
{ ForeignCode = mlds__foreign_code(RevHeaderCode, _RevImports,
_RevBodyCode, _ExportDefns) },
{ HeaderCode = list__reverse(RevHeaderCode) },
- { DeclGuard = decl_guard(mlds_module_name_to_sym_name(ModuleName)) },
+ { is_std_lib_module(ModuleName, ModuleNameStr) ->
+ SymName = unqualified(ModuleNameStr)
+ ;
+ SymName = mlds_module_name_to_sym_name(ModuleName)
+ },
+ { DeclGuard = decl_guard(SymName) },
io__write_strings(["#ifndef ", DeclGuard,
"\n#define ", DeclGuard, "\n"]),
io__write_list(HeaderCode, "\n", mlds_output_c_hdr_decl(Indent)),
only in patch2:
--- mercury/library/Mmakefile 29 Jul 2002 07:51:06 -0000 1.95
+++ mercury/library/Mmakefile 2 Aug 2002 14:54:11 -0000
@@ -239,9 +239,11 @@
# making tree234.$O first improves effective parallelism with parallel makes.
# `mmc --make' does not support parallel makes, so this dependency just
# slows things down.
-ifeq ($(MMAKE_USE_MMC_MAKE),no)
-lib_std: $(os_subdir)tree234.$O
-endif
+# XXX This is currently disabled because .mh files aren't built before
+# the tree234.o
+#ifeq ($(MMAKE_USE_MMC_MAKE),no)
+#lib_std: $(os_subdir)tree234.$O
+#endif
lib_std: lib$(STD_LIB_NAME)
ifeq ($(MMAKE_USE_MMC_MAKE),no)
only in patch2:
--- mercury/compiler/modules.m 29 Jul 2002 07:50:55 -0000 1.241
+++ mercury/compiler/modules.m 5 Aug 2002 12:45:17 -0000
@@ -2063,6 +2063,20 @@
Intermod),
globals__io_lookup_accumulating_option(intermod_directories,
IntermodDirs),
+
+ % If intermodule_optimization is enabled then
+ % build all the .c files before the .o files to
+ % avoid problems with foreign_import_module
+ % dependencies not being correctly calculated.
+ ( { Intermod = yes } ->
+ io__write_strings(DepStream, [
+ "\n\n",
+ ObjFileName, " : "
+ ]),
+ write_dependencies_list(AllDeps, ".c", DepStream)
+ ;
+ []
+ ),
( { Intermod = yes ; UseOptFiles = yes } ->
io__write_strings(DepStream, [
"\n\n",
--------------------------------------------------------------------------
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