[m-rev.] diff: fix bug with mmc --make and static libraries
Julien Fischer
juliensf at csse.unimelb.edu.au
Tue Oct 24 15:52:28 AEST 2006
Estimated hours taken: 1
Branches: main, release
Fix a bug with mmc --make and static libraries. We need to update the
archive index after copying the library to the installation directory.
The linker on Mac OS X complains if we don't do this. This is also the
behaviour of mmake anyway, so mmc --make should do the same.
compiler/make.program_target.m:
Rebuild the archive index after installing a static library.
Julien.
Index: compiler/make.program_target.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/make.program_target.m,v
retrieving revision 1.53
diff -u -r1.53 make.program_target.m
--- compiler/make.program_target.m 15 Oct 2006 23:26:45 -0000 1.53
+++ compiler/make.program_target.m 24 Oct 2006 03:31:35 -0000
@@ -340,7 +340,7 @@
% Report errors if any of the extra objects aren't present.
list.map_foldl2(dependency_status,
list.map((func(F) = dep_file(F, no)), ObjectsToCheck),
- ExtraObjStatus, !Info, !IO),
+ ExtraObjStatus, !Info, !IO),
DepsResult3 =
( list.member(deps_status_error, ExtraObjStatus) ->
@@ -1102,7 +1102,20 @@
maybe_install_library_file(Linkage, FileName, InstallDir, Succeeded, !IO) :-
globals.io_lookup_accumulating_option(lib_linkages, LibLinkages, !IO),
( list.member(Linkage, LibLinkages) ->
- install_file(FileName, InstallDir, Succeeded, !IO)
+ install_file(FileName, InstallDir, Succeeded0, !IO),
+ %
+ % We need to update the archive index after we copy a .a file to
+ % the installation directory because the linkers on some OSs
+ % complain if we don't.
+ %
+ (
+ Linkage = "static",
+ Succeeded0 = yes
+ ->
+ generate_archive_index(FileName, InstallDir, Succeeded, !IO)
+ ;
+ Succeeded = Succeeded0
+ )
;
Succeeded = yes
).
@@ -1206,6 +1219,27 @@
LinkName = Subdir/(Ext ++ "s"),
maybe_make_symlink("..", LinkName, Succeeded, !IO).
+ % Generate (or update) the index for an archive file,
+ % i.e. run ranlib on a .a file.
+ %
+:- pred generate_archive_index(file_name::in, dir_name::in, bool::out,
+ io::di, io::uo) is det.
+
+generate_archive_index(FileName, InstallDir, Succeeded, !IO) :-
+ verbose_msg(
+ (pred(!.IO::di, !:IO::uo) is det :-
+ io.write_string("Generating archive index for file ", !IO),
+ io.write_string(FileName, !IO),
+ io.write_string(" in ", !IO),
+ io.write_string(InstallDir, !IO),
+ io.nl(!IO)
+ ), !IO),
+ globals.io_lookup_string_option(ranlib_command, RanLibCommand, !IO),
+ Command = string.join_list(" ", list.map(quote_arg,
+ [RanLibCommand, InstallDir / FileName ])),
+ io.output_stream(OutputStream, !IO),
+ invoke_system_command(OutputStream, cmd_verbose, Command, Succeeded, !IO).
+
%-----------------------------------------------------------------------------%
% Clean up grade-dependent files.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list