[RFC PATCH 1/2] a68: add --enable-algol68-posix-prelude

Mohammad-Reza Nabipoor mnabipoor@gnu.org
Sat Oct 25 18:06:49 GMT 2025


This configure option controls inclusion of POSIX prelude in Algol68
runtime (by default it is included).
---

Hi Jose.

With --disable-algol68-posix-prelude, I can build gcc for arm-none-eabi
baremetal targets.

Is this the right approach?
If yes, then I can update ChangeLogs and send the proper patch.


Regards,
Mohammad-Reza



 gcc/algol68/a68-low-posix.cc      |  4 ++++
 gcc/algol68/a68-low-prelude.cc    |  4 ++++
 gcc/algol68/a68-parser-prelude.cc |  6 ++++++
 gcc/config.in                     |  6 ++++++
 gcc/configure.ac                  | 15 +++++++++++++++
 libga68/Makefile.am               |  5 ++++-
 libga68/configure.ac              | 17 +++++++++++++++++
 7 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/gcc/algol68/a68-low-posix.cc b/gcc/algol68/a68-low-posix.cc
index fd30677757c..772521013d0 100644
--- a/gcc/algol68/a68-low-posix.cc
+++ b/gcc/algol68/a68-low-posix.cc
@@ -42,6 +42,8 @@
 
 #include "a68.h"
 
+#ifdef ENABLE_A68_POSIX_PRELUDE
+
 /* Set the exit status of the running process, to be returned to the OS upon
    exit.  */
 
@@ -551,3 +553,5 @@ a68_posix_gets (void)
   return fold_build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (gets_fndecl)),
 		      gets_fndecl);
 }
+
+#endif // ifdef ENABLE_A68_POSIX_PRELUDE
diff --git a/gcc/algol68/a68-low-prelude.cc b/gcc/algol68/a68-low-prelude.cc
index 944db198a83..ad71b2ebdad 100644
--- a/gcc/algol68/a68-low-prelude.cc
+++ b/gcc/algol68/a68-low-prelude.cc
@@ -1891,6 +1891,8 @@ a68_lower_longlongrandom (NODE_T *p ATTRIBUTE_UNUSED, LOW_CTX_T ctx ATTRIBUTE_UN
 
 /********* POSIX prelude.  ***************/
 
+#ifdef ENABLE_A68_POSIX_PRELUDE
+
 tree
 a68_lower_setexitstatus (NODE_T *p, LOW_CTX_T ctx ATTRIBUTE_UNUSED)
 {
@@ -2149,3 +2151,5 @@ a68_lower_posixfgets (NODE_T *p, LOW_CTX_T ctx ATTRIBUTE_UNUSED)
     SET_EXPR_LOCATION (t, a68_get_node_location (p));
   return t;
 }
+
+#endif // ifdef ENABLE_A68_POSIX_PRELUDE
diff --git a/gcc/algol68/a68-parser-prelude.cc b/gcc/algol68/a68-parser-prelude.cc
index 46c61c2ee19..4a831723487 100644
--- a/gcc/algol68/a68-parser-prelude.cc
+++ b/gcc/algol68/a68-parser-prelude.cc
@@ -1364,6 +1364,8 @@ gnu_prelude (void)
 
 /* POSIX prelude.  */
 
+#ifdef ENABLE_A68_POSIX_PRELUDE
+
 static void
 posix_prelude (void)
 {
@@ -1428,6 +1430,8 @@ posix_prelude (void)
   a68_idf (A68_EXT, "fgets", m, a68_lower_posixfgets);
 }
 
+#endif // ifdef ENABLE_A68_POSIX_PRELUDE
+
 /* Transput.  */
 
 static void
@@ -1487,7 +1491,9 @@ a68_make_standard_environ (void)
   if (!OPTION_STRICT (&A68_JOB))
     {
       gnu_prelude ();
+#ifdef ENABLE_A68_POSIX_PRELUDE
       posix_prelude ();
+#endif // ifdef ENABLE_A68_POSIX_PRELUDE
     }
   stand_transput ();
 }
diff --git a/gcc/config.in b/gcc/config.in
index 0c634dfc538..efdeb352faa 100644
--- a/gcc/config.in
+++ b/gcc/config.in
@@ -119,6 +119,12 @@
 #endif
 
 
+/* Define if inclusion of POSIX prelude is expected */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_A68_POSIX_PRELUDE
+#endif
+
+
 /* Define 0/1 if static analyzer feature is enabled. */
 #ifndef USED_FOR_TARGET
 #undef ENABLE_ANALYZER
diff --git a/gcc/configure.ac b/gcc/configure.ac
index 41430c5b475..d874bc10f57 100644
--- a/gcc/configure.ac
+++ b/gcc/configure.ac
@@ -1014,6 +1014,21 @@ else
 fi,
 objc_boehm_gc='')
 
+AC_ARG_ENABLE(algol68-posix-prelude,
+[AS_HELP_STRING([--enable-algol68-posix-prelude],
+                [enable inclusion of POSIX prelude as part of GNU Algol
+                 runtime])],
+[case "$enableval" in
+  yes) enable_algol68_posix_prelude=yes ;;
+  no) enable_algol68_posix_prelude=no;;
+  *) AC_MSG_ERROR([bad value $enableval for --enable-algol68-posix-prelude]) ;;
+esac], [enable_algol68_posix_prelude=yes])
+
+if test x"$enable_algol68_posix_prelude" = xyes; then
+  AC_DEFINE([ENABLE_A68_POSIX_PRELUDE], [1],
+            [Define if inclusion of POSIX prelude is expected])
+fi
+
 AC_ARG_WITH(dwarf2,
 [AS_HELP_STRING([--with-dwarf2], [force the default debug format to be DWARF 2 (or later)])],
 dwarf2="$with_dwarf2",
diff --git a/libga68/Makefile.am b/libga68/Makefile.am
index accdd910d8d..7422d551c93 100644
--- a/libga68/Makefile.am
+++ b/libga68/Makefile.am
@@ -104,7 +104,6 @@ toolexeclib_LTLIBRARIES = libga68.la
 
 libga68_la_SOURCES = libga68.c \
                      ga68-unistr.c \
-                     ga68-posix.c \
                      ga68-alloc.c \
                      ga68-error.c \
                      ga68-standenv.c \
@@ -116,6 +115,10 @@ libga68_la_LDFLAGS = -version-info $(libga68_VERSION) \
 libga68_la_DEPENDENCIES = libga68.spec
 libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS)
 
+if ENABLE_A68_POSIX_PRELUDE
+libga68_la_SOURCES += ga68-posix.c
+endif
+
 # target overrides
 -include $(tmake_file)
 
diff --git a/libga68/configure.ac b/libga68/configure.ac
index 8d8411c8c93..139074eb784 100644
--- a/libga68/configure.ac
+++ b/libga68/configure.ac
@@ -229,6 +229,23 @@ AC_SUBST(SPEC_LIBGA68_DEPS)
 libga68_VERSION=1:0:0
 AC_SUBST(libga68_VERSION)
 
+AC_ARG_ENABLE(algol68-posix-prelude,
+[AS_HELP_STRING([--enable-algol68-posix-prelude],
+                [enable inclusion of POSIX prelude as part of GNU Algol
+                 runtime])],
+[case "$enableval" in
+  yes) enable_algol68_posix_prelude=yes ;;
+  no) enable_algol68_posix_prelude=no;;
+  *) AC_MSG_ERROR([bad value $enableval for --enable-algol68-posix-prelude]) ;;
+esac], [enable_algol68_posix_prelude=yes])
+
+AM_CONDITIONAL([ENABLE_A68_POSIX_PRELUDE],
+               [test "x$enable_algol68_posix_prelude" = xyes])
+if test x"$enable_algol68_posix_prelude" = xyes; then
+  AC_DEFINE([ENABLE_A68_POSIX_PRELUDE], [1],
+            [Define if inclusion of POSIX prelude is expected])
+fi
+
 # The Boehm GC
 
 AC_ARG_ENABLE(algol68-gc,
-- 
2.51.0



More information about the Algol68 mailing list