[m-rev.] for review: fix problems with --search-lib-files-dir
Peter Wang
wangp at students.csse.unimelb.edu.au
Tue Nov 28 12:36:27 AEDT 2006
Estimated hours taken: 4
Branches: main
Fix problems with the `--search-library-files-directory <dir>' option
implementation:
- It did not work with the high level C backend because it did not add
`<dir>/Mercury/mihs' or `<dir>/Mercury/<grade>/<fullarch>/Mercury/mihs' to
be searched for `.mih' files.
- It did not work with intermodule optimisation and --use-grade-subdirs
because it did not add grade-dependent directories to be searched for
`.opt' and `.trans_opt' files.
Also, it relied on <dir> to contain (symlinks to) libraries of the correct
grade. When using --use-grade-subdirs, we now search for libraries in the
grade-dependent subdirectory under `<dir>/Mercury'.
To simplify things, we place both static and shared libraries into
`<dir>/Mercury/<grade>/<fullarch>/Mercury/lib' instead of separate
`<dir>/Mercury/<grade>/<fullarch>/Mercury/<ext>s' directories.
compiler/handle_options.m:
compiler/options.m:
Make the changes above.
Mark a couple of spots which will need to be updated for
grade-dependent `.init' files.
doc/user_guide.texi:
Update documentation for `--search-library-files-directory'.
Index: compiler/handle_options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.282
diff -u -r1.282 handle_options.m
--- compiler/handle_options.m 24 Nov 2006 03:48:01 -0000 1.282
+++ compiler/handle_options.m 28 Nov 2006 01:03:41 -0000
@@ -1563,9 +1563,9 @@
),
%
- % Handle the `.opt', C header and library search directories.
- % These couldn't be handled by options.m because they are grade
- % dependent.
+ % Handle the `.opt', C header and library search directories
+ % for installed libraries. These couldn't be handled by options.m
+ % because they are grade dependent.
%
globals.lookup_accumulating_option(!.Globals,
mercury_library_directories, MercuryLibDirs),
@@ -1578,9 +1578,9 @@
), MercuryLibDirs),
globals.lookup_accumulating_option(!.Globals,
- link_library_directories, LinkLibDirs),
+ link_library_directories, LinkLibDirs1),
globals.set_option(link_library_directories,
- accumulating(LinkLibDirs ++ ExtraLinkLibDirs), !Globals),
+ accumulating(LinkLibDirs1 ++ ExtraLinkLibDirs), !Globals),
globals.lookup_accumulating_option(!.Globals,
runtime_link_library_directories, Rpath),
@@ -1628,6 +1628,11 @@
globals.lookup_bool_option(!.Globals, use_grade_subdirs,
UseGradeSubdirs),
+ globals.lookup_accumulating_option(!.Globals,
+ search_library_files_directories, SearchLibFilesDirs),
+ globals.lookup_accumulating_option(!.Globals,
+ intermod_directories, IntermodDirs2),
+ ToGradeSubdir = (func(Dir) = Dir/"Mercury"/GradeString/FullArch),
(
UseGradeSubdirs = yes,
%
@@ -1640,36 +1645,63 @@
% `--intermod-directory Mercury/<grade>/<fullarch>'
% to find the `.opt' files in the current directory.
%
- globals.lookup_accumulating_option(!.Globals,
- intermod_directories, IntermodDirs2),
- GradeSubdirIntermodDirs =
- ["Mercury"/GradeString/FullArch |
- list.filter(isnt(unify(dir.this_directory)), IntermodDirs2)],
- globals.set_option(intermod_directories,
- accumulating(GradeSubdirIntermodDirs), !Globals)
+ GradeSubdir = "Mercury"/GradeString/FullArch,
+ %
+ % Directories listed with --search-library-files-directories need
+ % to be treated in the same way as the current directory.
+ %
+ SearchLibFilesGradeSubdirs = list.map(ToGradeSubdir,
+ SearchLibFilesDirs),
+ IntermodDirs3 = [GradeSubdir] ++ SearchLibFilesGradeSubdirs ++
+ list.filter(isnt(unify(dir.this_directory)), IntermodDirs2)
+ ;
+ UseGradeSubdirs = no,
+ IntermodDirs3 = SearchLibFilesDirs ++ IntermodDirs2
+ ),
+ globals.set_option(intermod_directories,
+ accumulating(IntermodDirs3), !Globals),
+
+ globals.lookup_accumulating_option(!.Globals,
+ link_library_directories, LinkLibDirs2),
+ (
+ UseGradeSubdirs = yes,
+ %
+ % With --use-grade-subdirs we need to search in
+ % `Mercury/<grade>/<fullarch>/Mercury/lib' for libraries, for
+ % each directory listed with --search-library-files-directory.
+ %
+ ToGradeLibDir = (func(Dir) = ToGradeSubdir(Dir)/"Mercury"/"lib"),
+ SearchGradeLibDirs = list.map(ToGradeLibDir, SearchLibFilesDirs),
+ LinkLibDirs = SearchGradeLibDirs ++ LinkLibDirs2
;
- UseGradeSubdirs = no
+ UseGradeSubdirs = no,
+ LinkLibDirs = SearchLibFilesDirs ++ LinkLibDirs2
),
+ globals.set_option(link_library_directories,
+ accumulating(LinkLibDirs), !Globals),
%
% When searching for a header (.mh or .mih) file,
% module_name_to_file_name uses the plain header name, so we need to
- % add the full path to the header files in the current directory.
+ % add the full path to the header files in the current directory,
+ % and any directories listed with --search-library-files-directory.
%
globals.lookup_bool_option(!.Globals, use_subdirs, UseSubdirs),
(
( UseGradeSubdirs = yes ->
- MihsSubdir = "Mercury"/GradeString/FullArch/"Mercury"/"mihs"
+ ToMihsSubdir = (func(Dir) = ToGradeSubdir(Dir)/"Mercury"/"mihs")
; UseSubdirs = yes ->
- MihsSubdir = "Mercury"/"mihs"
+ ToMihsSubdir = (func(Dir) = Dir/"Mercury"/"mihs")
;
fail
)
->
globals.lookup_accumulating_option(!.Globals, c_include_directory,
CIncludeDirs1),
- SubdirCIncludeDirs =
- [dir.this_directory, MihsSubdir | CIncludeDirs1],
+ MihsSubdir = ToMihsSubdir(dir.this_directory),
+ SearchLibMihsSubdirs = list.map(ToMihsSubdir, SearchLibFilesDirs),
+ SubdirCIncludeDirs = [dir.this_directory, MihsSubdir |
+ SearchLibMihsSubdirs ++ CIncludeDirs1],
globals.set_option(c_include_directory,
accumulating(SubdirCIncludeDirs), !Globals)
;
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.412
diff -u -r1.412 modules.m
--- compiler/modules.m 24 Nov 2006 03:48:05 -0000 1.412
+++ compiler/modules.m 28 Nov 2006 01:11:46 -0000
@@ -871,9 +871,12 @@
bool::in, file_name::out, io::di, io::uo) is det.
choose_file_name(_ModuleName, BaseName, Ext, Search, MkDir, FileName, !IO) :-
- globals.io_lookup_bool_option(use_subdirs, UseSubdirs, !IO),
- globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO),
globals.io_get_globals(Globals, !IO),
+ globals.lookup_bool_option(Globals, use_subdirs, UseSubdirs),
+ globals.lookup_bool_option(Globals, use_grade_subdirs, UseGradeSubdirs),
+ globals.lookup_string_option(Globals, library_extension, LibExt),
+ globals.lookup_string_option(Globals, shared_library_extension,
+ SharedLibExt),
(
(
UseSubdirs = no
@@ -973,7 +976,6 @@
( Ext = ".dir/*.o"
; Ext = ".dir/*.$O"
)
-
->
SubDirName = "dirs"
;
@@ -1013,6 +1015,13 @@
->
SubDirName = "deps"
;
+ % Static and shared libraries go in the `lib' subdirectory.
+ ( Ext = LibExt
+ ; Ext = SharedLibExt
+ )
+ ->
+ SubDirName = "lib"
+ ;
% The usual case: `*.foo' files go in the `foos' subdirectory.
string.append(".", ExtName, Ext)
->
@@ -1118,9 +1127,9 @@
string::in, file_name::out, io::di, io::uo) is det.
make_file_name(SubDirName, Search, MkDir, BaseName, Ext, FileName, !IO) :-
- globals.io_lookup_bool_option(use_grade_subdirs, UseGradeSubdirs, !IO),
- globals.io_lookup_string_option(fullarch, FullArch, !IO),
globals.io_get_globals(Globals, !IO),
+ globals.lookup_bool_option(Globals, use_grade_subdirs, UseGradeSubdirs),
+ globals.lookup_string_option(Globals, fullarch, FullArch),
(
UseGradeSubdirs = yes,
file_is_arch_or_grade_dependent(Globals, Ext),
Index: compiler/options.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.537
diff -u -r1.537 options.m
--- compiler/options.m 24 Nov 2006 03:48:06 -0000 1.537
+++ compiler/options.m 28 Nov 2006 00:23:51 -0000
@@ -693,6 +693,7 @@
; link_objects
; mercury_library_directories
; mercury_library_directory_special
+ ; search_library_files_directories
; search_library_files_directory_special
; mercury_libraries
; mercury_library_special
@@ -1429,8 +1430,9 @@
link_libraries - accumulating([]),
link_objects - accumulating([]),
mercury_library_directory_special - string_special,
- search_library_files_directory_special - string_special,
mercury_library_directories - accumulating([]),
+ search_library_files_directory_special - string_special,
+ search_library_files_directories - accumulating([]),
mercury_library_special - string_special,
mercury_libraries - accumulating([]),
mercury_standard_library_directory - maybe_string(no),
@@ -2505,17 +2507,20 @@
list.foldl(append_to_accumulating_option, [
search_directories - dir.make_path_name(Dir, "ints"),
c_include_directory - dir.make_path_name(Dir, "inc"),
+ % XXX Trace goal fix.
init_file_directories - dir.make_path_name(Dir, "modules"),
mercury_library_directories - Dir
], OptionTable0).
option_table_add_search_library_files_directory(OptionTable0, Dir) =
+ % Grade dependent directories need to be handled in handle_options.m
+ % when we know the grade.
list.foldl(append_to_accumulating_option, [
search_directories - Dir,
- intermod_directories - Dir,
c_include_directory - Dir,
+ % XXX Trace goal fix.
init_file_directories - Dir,
- link_library_directories - Dir
+ search_library_files_directories - Dir
], OptionTable0).
:- func append_to_accumulating_option(pair(option, string),
@@ -4516,7 +4521,8 @@
"\tLink with the specified object file.",
"--search-lib-files-dir <directory>",
"--search-library-files-directory <directory>",
- "\tEquivalent to adding <directory> using all of the",
+ "\tSearch <directory> for uninstalled Mercury library files.",
+ "\tSimilar to adding <directory> using all of the",
"\t`--search-directory', `--intermod-directory',",
"\t`--library-directory', `--init-file-directory' and",
"\t`--c-include-directory' options.",
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.499
diff -u -r1.499 user_guide.texi
--- doc/user_guide.texi 24 Nov 2006 03:48:15 -0000 1.499
+++ doc/user_guide.texi 28 Nov 2006 00:25:04 -0000
@@ -8475,10 +8475,13 @@
@findex --search-library-files-directory
@cindex Directories for libraries
@cindex Search path for libraries
-Equivalent to adding @var{directory} using all of the
+Search @var{directory} for uninstalled Mercury library files.
+Similar to adding @var{directory} using all of the
@samp{--search-directory}, @samp{--intermod-directory},
@samp{--library-directory}, @samp{--init-file-directory} and
- at samp{--c-include-directory} options.
+ at samp{--c-include-directory} options, but
+does the right thing when @samp{--use-subdirs} or
+ at samp{--use-grade-subdirs} options are used.
@sp 1
@item --mld @var{directory}
--------------------------------------------------------------------------
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