[m-rev.] for review: start using the new code in file_names.m

Julien Fischer jfischer at opturion.com
Mon Jun 19 21:11:29 AEST 2023


Hi Zoltan,

On Mon, 19 Jun 2023, Zoltan Somogyi wrote:

> On 2023-06-19 03:13 +02:00 CEST, "Julien Fischer" <jfischer at opturion.com> wrote:
>> That gets us further (i.e. when compiling hello world, hello.obj is now
>> successfully created).  The next mismatch is:
>>
>> Uncaught Mercury exception:
>> Software Error: predicate
>> `parse_tree.file_names.module_name_to_file_name'/9: Unexpected: FILENAME
>> MISMATCH 1 for
>> ext_other(other_ext("_init.obj"))/newext_target_init_obj(ext_init_obj_obj_opt):
>> Mercury\objs\hel
>> lo_init.obj vs Mercury\os\hello_init.obj
>
> So the same issue, just with a _init prefix. The attached diff,
> which replaces the earlier diff, should fix that. Please try it out.

That doesn't work because the big if-then-else chain handles _init.*
files (including object files) *before* it gets to the code that handles
object files. Reordering as per the attached diff works.

Julien.
-------------- next part --------------
diff --git a/compiler/file_names.m b/compiler/file_names.m
index dc565084c..8edd9e515 100644
--- a/compiler/file_names.m
+++ b/compiler/file_names.m
@@ -999,12 +999,6 @@ choose_subdir_name(Globals, ExtStr, SubDirName) :-
         )
     then
         SubDirName = SubDirNamePrime
-    else if
-        % _init.c, _init.cs, _init.o etc. files go in the cs, css, os etc
-        % subdirectories.
-        string.remove_prefix("_init.", ExtStr, ExtName)
-    then
-        SubDirName = ExtName ++ "s"
     else if
         globals.lookup_string_option(Globals, library_extension, LibExt),
         globals.lookup_string_option(Globals, shared_library_extension,
@@ -1015,6 +1009,29 @@ choose_subdir_name(Globals, ExtStr, SubDirName) :-
         )
     then
         SubDirName = "lib"
+    else if
+        some [ObjExtStr] (
+            (
+                globals.lookup_string_option(Globals,
+                    object_file_extension, ObjExtStr)
+            ;
+                globals.lookup_string_option(Globals,
+                    pic_object_file_extension, ObjExtStr)
+            ),
+            (
+                ExtStr = ObjExtStr
+            ;
+                ExtStr = "_init" ++ ObjExtStr
+            )
+        )
+    then
+        SubDirName = "os"
+    else if
+        % _init.c, _init.cs, etc. files go in the cs, css, etc
+        % subdirectories.
+        string.remove_prefix("_init.", ExtStr, ExtName)
+    then
+        SubDirName = ExtName ++ "s"
     else if
         % The usual case: `*.foo' files go in the `foos' subdirectory.
         string.remove_prefix(".", ExtStr, ExtName)


More information about the reviews mailing list