[m-rev.] for post-commit review: Ensure trans_opt_deps rules can be read back.

Peter Wang novalazy at gmail.com
Thu Dec 15 15:50:51 AEDT 2022


When writing out a trans_opt_deps rule in a .d file,
always write each dependency on a separate line. If the rule is
written "horizontally" because there is only one dependency, e.g.

    foo.trans_opt_date : bar.trans_opt

then maybe_read_d_file_for_trans_opt_deps will not be able to parse the
list, and the .trans_opt file will not be used.

compiler/mmakefiles.m:
    As above.

diff --git a/compiler/mmakefiles.m b/compiler/mmakefiles.m
index 9c07905f0..f9d340df8 100644
--- a/compiler/mmakefiles.m
+++ b/compiler/mmakefiles.m
@@ -445,7 +445,15 @@ write_mmake_entry(OutStream, _WriteComments, MmakeEntry, !IO) :-
         ;
             SourceFiles = [HeadSourceFile | TailSourceFiles],
             io.write_string(OutStream, " : ", !IO),
-            ( if 1 + list.length(TailSourceFiles) > max_horizontal then
+            ( if
+                (
+                    % Always write trans_opt_deps vertically as the list needs
+                    % to be parseable by maybe_read_d_file_for_trans_opt_deps.
+                    RuleName = "trans_opt_deps"
+                ;
+                    1 + list.length(TailSourceFiles) > max_horizontal
+                )
+            then
                 io.write_string(OutStream, "\\\n", !IO),
                 write_mmake_file_names_vertical(OutStream,
                     HeadSourceFile, TailSourceFiles, !IO)
-- 
2.38.0



More information about the reviews mailing list