[m-rev.] for review: fix problems with mmc --make

Peter Wang wangp at students.cs.mu.OZ.AU
Fri Dec 2 16:43:49 AEDT 2005


Estimated hours taken: 8
Branches: main

Fix some problems with `mmc --make'.

compiler/compile_target_code.m:
	In `link' predicate, after the file has been created in a grade
	subdirectory it would try to symlink or copy the file into the user
	directory.  This would fail if a file of the same name already existed
	there, so remove it before attempting the symlink/copy.

compiler/make.program_target.m:
	Prevent `mmc --make libFOO' from trying to produce a shared library
	if that is unsupported on the current architecture.

	Disable the logic to conditionally generate `.mh' files so as to avoid
	trouble with Mmake, which expects them to always exist.

	Fix a typo that tried to install `.mih' files into `int' directories
	instead of `ints'.

compiler/modules.m:
	Make `make_symlink_or_copy_file' write a newline after errors.

Index: compiler/compile_target_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/compile_target_code.m,v
retrieving revision 1.77
diff -u -r1.77 compile_target_code.m
--- compiler/compile_target_code.m	28 Nov 2005 02:30:18 -0000	1.77
+++ compiler/compile_target_code.m	2 Dec 2005 05:00:45 -0000
@@ -1373,6 +1373,7 @@
         globals__io_set_option(use_grade_subdirs, bool(yes), !IO),
 
         io__set_output_stream(ErrorStream, OutputStream, !IO),
+        io__remove_file(UserDirFileName, _, !IO),
         make_symlink_or_copy_file(OutputFileName, UserDirFileName,
             Succeeded, !IO),
         io__set_output_stream(OutputStream, _, !IO)
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.34
diff -u -r1.34 make.program_target.m
--- compiler/make.program_target.m	28 Nov 2005 04:11:45 -0000	1.34
+++ compiler/make.program_target.m	2 Dec 2005 05:18:00 -0000
@@ -516,10 +516,17 @@
                 InitSucceeded = yes,
                 make_linked_target(MainModuleName - static_library,
                     StaticSucceeded, !Info, !IO),
+                shared_libraries_supported(SharedLibsSupported, !IO),
                 (
                     StaticSucceeded = yes,
-                    make_linked_target(MainModuleName - shared_library,
-                        Succeeded, !Info, !IO)
+                    (
+                        SharedLibsSupported = yes,
+                        make_linked_target(MainModuleName - shared_library,
+                            Succeeded, !Info, !IO)
+                    ;
+                        SharedLibsSupported = no,
+                        Succeeded = yes
+                    )
                 ;
                     StaticSucceeded = no,
                     Succeeded = no
@@ -545,6 +552,14 @@
         )
     ).
 
+:- pred shared_libraries_supported(bool::out, io::di, io::uo) is det.
+
+shared_libraries_supported(Supported, !IO) :-
+    globals__io_lookup_string_option(library_extension, LibExt, !IO),
+    globals__io_lookup_string_option(shared_library_extension, SharedLibExt,
+        !IO),
+    Supported = (if LibExt \= SharedLibExt then yes else no).
+
 %-----------------------------------------------------------------------------%
 
 :- pred install_library(module_name::in, bool::out,
@@ -626,10 +641,13 @@
 
         globals__io_get_target(Target, !IO),
         (
-            % `.mh' files are only generated for modules containing
+            % `.mh' files are (were) only generated for modules containing
             % `:- pragma export' declarations.
-            ( Target = c ; Target = asm ),
-            Imports ^ contains_foreign_export = contains_foreign_export
+            % But `.mh' files are expected by Mmake so always generate them,
+            % otherwise there is trouble using libraries installed by
+            % `mmc --make' with Mmake.
+            ( Target = c ; Target = asm )
+            % Imports ^ contains_foreign_export = contains_foreign_export
         ->
             install_subdir_file(SubdirLinkSucceeded, LibDir/"inc",
                 ModuleName, "mh", HeaderSucceded1, !IO),
@@ -758,9 +776,13 @@
         ;
             GradeLibDir = Prefix/"lib"/"mercury"/"lib"/Grade,
             install_file(LibFileName, GradeLibDir, LibSuccess, !IO),
-            install_file(SharedLibFileName, GradeLibDir, SharedLibSuccess,
-                !IO),
-            LibsSucceeded = LibSuccess `and` SharedLibSuccess
+            ( LibFileName = SharedLibFileName ->
+                LibsSucceeded = LibSuccess
+            ;
+                install_file(SharedLibFileName, GradeLibDir, SharedLibSuccess,
+                    !IO),
+                LibsSucceeded = LibSuccess `and` SharedLibSuccess
+            )
         ),
 
         list__map_foldl2(install_grade_ints_and_headers(LinkSucceeded, Grade),
@@ -801,7 +823,7 @@
 
             % This is needed so that the file will be
             % found in Mmake's VPATH.
-            IntDir = LibDir/"int",
+            IntDir = LibDir/"ints",
             install_subdir_file(LinkSucceeded, IntDir, ModuleName, "mih",
                 HeaderSucceded2, !IO),
 
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.366
diff -u -r1.366 modules.m
--- compiler/modules.m	28 Nov 2005 02:30:20 -0000	1.366
+++ compiler/modules.m	2 Dec 2005 02:52:48 -0000
@@ -1113,7 +1113,9 @@
         io__write_string("' to `", !IO),
         io__write_string(DestinationFileName, !IO),
         io__write_string("': ", !IO),
-        io__write_string(io__error_message(Error), !IO)
+        io__write_string(io__error_message(Error), !IO),
+        io__nl(!IO),
+        io__flush_output(!IO)
     ).
 
 :- pred make_file_name(dir_name::in, bool::in, bool::in, file_name::in,

--------------------------------------------------------------------------
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