[2/3] libga68: do not record the source directory in generated sources

Message ID 20260805063729.3492311-2-twoerner@gmail.com
State New
Headers
Series [1/3] libga68: honour a preset A68FLAGS |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-arm-bootstrap success Build passed
linaro-tcwg-bot/tcwg_gcc_build--master-arm fail Patch failed to apply
linaro-tcwg-bot/tcwg_simplebootstrap_build--master-aarch64-bootstrap fail Patch failed to apply

Commit Message

Trevor Woerner Aug. 5, 2026, 6:37 a.m. UTC
  sppp.awk writes a header comment naming the file it was generated from,
using awk's FILENAME. The makefile rule invokes it as

    $(AWK) -f $(srcdir)/sppp.awk $< > $@

so FILENAME is $(srcdir)/standard.a68.in, and for an out-of-tree build
with an absolute srcdir the resulting standard.a68 begins with

    { This is auto-generated from /abs/path/to/libga68/standard.a68.in.
      Do not edit.  }

The content of a generated source therefore depends on where the tree
was unpacked. That is a reproducibility problem in its own right, and it
leaks the build directory into anything that ships the generated source,
such as a distribution's debug-source package.

Print only the file name, which is what the comment is for.

Assisted by: Codex (Claude Opus 5)

libga68/ChangeLog:

	* sppp.awk: Strip any directory prefix from FILENAME in the
	generated header comment.

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 libga68/sppp.awk | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Jose E. Marchesi Aug. 5, 2026, 2:27 p.m. UTC | #1
Hello.

> sppp.awk writes a header comment naming the file it was generated from,
> using awk's FILENAME. The makefile rule invokes it as
>
>     $(AWK) -f $(srcdir)/sppp.awk $< > $@
>
> so FILENAME is $(srcdir)/standard.a68.in, and for an out-of-tree build
> with an absolute srcdir the resulting standard.a68 begins with
>
>     { This is auto-generated from /abs/path/to/libga68/standard.a68.in.
>       Do not edit.  }
>
> The content of a generated source therefore depends on where the tree
> was unpacked. That is a reproducibility problem in its own right, and it
> leaks the build directory into anything that ships the generated source,
> such as a distribution's debug-source package.
>
> Print only the file name, which is what the comment is for.


It is reasonable, thanks.
I just installed this patch on your behalf.

>
> Assisted by: Codex (Claude Opus 5)
>
> libga68/ChangeLog:
>
> 	* sppp.awk: Strip any directory prefix from FILENAME in the
> 	generated header comment.
>
> Signed-off-by: Trevor Woerner <twoerner@gmail.com>
> ---
>  libga68/sppp.awk | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libga68/sppp.awk b/libga68/sppp.awk
> index 8ab94bac6363..97a2fb825b3e 100644
> --- a/libga68/sppp.awk
> +++ b/libga68/sppp.awk
> @@ -29,7 +29,9 @@ BEGIN {
>  }
>  
>  /^[ \t]*\{ Process this file/ {
> -    print "{ This is auto-generated from " FILENAME ".  Do not edit.  }"
> +    srcfile = FILENAME
> +    sub (/^.*\//, "", srcfile)
> +    print "{ This is auto-generated from " srcfile ".  Do not edit.  }"
>      next
>  }
  

Patch

diff --git a/libga68/sppp.awk b/libga68/sppp.awk
index 8ab94bac6363..97a2fb825b3e 100644
--- a/libga68/sppp.awk
+++ b/libga68/sppp.awk
@@ -29,7 +29,9 @@  BEGIN {
 }
 
 /^[ \t]*\{ Process this file/ {
-    print "{ This is auto-generated from " FILENAME ".  Do not edit.  }"
+    srcfile = FILENAME
+    sub (/^.*\//, "", srcfile)
+    print "{ This is auto-generated from " srcfile ".  Do not edit.  }"
     next
 }