[1/3] libga68: honour a preset A68FLAGS

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

Commit Message

Trevor Woerner Aug. 5, 2026, 6:37 a.m. UTC
  AC_PROG_A68 declares A68FLAGS as a user variable with AC_ARG_VAR, which
promises that a value from the environment or the configure command line
is used, and then assigns it unconditionally nine lines later. Any value
the user supplied is discarded, so there is no way to control the flags
the Algol 68 compiles in libga68 are built with.

This matters when libga68 is built for a target whose objects have to be
reproducible: the sources compiled by ga68 receive A68FLAGS rather than
CFLAGS, so options such as -ffile-prefix-map never reach them and the
build directory is recorded in the debug information.

Default the variable only when it is unset, which is what libphobos
already does for GDCFLAGS in its own configure.ac:

    if test -z "$GDCFLAGS"; then
        GDCFLAGS="-g -O2"
    fi

Assisted by: Codex (Claude Opus 5)

libga68/ChangeLog:

	* m4/autoconf.m4 (AC_PROG_A68): Only default A68FLAGS when it
	is unset.
	* configure: Regenerate.

Signed-off-by: Trevor Woerner <twoerner@gmail.com>
---
 libga68/configure      | 4 +++-
 libga68/m4/autoconf.m4 | 4 +++-
 2 files changed, 6 insertions(+), 2 deletions(-)
  

Comments

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

Thanks for the patch.
I just installed it on your behalf.

> AC_PROG_A68 declares A68FLAGS as a user variable with AC_ARG_VAR, which
> promises that a value from the environment or the configure command line
> is used, and then assigns it unconditionally nine lines later. Any value
> the user supplied is discarded, so there is no way to control the flags
> the Algol 68 compiles in libga68 are built with.
>
> This matters when libga68 is built for a target whose objects have to be
> reproducible: the sources compiled by ga68 receive A68FLAGS rather than
> CFLAGS, so options such as -ffile-prefix-map never reach them and the
> build directory is recorded in the debug information.
>
> Default the variable only when it is unset, which is what libphobos
> already does for GDCFLAGS in its own configure.ac:
>
>     if test -z "$GDCFLAGS"; then
>         GDCFLAGS="-g -O2"
>     fi
>
> Assisted by: Codex (Claude Opus 5)
>
> libga68/ChangeLog:
>
> 	* m4/autoconf.m4 (AC_PROG_A68): Only default A68FLAGS when it
> 	is unset.
> 	* configure: Regenerate.
>
> Signed-off-by: Trevor Woerner <twoerner@gmail.com>
> ---
>  libga68/configure      | 4 +++-
>  libga68/m4/autoconf.m4 | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/libga68/configure b/libga68/configure
> index 731476fc9095..1208c3fa616d 100755
> --- a/libga68/configure
> +++ b/libga68/configure
> @@ -5906,7 +5906,9 @@ $as_echo "$ac_try_echo"; } >&5
>    rm -f conftest.er1 conftest.err
>    $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
>    test $ac_status = 0; }
> -A68FLAGS="-g -O2"
> +if test -z "$A68FLAGS"; then
> +  A68FLAGS="-g -O2"
> +fi
>  ac_ext=c
>  ac_cpp='$CPP $CPPFLAGS'
>  ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
> diff --git a/libga68/m4/autoconf.m4 b/libga68/m4/autoconf.m4
> index 7b85996265c0..daf67322f35e 100644
> --- a/libga68/m4/autoconf.m4
> +++ b/libga68/m4/autoconf.m4
> @@ -126,6 +126,8 @@ ac_compiler=$[2]
>  _AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
>  m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
>  m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
> -A68FLAGS="-g -O2"
> +if test -z "$A68FLAGS"; then
> +  A68FLAGS="-g -O2"
> +fi
>  AC_LANG_POP(Algol 68)dnl
>  ])# AC_PROG_A68
  

Patch

diff --git a/libga68/configure b/libga68/configure
index 731476fc9095..1208c3fa616d 100755
--- a/libga68/configure
+++ b/libga68/configure
@@ -5906,7 +5906,9 @@  $as_echo "$ac_try_echo"; } >&5
   rm -f conftest.er1 conftest.err
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }
-A68FLAGS="-g -O2"
+if test -z "$A68FLAGS"; then
+  A68FLAGS="-g -O2"
+fi
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
diff --git a/libga68/m4/autoconf.m4 b/libga68/m4/autoconf.m4
index 7b85996265c0..daf67322f35e 100644
--- a/libga68/m4/autoconf.m4
+++ b/libga68/m4/autoconf.m4
@@ -126,6 +126,8 @@  ac_compiler=$[2]
 _AC_DO_LIMIT([$ac_compiler --version >&AS_MESSAGE_LOG_FD])
 m4_expand_once([_AC_COMPILER_EXEEXT])[]dnl
 m4_expand_once([_AC_COMPILER_OBJEXT])[]dnl
-A68FLAGS="-g -O2"
+if test -z "$A68FLAGS"; then
+  A68FLAGS="-g -O2"
+fi
 AC_LANG_POP(Algol 68)dnl
 ])# AC_PROG_A68