<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>Trying to resume work here..</p>
<p>Here, I've commited this to a branch:</p>
<p><br>
</p>
<p><a href="https://github.com/modula3/cm3/commit/0d59546d11641afe3772b73f226c2e90b960d7fc" class="OWAAutoLink" id="LPlnk776313" previewremoved="true">https://github.com/modula3/cm3/commit/0d59546d11641afe3772b73f226c2e90b960d7fc</a></p>
<p><br>
</p>
<p>There are some unrelated changes I will tease out and commit separately.<br>
</p>
<p><br>
</p>
<p></p>
<p>I still believe we should implement this.</p>
<p><br>
</p>
<p>It is a variation of what people call "deterministic builds".</p>
<p><br>
</p>
<p>"deterministic builds" are kind of an overloaded term, or common sense at first, but then controversial as details emerge.</p>
<p><br>
</p>
<p>For examples:</p>
<p> - Compilers should not generate random numbers, at least not base their output on them.</p>
<p><br>
</p>
<p> - Optimizers should not "give up" after some elapsed time or consumed memory -- leading to different results on similar-but-different hardware -- though if memory can be accounted precisely and controlled by a switch, maybe</p>
<p> But then again, compilers should make good use of their host machines -- you can't have it both ways.</p>
<p><br>
</p>
<p> - full paths should occur nowhere in the output</p>
<p></p>
<p style="font-family: Calibri, Helvetica, sans-serif, Helvetica, EmojiFont, "Apple Color Emoji", "Segoe UI Emoji", NotoColorEmoji, "Segoe UI Symbol", "Android Emoji", EmojiSymbols; font-size: 16px;">
see also debugging information, that might work better with full paths -- no need to tell debugger some such search paths</p>
<div><br>
</div>
<p></p>
<p> - varying a source file's full path should not change how it compiles; but see constructs like #include ../foo.c and printf(__FILE__) or printf("%d\n", sizeof(__FILE__)). And is __FILE__ a full path or not? (Modula-3 has the analogous Compiler.ThisLine
and Compiler.ThisFile so please pardon my C++-ness, it still is relevant</p>
<p> Perhaps compiler can trim prefixes of paths.</p>
<p><br>
</p>
<p> - adding a comment in a heavily used header should not change any output; but see for example, in such header inline void foo() { printf("%d\n", __LINE__);</p>
<p><br>
</p>
<p> - adding comments anywhere, really, should not change any output -- but again __LINE__</p>
<p><br>
</p>
<p> - recompiling all the same files with the same compiler and command lines should produce the same output every time -- but see for examples printf("%d\n", __TIME__ or __DATE__ or __TIMESTAMP__) or things like Modula-3 date-based-version; burden is perhaps
on the programer to not use these problematic constructs, and compiler can maybe get switches to warn/error for them. </p>
<p><br>
</p>
<p>So, then, I add to this mix, Linux/x86, NetBSD/x86, OpenBSD/x86, Solaris/x86 should generally have identical output.</p>
<p>But again, things like printing targetname -- including as comments from the C backend.</p>
<p><br>
</p>
<p><br>
</p>
<p> - Jay</p>
<p><br>
</p>
<div id="Signature"><br>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> M3devel <m3devel-bounces@elegosoft.com> on behalf of Jay K <jayk123@hotmail.com><br>
<b>Sent:</b> Wednesday, March 15, 2017 8:37 AM<br>
<b>To:</b> m3devel<br>
<b>Subject:</b> [M3devel] compiler switch "reduce target variation"?</font>
<div> </div>
</div>
<div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Arial,Helvetica,sans-serif">
<p></p>
<div>Tangent: Should we start use git branches and pull requests?</div>
<div>Are people here reasonable able to view textual diffs? It pushes my limits personally.</div>
<div>But I know some developers work this way.</div>
<div><br>
</div>
<div><br>
</div>
<div>This is some old stuff I was working on.</div>
<div><br>
</div>
<div><br>
</div>
<div>I kinda think it should be the default, but almost everyone here protests</div>
<div>almost all of my changes, so here is a new switch instead.</div>
<div><br>
</div>
<div>The idea is to remove somewhat gratituous target variation.</div>
<div>One would have to argue over each difference and if it is gratuitous</div>
<div>and if it should be removed by default, or under a switch, and which switch.</div>
<div><br>
</div>
<div>So I'm proposing generally one switch to put everything under.</div>
<div><br>
</div>
<div>The differences I had noticed in my investigation months ago</div>
<div>is the name of the TARGET appearing, for example in paths.</div>
<div>Such as maybe in generic instantiations, in debug symbols, in output logs.</div>
<div><br>
</div>
<div>I actually think debug symbols need full paths, and so for generics,</div>
<div>they end up with target. But for now, I desist on that agenda in favor</div>
<div>of rougly the opposite.</div>
<div><br>
</div>
<div>The goal here, as I mentioned before, is to establish that</div>
<div> I386_LINUX == I386_FREEBSD == I386_NETBSD == I386_OPENBSD == I386_SOLARIS</div>
<div> == I386_DARWIN == I386_CYGWIN == I386_SOLARIS maybe == I386_NT</div>
<div> ditto AMD64, SPARC32, SPARC64, PPC32, PPC64, etc.</div>
<div> </div>
<div> So that we might collapse targets down.</div>
<div> A soon/later step would establish even fewer equivalence classes:</div>
<div> PP32be == SPARC32, PPC64be == SPARC64, => BigEndian64 or PosixBigEndian64</div>
<div> I386 == ARM => LittleEndian32</div>
<div> AMD64 == ARM64 == PPC64le => LittleEndian64</div>
<div> etc.</div>
<div> </div>
<div> and then eventually we could have one or a small number of C-based distributions.</div>
<div> </div>
<div> I have to go back and build and test all this anew.</div>
<div> </div>
<div>Reasonable?</div>
<div><br>
</div>
<div>Maybe the default?</div>
<div>Maybe add a switch for restore-target-difference or preserve-target-differences?</div>
<div><br>
</div>
<div><br>
</div>
<div>diff --git a/m3-sys/cm3/src/Main.m3 b/m3-sys/cm3/src/Main.m3</div>
<div>index 5d753e6..61b3f18 100644</div>
<div>--- a/m3-sys/cm3/src/Main.m3</div>
<div>+++ b/m3-sys/cm3/src/Main.m3</div>
<div>@@ -5,7 +5,7 @@ MODULE Main;</div>
<div> </div>
<div> IMPORT M3Timers, Pathname, Process, Quake;</div>
<div> IMPORT RTCollector, RTParams, RTutils, Thread, Wr;</div>
<div>-IMPORT TextTextTbl;</div>
<div>+IMPORT TextTextTbl, Target;</div>
<div> </div>
<div> IMPORT Builder, Dirs, M3Build, M3Options, Makefile, Msg, Utils, WebFile;</div>
<div> IMPORT MxConfig(*, M3Config, CMKey, CMCurrent *);</div>
<div>@@ -18,6 +18,8 @@ VAR</div>
<div> build_dir : TEXT := NIL;</div>
<div> mach : Quake.Machine := NIL;</div>
<div> </div>
<div>+CONST BoolToText = ARRAY BOOLEAN OF TEXT{"FALSE", "TRUE"};</div>
<div>+</div>
<div> PROCEDURE DefineIfNotDefined (qmachine: Quake.Machine;</div>
<div> symbol, value: TEXT) RAISES {Quake.Error} =</div>
<div> BEGIN</div>
<div>@@ -73,6 +75,7 @@ VAR defs: TextTextTbl.T;</div>
<div> (* DefineIfNotDefined (mach, "THREAD_LIBRARY", Version.ThreadLibrary); *)</div>
<div> (* DefineIfNotDefined (mach, "WINDOW_LIBRARY", Version.WindowLibrary); *)</div>
<div> DefineIfNotDefined (mach, "WORD_SIZE", MxConfig.HOST_WORD_SIZE);</div>
<div>+ DefineIfNotDefined (mach, "REDUCE_TARGET_VARIATION", BoolToText[Target.ReduceTargetVariation]);</div>
<div> </div>
<div> (* Even if the config file overrides the defaults, such as to do</div>
<div> a cross build, the host characteristics are still available. *)</div>
<div>diff --git a/m3-sys/cm3/src/Makefile.m3 b/m3-sys/cm3/src/Makefile.m3</div>
<div>index 64e169e..f2e1c7b 100644</div>
<div>--- a/m3-sys/cm3/src/Makefile.m3</div>
<div>+++ b/m3-sys/cm3/src/Makefile.m3</div>
<div>@@ -5,7 +5,7 @@ MODULE Makefile;</div>
<div> </div>
<div> IMPORT FS, M3File, M3Timers, OSError, Params, Process, Text, Thread, Wr;</div>
<div> IMPORT Arg, M3Build, M3Options, M3Path, Msg, Utils, TextSeq, TextTextTbl;</div>
<div>-IMPORT MxConfig, Dirs, Version;</div>
<div>+IMPORT MxConfig, Dirs, Version, Target;</div>
<div> </div>
<div> TYPE</div>
<div> NK = M3Path.Kind;</div>
<div>@@ -267,6 +267,9 @@ PROCEDURE ConvertOption (VAR s: State; arg: TEXT; arg_len: INTEGER)</div>
<div> | 'r' => IF Text.Equal(arg, "-realclean") THEN</div>
<div> ok := TRUE; (* mode set during the pre-scan *)</div>
<div> s.found_work := TRUE;</div>
<div>+ ELSIF Text.Equal(arg, "-reduce-target-variation") THEN</div>
<div>+ ok := TRUE;</div>
<div>+ Target.ReduceTargetVariation := TRUE;</div>
<div> END;</div>
<div> </div>
<div> | 's' => IF Text.Equal (arg, "-silent") THEN</div>
<div>@@ -707,6 +710,9 @@ CONST</div>
<div> " -group-writable \"",</div>
<div> " -pb <n> allow <n> parallelism in running back-end (experimental)",</div>
<div> " -no-m3ship-resolution use quake variables in .M3SHIP (experimental)",</div>
<div>+ " -reduce-target-variation omit target in some minor places such as",</div>
<div>+ " current working directory in debug information",</div>
<div>+ " for internal development purposes (showing target equivalence)",</div>
<div> "",</div>
<div> "environment variables:",</div>
<div> " M3CONFIG platform dependent configuration file to use (cm3.cfg)",</div>
<div>diff --git a/m3-sys/cminstall/src/config-no-install/cm3cfg.common b/m3-sys/cminstall/src/config-no-install/cm3cfg.common</div>
<div>index 7334252..42db06f 100644</div>
<div>--- a/m3-sys/cminstall/src/config-no-install/cm3cfg.common</div>
<div>+++ b/m3-sys/cminstall/src/config-no-install/cm3cfg.common</div>
<div>@@ -458,8 +458,14 @@ proc GetM3Back() is</div>
<div> else if equal(HOST, TARGET)</div>
<div> m3back = INSTALL_ROOT & "/bin/"</div>
<div> end end</div>
<div>- </div>
<div>+</div>
<div> m3back = "@" & m3back & "cm3cg " & GetM3BackFlags()</div>
<div>+</div>
<div>+ if defined ("REDUCE_TARGET_VARIATION")</div>
<div>+ if REDUCE_TARGET_VARIATION</div>
<div>+ m3back = m3back & " -freduce-target-variation"</div>
<div>+ end</div>
<div>+ end</div>
<div> return m3back</div>
<div> end</div>
<div> </div>
<div>diff --git a/m3-sys/m3back/src/M3C.m3 b/m3-sys/m3back/src/M3C.m3</div>
<div>index f6740c7..d584fea 100644</div>
<div>--- a/m3-sys/m3back/src/M3C.m3</div>
<div>+++ b/m3-sys/m3back/src/M3C.m3</div>
<div>@@ -29,7 +29,7 @@ VAR CaseDefaultAssertFalse := FALSE;</div>
<div> </div>
<div> (* Taken together, these help debugging, as you get more lines in the</div>
<div> C and the error messages reference C line numbers *)</div>
<div>- CONST output_line_directives = TRUE;</div>
<div>+ VAR output_line_directives := TRUE;</div>
<div> CONST output_extra_newlines = FALSE;</div>
<div> CONST inline_extract = FALSE;</div>
<div> </div>
<div>@@ -2197,7 +2197,9 @@ BEGIN</div>
<div> END;</div>
<div> </div>
<div> IF (*self.suppress_line_directive < 1 AND*) text_last_char = '\n' THEN</div>
<div>- Wr.PutText(self.c, self.line_directive);</div>
<div>+ IF NOT Target.ReduceTargetVariation THEN</div>
<div>+ Wr.PutText(self.c, self.line_directive);</div>
<div>+ END;</div>
<div> self.width := 0;</div>
<div> self.last_char_was_newline := TRUE;</div>
<div> RETURN;</div>
<div>@@ -2205,7 +2207,9 @@ BEGIN</div>
<div> </div>
<div> IF Text.FindChar(text, '\n') # -1 THEN</div>
<div> self.width := 0; (* roughly *)</div>
<div>- Wr.PutText(self.c, self.nl_line_directive);</div>
<div>+ IF NOT Target.ReduceTargetVariation THEN</div>
<div>+ Wr.PutText(self.c, self.nl_line_directive);</div>
<div>+ END;</div>
<div> self.last_char_was_newline := TRUE;</div>
<div> RETURN;</div>
<div> END;</div>
<div>@@ -2217,10 +2221,12 @@ BEGIN</div>
<div> END;</div>
<div> </div>
<div> self.width := 0;</div>
<div>- IF self.last_char_was_newline THEN</div>
<div>- Wr.PutText(self.c, self.line_directive);</div>
<div>- ELSE</div>
<div>- Wr.PutText(self.c, self.nl_line_directive);</div>
<div>+ IF NOT Target.ReduceTargetVariation THEN</div>
<div>+ IF self.last_char_was_newline THEN</div>
<div>+ Wr.PutText(self.c, self.line_directive);</div>
<div>+ ELSE</div>
<div>+ Wr.PutText(self.c, self.nl_line_directive);</div>
<div>+ END;</div>
<div> END;</div>
<div> self.last_char_was_newline := TRUE;</div>
<div> END print;</div>
<div>@@ -2339,9 +2345,10 @@ END set_error_handler;</div>
<div> PROCEDURE Prefix_Print(self: T; multipass: Multipass_t) =</div>
<div> BEGIN</div>
<div> self.comment("begin unit");</div>
<div>- self.comment("M3_TARGET = ", Target.System_name);</div>
<div>- (* This is an unnecessary target-specific output. *)</div>
<div>- (* self.comment("M3_TARGET = ", Target.System_name); *)</div>
<div>+ output_line_directives := output_line_directives AND NOT Target.ReduceTargetVariation;</div>
<div>+ IF NOT Target.ReduceTargetVariation THEN</div>
<div>+ self.comment("M3_TARGET = ", Target.System_name);</div>
<div>+ END;</div>
<div> self.comment("M3_WORDSIZE = ", IntToDec(Target.Word.size));</div>
<div> self.static_link_id := M3ID.Add("_static_link");</div>
<div> self.alloca_id := M3ID.Add("alloca");</div>
<div>@@ -4836,7 +4843,8 @@ BEGIN</div>
<div> & " ok2=" & BoolToText[ok2] & "\n"</div>
<div> );</div>
<div> RTIO.Flush();</div>
<div>- <* ASSERT FALSE *></div>
<div>+ <* ASSERT ok1 *></div>
<div>+ <* ASSERT ok2 *></div>
<div> END;</div>
<div> IF type = CGType.Int32 AND TInt.EQ(i, TInt.Min32) THEN</div>
<div> RETURN "-" & intLiteralPrefix[type] & TInt.ToText(TInt.Max32) & intLiteralSuffix[type] & "-1";</div>
<div>diff --git a/m3-sys/m3cc/gcc-4.7/gcc/dbxout.c b/m3-sys/m3cc/gcc-4.7/gcc/dbxout.c</div>
<div>index dc52576..33f8844 100644</div>
<div>--- a/m3-sys/m3cc/gcc-4.7/gcc/dbxout.c</div>
<div>+++ b/m3-sys/m3cc/gcc-4.7/gcc/dbxout.c</div>
<div>@@ -1065,8 +1065,11 @@ dbxout_init (const char *input_file_name)</div>
<div> labels. */</div>
<div> ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext", 0);</div>
<div> </div>
<div>- /* Put the current working directory in an N_SO symbol. */</div>
<div>- if (use_gnu_debug_info_extensions && !NO_DBX_MAIN_SOURCE_DIRECTORY)</div>
<div>+ /* Limit paths in debug output, to limit target variation. */</div>
<div>+ if (!reduce_target_variation)</div>
<div>+ {</div>
<div>+ /* Put the current working directory in an N_SO symbol. */</div>
<div>+ if (use_gnu_debug_info_extensions && !NO_DBX_MAIN_SOURCE_DIRECTORY)</div>
<div> {</div>
<div> static const char *cwd;</div>
<div> </div>
<div>@@ -1087,6 +1090,7 @@ dbxout_init (const char *input_file_name)</div>
<div> used_ltext_label_name = true;</div>
<div> #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */</div>
<div> }</div>
<div>+ }</div>
<div> </div>
<div> mapped_name = remap_debug_filename (input_file_name);</div>
<div> #ifdef DBX_OUTPUT_MAIN_SOURCE_FILENAME</div>
<div>diff --git a/m3-sys/m3cc/gcc-4.7/gcc/dwarf2out.c b/m3-sys/m3cc/gcc-4.7/gcc/dwarf2out.c</div>
<div>index 6f60742..291aea3 100644</div>
<div>--- a/m3-sys/m3cc/gcc-4.7/gcc/dwarf2out.c</div>
<div>+++ b/m3-sys/m3cc/gcc-4.7/gcc/dwarf2out.c</div>
<div>@@ -15450,15 +15450,18 @@ add_gnat_descriptive_type_attribute (dw_die_ref die, tree type,</div>
<div> static void</div>
<div> add_comp_dir_attribute (dw_die_ref die)</div>
<div> {</div>
<div>+ /* Limit paths in debug output, to limit target variation. */</div>
<div>+ if (reduce_target_variation)</div>
<div>+ return;</div>
<div>+</div>
<div> const char *wd = get_src_pwd ();</div>
<div>- char *wd1;</div>
<div> </div>
<div> if (wd == NULL)</div>
<div> return;</div>
<div> </div>
<div> if (DWARF2_DIR_SHOULD_END_WITH_SEPARATOR)</div>
<div> {</div>
<div>- int const wdlen = (int)strlen (wd);</div>
<div>+ size_t const wdlen = strlen (wd);</div>
<div> char * const wd1 = (char *) ggc_alloc_atomic (wdlen + 2);</div>
<div> memcpy (wd1, wd, wdlen);</div>
<div> wd1 [wdlen] = DIR_SEPARATOR;</div>
<div>diff --git a/m3-sys/m3cc/gcc-4.7/gcc/toplev.c b/m3-sys/m3cc/gcc-4.7/gcc/toplev.c</div>
<div>index 63e4b92..d468632 100644</div>
<div>--- a/m3-sys/m3cc/gcc-4.7/gcc/toplev.c</div>
<div>+++ b/m3-sys/m3cc/gcc-4.7/gcc/toplev.c</div>
<div>@@ -217,11 +217,8 @@ const char *</div>
<div> get_src_pwd (void)</div>
<div> {</div>
<div> if (! src_pwd)</div>
<div>- {</div>
<div>- src_pwd = getpwd ();</div>
<div>- if (!src_pwd)</div>
<div>-<span class="Apple-tab-span" style="white-space:pre"> </span>src_pwd = ".";</div>
<div>- }</div>
<div>+ if (reduce_target_variation || !(src_pwd = getpwd ()))</div>
<div>+ src_pwd = ".";</div>
<div> </div>
<div> return src_pwd;</div>
<div> }</div>
<div>diff --git a/m3-sys/m3cc/gcc-4.7/gcc/toplev.h b/m3-sys/m3cc/gcc-4.7/gcc/toplev.h</div>
<div>index 588cfdb..f4f7cc7 100644</div>
<div>--- a/m3-sys/m3cc/gcc-4.7/gcc/toplev.h</div>
<div>+++ b/m3-sys/m3cc/gcc-4.7/gcc/toplev.h</div>
<div>@@ -80,4 +80,6 @@ extern bool set_src_pwd<span class="Apple-tab-span" style="white-space:pre">
</span> (const char *);</div>
<div> extern HOST_WIDE_INT get_random_seed (bool);</div>
<div> extern const char *set_random_seed (const char *);</div>
<div> </div>
<div>+extern bool reduce_target_variation;</div>
<div>+</div>
<div> #endif /* ! GCC_TOPLEV_H */</div>
<div>diff --git a/m3-sys/m3cc/gcc/gcc/m3cg/lang.opt b/m3-sys/m3cc/gcc/gcc/m3cg/lang.opt</div>
<div>index 3bd0469..cb0189f 100644</div>
<div>--- a/m3-sys/m3cc/gcc/gcc/m3cg/lang.opt</div>
<div>+++ b/m3-sys/m3cc/gcc/gcc/m3cg/lang.opt</div>
<div>@@ -28,9 +28,6 @@ m3cg</div>
<div> Language</div>
<div> M3CG</div>
<div> </div>
<div>-y</div>
<div>-m3cg M3CG</div>
<div>-</div>
<div> fopcodes-trace</div>
<div> m3cg M3CG</div>
<div> Trace opcodes</div>
<div>@@ -59,10 +56,17 @@ ftypes-trace</div>
<div> m3cg M3CG</div>
<div> Trace types</div>
<div> </div>
<div>+reduce-target-variation</div>
<div>+m3cg M3CG</div>
<div>+Reduce target variation somewhat, such as by omitting current working</div>
<div>+directory from debug info. Many necessary target variations remain.</div>
<div>+</div>
<div> v</div>
<div> m3cg M3CG</div>
<div>+print version</div>
<div> </div>
<div> y</div>
<div> m3cg M3CG</div>
<div>+Trace opcodes</div>
<div> </div>
<div> ; This comment is to ensure we retain the blank line above.</div>
<div>diff --git a/m3-sys/m3cc/gcc/gcc/m3cg/parse.c b/m3-sys/m3cc/gcc/gcc/m3cg/parse.c</div>
<div>index 03417ed..071bbc8 100644</div>
<div>--- a/m3-sys/m3cc/gcc/gcc/m3cg/parse.c</div>
<div>+++ b/m3-sys/m3cc/gcc/gcc/m3cg/parse.c</div>
<div>@@ -246,6 +246,7 @@ build_case_label (tree low_value, tree high_value, tree label_decl)</div>
<div> /*======================================================= OPTION HANDLING ===*/</div>
<div> </div>
<div> static int option_trace_all;</div>
<div>+bool reduce_target_variation;</div>
<div> </div>
<div> /*===========================================================================*/</div>
<div> </div>
<div>@@ -6364,6 +6365,10 @@ m3_handle_option (size_t code, PCSTR /*arg*/, int /*value*/)</div>
<div> case OPT_ftypes_trace:</div>
<div> option_trace_all += 1;</div>
<div> break;</div>
<div>+</div>
<div>+ case OPT_reduce_target_variation:</div>
<div>+ reduce_target_variation = true;</div>
<div>+ break;</div>
<div> }</div>
<div> </div>
<div> return 1;</div>
<div>diff --git a/m3-sys/m3front/src/misc/Coverage.m3 b/m3-sys/m3front/src/misc/Coverage.m3</div>
<div>index c04c902..73fff21 100644</div>
<div><br>
</div>
<div>I don't remember what is going on here, but coverage isn't used much..</div>
<div>I suspect it might just have to do with forward vs. backward slashes,</div>
<div>and that this distinction does not really matter -- Windows accepts forward slashes</div>
<div>so we should just use them everywhere.</div>
<div><br>
</div>
<div>--- a/m3-sys/m3front/src/misc/Coverage.m3</div>
<div>+++ b/m3-sys/m3front/src/misc/Coverage.m3</div>
<div>@@ -77,8 +77,9 @@ PROCEDURE NoteProcedure (v: Value.T) =</div>
<div> PROCEDURE GenerateTables () =</div>
<div> VAR</div>
<div> nLines := MAX (0, maxLine - minLine) + 1;</div>
<div>+ fname := Host.FileTail (Host.filename);</div>
<div> l_header := TLen (Header);</div>
<div>- l_fname := TLen (Host.filename);</div>
<div>+ l_fname := TLen (fname);</div>
<div> l_trailer := TLen (Trailer);</div>
<div> size : INTEGER;</div>
<div> p : ProcHead;</div>
<div>@@ -124,10 +125,10 @@ PROCEDURE GenerateTables () =</div>
<div> (* CG.Init_int (size, Target.Integer.size, TInt.Zero, FALSE); *)</div>
<div> INC (size, Target.Integer.size); (*timestamp*)</div>
<div> </div>
<div>- CG.Init_intt (size, Target.Integer.size, Text.Length (Host.filename), FALSE);</div>
<div>+ CG.Init_intt (size, Target.Integer.size, Text.Length (fname), FALSE);</div>
<div> INC (size, Target.Integer.size); (*fileLen*)</div>
<div> </div>
<div>- CG.Init_chars (size, Host.filename, FALSE);</div>
<div>+ CG.Init_chars (size, fname, FALSE);</div>
<div> INC (size, l_fname * Target.Char.size); (*file*)</div>
<div> </div>
<div> CG.Init_intt (size, Target.Integer.size, minLine, FALSE);</div>
<div>diff --git a/m3-sys/m3front/src/misc/Host.i3 b/m3-sys/m3front/src/misc/Host.i3</div>
<div>index c71489f..af6a89a 100644</div>
<div>--- a/m3-sys/m3front/src/misc/Host.i3</div>
<div>+++ b/m3-sys/m3front/src/misc/Host.i3</div>
<div>@@ -75,4 +75,7 @@ PROCEDURE OpenUnit (name: M3ID.T; interface, generic: BOOLEAN;</div>
<div> </div>
<div> PROCEDURE CloseFile (rd: File.T);</div>
<div> </div>
<div>+PROCEDURE FileTail (path: TEXT): TEXT;</div>
<div>+ (* returns the 'tail' of 'path' -- after any slashes or even spaces *)</div>
<div>+</div>
<div> END Host.</div>
<div>diff --git a/m3-sys/m3front/src/misc/Host.m3 b/m3-sys/m3front/src/misc/Host.m3</div>
<div>index 962d3c6..79042e3 100644</div>
<div>--- a/m3-sys/m3front/src/misc/Host.m3</div>
<div>+++ b/m3-sys/m3front/src/misc/Host.m3</div>
<div>@@ -9,7 +9,7 @@</div>
<div> </div>
<div> MODULE Host;</div>
<div> </div>
<div>-IMPORT File, Text, (*ETimer, M3Timers,*) M3ID, M3Compiler;</div>
<div>+IMPORT File, Text, (*ETimer, M3Timers,*) M3ID, M3Compiler, Target;</div>
<div> </div>
<div> PROCEDURE Initialize (READONLY options: ARRAY OF TEXT): BOOLEAN =</div>
<div> BEGIN</div>
<div>@@ -192,5 +192,24 @@ PROCEDURE CloseFile (rd: File.T) =</div>
<div> END;</div>
<div> END CloseFile;</div>
<div> </div>
<div>+PROCEDURE FileTail (path: TEXT): TEXT =</div>
<div>+ VAR c: CHAR;</div>
<div>+ BEGIN</div>
<div>+ IF NOT Target.ReduceTargetVariation THEN RETURN path; END;</div>
<div>+</div>
<div>+ IF (path = NIL) THEN RETURN NIL END;</div>
<div>+</div>
<div>+ (* search for the last slash or blank in the string *)</div>
<div>+ FOR x := Text.Length (path) - 1 TO 0 BY -1 DO</div>
<div>+ c := Text.GetChar (path, x);</div>
<div>+ IF (c = '/') OR (c = ' ') OR (c = '\\') THEN</div>
<div>+ RETURN Text.Sub (path, x+1);</div>
<div>+ END;</div>
<div>+ END;</div>
<div>+</div>
<div>+ (* no slashes *)</div>
<div>+ RETURN path;</div>
<div>+ END FileTail;</div>
<div>+</div>
<div> BEGIN</div>
<div> END Host.</div>
<div>diff --git a/m3-sys/m3front/src/misc/M3Header.m3 b/m3-sys/m3front/src/misc/M3Header.m3</div>
<div>index 1e4decf..877d77c 100644</div>
<div>--- a/m3-sys/m3front/src/misc/M3Header.m3</div>
<div>+++ b/m3-sys/m3front/src/misc/M3Header.m3</div>
<div>@@ -104,7 +104,7 @@ PROCEDURE PushGeneric (VAR s: State) =</div>
<div> IF (s.generic = NIL) THEN s.failed := TRUE; RETURN; END;</div>
<div> </div>
<div> (* build a synthetic file name & start reading *)</div>
<div>- filename := old_filename & " => " & filename;</div>
<div>+ filename := Host.FileTail(old_filename) & " => " & filename;</div>
<div> Scanner.Push (filename, s.generic, is_main := Scanner.in_main);</div>
<div> </div>
<div> (* make sure we got what we wanted *)</div>
<div>diff --git a/m3-sys/m3front/src/misc/Scanner.m3 b/m3-sys/m3front/src/misc/Scanner.m3</div>
<div>index 7470374..e1dc024 100644</div>
<div>--- a/m3-sys/m3front/src/misc/Scanner.m3</div>
<div>+++ b/m3-sys/m3front/src/misc/Scanner.m3</div>
<div>@@ -228,13 +228,16 @@ PROCEDURE Here (VAR file: TEXT; VAR line: INTEGER) =</div>
<div> BEGIN</div>
<div> file := files [offset DIV MaxLines];</div>
<div> line := offset MOD MaxLines;</div>
<div>+ IF Target.ReduceTargetVariation THEN</div>
<div>+ file := Host.FileTail(file);</div>
<div>+ END;</div>
<div> END Here;</div>
<div> </div>
<div> PROCEDURE LocalHere (VAR file: TEXT; VAR line: INTEGER) =</div>
<div> VAR fnum := offset DIV MaxLines;</div>
<div> BEGIN</div>
<div> IF (local_files[fnum] = NIL) THEN</div>
<div>- local_files[fnum] := files[fnum];</div>
<div>+ local_files[fnum] := Host.FileTail(files[fnum]);</div>
<div> END;</div>
<div> file := local_files [fnum];</div>
<div> line := offset MOD MaxLines;</div>
<div>diff --git a/m3-sys/m3front/src/values/Module.m3 b/m3-sys/m3front/src/values/Module.m3</div>
<div>index a085eab..576c857 100644</div>
<div>--- a/m3-sys/m3front/src/values/Module.m3</div>
<div>+++ b/m3-sys/m3front/src/values/Module.m3</div>
<div>@@ -421,7 +421,7 @@ PROCEDURE PushGeneric (t: T; VAR rd: File.T): M3ID.T =</div>
<div> END;</div>
<div> </div>
<div> (* build a synthetic file name & start reading *)</div>
<div>- filename := old_filename & " => " & filename;</div>
<div>+ filename := Host.FileTail(old_filename) & " => " & filename;</div>
<div> Scanner.Push (filename, rd, is_main := Scanner.in_main);</div>
<div> t.genericFile := filename;</div>
<div> </div>
<div>diff --git a/m3-sys/m3middle/src/Target.i3 b/m3-sys/m3middle/src/Target.i3</div>
<div>index fe198d2..cd7acee 100644</div>
<div>--- a/m3-sys/m3middle/src/Target.i3</div>
<div>+++ b/m3-sys/m3middle/src/Target.i3</div>
<div>@@ -529,4 +529,8 @@ VAR (*CONST*)</div>
<div> test for nested procedures passed as parameters must be more</div>
<div> elaborate (e.g. HPPA). *)</div>
<div> </div>
<div>+ (* This removes some unnecessary target variation in the output,</div>
<div>+ * such as current working directory in debug output. *)</div>
<div>+ ReduceTargetVariation: BOOLEAN;</div>
<div>+</div>
<div> END Target.</div>
<div>diff --git a/scripts/python/pylib.py b/scripts/python/pylib.py</div>
<div>index 73e622f..487ad17 100755</div>
<div>--- a/scripts/python/pylib.py</div>
<div>+++ b/scripts/python/pylib.py</div>
<div>@@ -388,7 +388,7 @@ def _GetAllTargets():</div>
<div> </div>
<div> _CBackend = "c" in sys.argv or "C" in sys.argv</div>
<div> _BuildDirC = ["", "c"][_CBackend]</div>
<div>-_PossibleCm3Flags = ["boot", "keep", "override", "commands", "verbose", "why"]</div>
<div>+_PossibleCm3Flags = ["boot", "keep", "override", "commands", "verbose", "why", "reduce-target-variation", "reducetargetvariation"]</div>
<div> _SkipGccFlags = ["nogcc", "skipgcc", "omitgcc"]</div>
<div> _PossiblePylibFlags = ["noclean", "nocleangcc", "c", "C"] + _SkipGccFlags + _PossibleCm3Flags</div>
<div> </div>
<div>@@ -1610,9 +1610,9 @@ def Boot():</div>
<div> Makefile.close()</div>
<div> </div>
<div> if vms or nt:</div>
<div>- _MakeZip(BootDir[2:])</div>
<div>+ pass#_MakeZip(BootDir[2:])</div>
<div> else:</div>
<div>- _MakeTGZ(BootDir[2:])</div>
<div>+ pass#_MakeTGZ(BootDir[2:])</div>
<div> </div>
<div> #-----------------------------------------------------------------------------</div>
<div> # map action names to code and possibly other data</div>
<div><br>
</div>
<br>
<p></p>
<p><br>
</p>
<div id="Signature"><br>
</div>
</div>
</div>
</div>
</div>
</body>
</html>