This configure option controls the inclusion of POSIX prelude in Algol68 runtime. By default it is not included in non-POSIX systems.
Thanks to Pietro Monteiro for demonstrating how to handle unsupported platforms. Signed-off-by: Mohammad-Reza Nabipoor <[email protected]> libga68/ChangeLog * configure.ac: Add --enable-algol68-posix-prelude option. * configure.tgt: New file to check POSIX prelude support. * Makefile.am: Make inclusion of `ga68-posix.c' conditional. * configure: Regenerate. * Makefile.in: Likewise. * config.h.in: Likewise. gcc/ChangeLog * configure.ac: Add --enable-algol68-posix-prelude option. * configure: Regenerate. * config.in: Likewise. gcc/algol68/ChangeLog * a68-parser-prelude.cc: Make POSIX prelude available conditionally. * a68-low.cc: Likewise. gcc/testsuite/ChangeLog * lib/algol68-target-supports.exp: New file which provides `check_effective_target_posix_prelude' procedure. * lib/algol68-dg.exp: Load `algol68-target-supports.exp'. * lib/algol68-torture.exp: Likewise. * algol68/compile/error-nested-comment-1.a68: Require `posix_prelude'. * algol68/compile/error-string-break-1.a68: Likewise. * algol68/compile/error-string-break-2.a68: Likewise. * algol68/compile/error-string-break-3.a68: Likewise. * algol68/compile/error-string-break-4.a68: Likewise. * algol68/compile/error-string-break-5.a68: Likewise. * algol68/compile/error-string-break-6.a68: Likewise. * algol68/compile/error-string-break-7.a68: Likewise. * algol68/compile/include.a68: Likewise. * algol68/compile/include-supper.a68: Likewise. * algol68/compile/module-1.a68: Likewise. * algol68/compile/module-pub-mangling-8.a68: Likewise. * algol68/compile/modules/module1.a68: Likewise. * algol68/compile/modules/program-error-outside-access-1.a68: Likewise. * algol68/compile/module-top-down-1.a68: Likewise. * algol68/compile/nested-comment-1.a68: Likewise. * algol68/compile/nested-comment-2.a68: Likewise. * algol68/compile/snobol.a68: Likewise. * algol68/compile/supper-12.a68: Likewise. * algol68/compile/supper-1.a68: Likewise. * algol68/compile/upper-1.a68: Likewise. * algol68/compile/warning-hidding-6.a68: Likewise. * algol68/compile/warning-hidding-7.a68: Likewise. * algol68/compile/warning-module-hidding-1.a68: Likewise. * algol68/execute/assignation-multiple-2.a68: Likewise. * algol68/execute/goto-5.a68: Likewise. * algol68/execute/modules/module1.a68: Likewise. * algol68/execute/posix-argc-argv-1.a68: Likewise. * algol68/execute/posix-fputc-fputs-1.a68: Likewise. * algol68/execute/posix-putchar-1.a68: Likewise. * algol68/execute/posix-stride-1.a68: Likewise. * algol68/execute/posix-exit-1.a68: Likewise. * algol68/execute/posix-fopen-1.a68: Likewise. * algol68/execute/posix-getenv-1.a68: Likewise. * algol68/execute/posix-lseek.a68: Likewise. * algol68/execute/posix-perror-1.a68: Likewise. * algol68/execute/posix-stdinouterr-1.a68: Likewise. * algol68/execute/posix-strerror-1.a68: Likewise. * algol68/execute/procedured-goto-1.a68: Likewise. * algol68/execute/quine.a68: Likewise. * algol68/execute/random-1.a68: Likewise. * algol68/execute/slice-indexing-4.a68: Likewise. * algol68/execute/string-2.a68: Likewise. * algol68/execute/fsize-1.a68: Likewise. --- Hi Jose. I've tested this patch for the following targets: - arm-none-eabi - aarch64-none-elf - riscv64-elf Resulting ga68 compilers are capable of generating working code. On these targets, "make check-algol68 RUNTESTFLAGS='compile.exp'" works as expected. But there's no simple way to run `execute.exp' tests (that I'm aware of). On x86-64, --disable-algol68-posix-prelude works as expected and `compile.exp' tests are all passing. All non-POSIX tests from `execute.exp' are also passing, but I couldn't manage to convince DejaGnu to skip POSIX tests. It'd be nice if you help me to fix this problem. I get errors like: ``` ERROR: (DejaGnu) proc "dg-require-effective-target 1 posix_prelude" does not exist. The error code is TCL LOOKUP COMMAND dg-require-effective-target The info on the error is: invalid command name "dg-require-effective-target" while executing "::tcl_unknown dg-require-effective-target 1 posix_prelude" ("uplevel" body line 1) invoked from within "uplevel 1 ::tcl_unknown $args" ERROR: $HOME/p/gnu/gcc-branches/disable-posix-prelude/gcc/testsuite/algol68/execute/assignation-multiple-2.a68: invalid command name "dg-require-effective-target" for " dg-require-effective-target 1 posix_prelude " ``` Regards, Mohammad-Reza gcc/algol68/a68-low.cc | 14 +- gcc/algol68/a68-parser-prelude.cc | 6 + gcc/config.in | 6 + gcc/configure | 32 +++- gcc/configure.ac | 21 +++ .../compile/error-nested-comment-1.a68 | 1 + .../algol68/compile/error-string-break-1.a68 | 1 + .../algol68/compile/error-string-break-2.a68 | 3 +- .../algol68/compile/error-string-break-3.a68 | 3 +- .../algol68/compile/error-string-break-4.a68 | 3 +- .../algol68/compile/error-string-break-5.a68 | 3 +- .../algol68/compile/error-string-break-6.a68 | 3 +- .../algol68/compile/error-string-break-7.a68 | 3 +- .../algol68/compile/include-supper.a68 | 1 + gcc/testsuite/algol68/compile/include.a68 | 1 + gcc/testsuite/algol68/compile/module-1.a68 | 1 + .../algol68/compile/module-pub-mangling-8.a68 | 1 + .../algol68/compile/module-top-down-1.a68 | 1 + .../algol68/compile/modules/module1.a68 | 1 + .../program-error-outside-access-1.a68 | 2 + .../algol68/compile/nested-comment-1.a68 | 1 + .../algol68/compile/nested-comment-2.a68 | 1 + gcc/testsuite/algol68/compile/snobol.a68 | 1 + gcc/testsuite/algol68/compile/supper-1.a68 | 1 + gcc/testsuite/algol68/compile/supper-12.a68 | 1 + gcc/testsuite/algol68/compile/upper-1.a68 | 1 + .../algol68/compile/warning-hidding-6.a68 | 2 + .../algol68/compile/warning-hidding-7.a68 | 2 + .../compile/warning-module-hidding-1.a68 | 1 + .../execute/assignation-multiple-2.a68 | 1 + gcc/testsuite/algol68/execute/fsize-1.a68 | 1 + gcc/testsuite/algol68/execute/goto-5.a68 | 1 + .../algol68/execute/modules/module1.a68 | 1 + .../algol68/execute/posix-argc-argv-1.a68 | 1 + .../algol68/execute/posix-exit-1.a68 | 1 + .../algol68/execute/posix-fopen-1.a68 | 1 + .../algol68/execute/posix-fputc-fputs-1.a68 | 1 + .../algol68/execute/posix-getenv-1.a68 | 1 + gcc/testsuite/algol68/execute/posix-lseek.a68 | 1 + .../algol68/execute/posix-perror-1.a68 | 1 + .../algol68/execute/posix-putchar-1.a68 | 1 + .../algol68/execute/posix-stdinouterr-1.a68 | 1 + .../algol68/execute/posix-strerror-1.a68 | 1 + .../algol68/execute/posix-stride-1.a68 | 1 + .../algol68/execute/procedured-goto-1.a68 | 1 + gcc/testsuite/algol68/execute/quine.a68 | 1 + gcc/testsuite/algol68/execute/random-1.a68 | 1 + .../algol68/execute/slice-indexing-4.a68 | 1 + gcc/testsuite/algol68/execute/string-2.a68 | 1 + gcc/testsuite/lib/algol68-dg.exp | 1 + gcc/testsuite/lib/algol68-target-supports.exp | 38 ++++ gcc/testsuite/lib/algol68-torture.exp | 3 +- libga68/Makefile.am | 11 +- libga68/Makefile.in | 41 ++--- libga68/config.h.in | 3 + libga68/configure | 166 +++++------------- libga68/configure.ac | 27 ++- libga68/configure.tgt | 35 ++++ 58 files changed, 302 insertions(+), 161 deletions(-) create mode 100644 gcc/testsuite/lib/algol68-target-supports.exp create mode 100644 libga68/configure.tgt diff --git a/gcc/algol68/a68-low.cc b/gcc/algol68/a68-low.cc index 09cd5339b68..55bbf48534f 100644 --- a/gcc/algol68/a68-low.cc +++ b/gcc/algol68/a68-low.cc @@ -1343,9 +1343,11 @@ lower_module_text (NODE_T *p, LOW_CTX_T ctx) { /* Add calls to implicitly accessed standard preludes. */ tree standard_prelude = lower_lude_decl ("STANDARD", false); - tree posix_prelude = lower_lude_decl ("POSIX", false); a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, standard_prelude, 0)); +#ifdef ENABLE_A68_POSIX_PRELUDE + tree posix_prelude = lower_lude_decl ("POSIX", false); a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, posix_prelude, 0)); +#endif } /* Add calls to preludes of modules in REVELATION_PART. */ @@ -1410,9 +1412,11 @@ lower_module_text (NODE_T *p, LOW_CTX_T ctx) if (!flag_building_libga68) { /* Add calls to implicitly accessed standard postludes. */ - tree standard_postlude = lower_lude_decl ("STANDARD", true); +#ifdef ENABLE_A68_POSIX_PRELUDE tree posix_postlude = lower_lude_decl ("POSIX", true); a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, posix_postlude, 0)); +#endif + tree standard_postlude = lower_lude_decl ("STANDARD", true); a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, standard_postlude, 0)); } } @@ -1516,17 +1520,23 @@ lower_particular_program (NODE_T *p, LOW_CTX_T ctx) tree standard_prelude = lower_lude_decl ("STANDARD", false); tree standard_postlude = lower_lude_decl ("STANDARD", true); +#ifdef ENABLE_A68_POSIX_PRELUDE tree posix_prelude = lower_lude_decl ("POSIX", false); tree posix_postlude = lower_lude_decl ("POSIX", true); +#endif NODE_T *enclosed_clause = (IS (SUB (p), ENCLOSED_CLAUSE) ? SUB (p) : NEXT (SUB (p))); a68_push_range (M_VOID); a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, standard_prelude, 0)); +#ifdef ENABLE_A68_POSIX_PRELUDE a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, posix_prelude, 0)); +#endif a68_add_stmt (a68_lower_tree (enclosed_clause, ctx)); +#ifdef ENABLE_A68_POSIX_PRELUDE a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, posix_postlude, 0)); +#endif a68_add_stmt (build_call_expr_loc (UNKNOWN_LOCATION, standard_postlude, 0)); tree body = a68_pop_range (); diff --git a/gcc/algol68/a68-parser-prelude.cc b/gcc/algol68/a68-parser-prelude.cc index 67edf55f9f7..71f141c4636 100644 --- a/gcc/algol68/a68-parser-prelude.cc +++ b/gcc/algol68/a68-parser-prelude.cc @@ -1382,6 +1382,8 @@ gnu_prelude (void) /* POSIX prelude. */ +#ifdef ENABLE_A68_POSIX_PRELUDE + static void posix_prelude (void) { @@ -1390,6 +1392,8 @@ posix_prelude (void) "POSIX", "ga68"); } +#endif + void a68_make_standard_environ (void) { @@ -1418,6 +1422,8 @@ a68_make_standard_environ (void) if (!OPTION_STRICT (&A68_JOB)) { gnu_prelude (); +#ifdef ENABLE_A68_POSIX_PRELUDE posix_prelude (); +#endif } } diff --git a/gcc/config.in b/gcc/config.in index a4fd5e0c108..c373b6504d5 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -125,6 +125,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 b/gcc/configure index a344e11b912..889c646237e 100755 --- a/gcc/configure +++ b/gcc/configure @@ -994,6 +994,7 @@ enable_tls enable_vtable_verify enable_analyzer enable_objc_gc +enable_algol68_posix_prelude with_dwarf2 enable_shared enable_gcov @@ -1744,6 +1745,9 @@ Optional Features: --disable-analyzer disable -fanalyzer static analyzer --enable-objc-gc enable the use of Boehm's garbage collector with the GNU Objective-C runtime + --enable-algol68-posix-prelude + enable inclusion of POSIX prelude as part of GNU + Algol 68 runtime --disable-shared don't provide a shared libgcc --disable-gcov don't provide libgcov and related host tools --enable-languages=LIST specify which front-ends to build @@ -8121,6 +8125,30 @@ else fi +# Check whether --enable-algol68-posix-prelude was given. +if test "${enable_algol68_posix_prelude+set}" = set; then : + enableval=$enable_algol68_posix_prelude; case "$enableval" in + yes) enable_algol68_posix_prelude=yes ;; + no) enable_algol68_posix_prelude=no;; + *) as_fn_error $? "bad value $enableval for --enable-algol68-posix-prelude" "$LINENO" 5 ;; +esac +else + enable_algol68_posix_prelude=default +fi + + +if test "x$enable_algol68_posix_prelude" = xdefault; then + unset LIBGA68_POSIXPRED_SUPPORTED + . "${srcdir}/../libga68/configure.tgt" + enable_algol68_posix_prelude=$LIBGA68_POSIXPRED_SUPPORTED +fi + +if test "x$enable_algol68_posix_prelude" = xyes; then + +$as_echo "#define ENABLE_A68_POSIX_PRELUDE 1" >>confdefs.h + +fi + # Check whether --with-dwarf2 was given. if test "${with_dwarf2+set}" = set; then : @@ -21953,7 +21981,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 21956 "configure" +#line 21984 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -22059,7 +22087,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 22062 "configure" +#line 22090 "configure" #include "confdefs.h" #if HAVE_DLFCN_H diff --git a/gcc/configure.ac b/gcc/configure.ac index d12382d2fa3..3761599c471 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -1028,6 +1028,27 @@ 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 68 + 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=default]) + +if test "x$enable_algol68_posix_prelude" = xdefault; then + unset LIBGA68_POSIXPRED_SUPPORTED + . "${srcdir}/../libga68/configure.tgt" + enable_algol68_posix_prelude=$LIBGA68_POSIXPRED_SUPPORTED +fi + +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/gcc/testsuite/algol68/compile/error-nested-comment-1.a68 b/gcc/testsuite/algol68/compile/error-nested-comment-1.a68 index 3c78f34a51a..04658fdb4eb 100644 --- a/gcc/testsuite/algol68/compile/error-nested-comment-1.a68 +++ b/gcc/testsuite/algol68/compile/error-nested-comment-1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { The string in nested comment is in one logical line. } begin { puts ("{'n { dg-error {} } diff --git a/gcc/testsuite/algol68/compile/error-string-break-1.a68 b/gcc/testsuite/algol68/compile/error-string-break-1.a68 index fd8e765ab48..257a7856502 100644 --- a/gcc/testsuite/algol68/compile/error-string-break-1.a68 +++ b/gcc/testsuite/algol68/compile/error-string-break-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN puts ("hello '_ world") # { dg-error "invalid string break sequence" } # diff --git a/gcc/testsuite/algol68/compile/error-string-break-2.a68 b/gcc/testsuite/algol68/compile/error-string-break-2.a68 index 465f8f80404..6857e9f9806 100644 --- a/gcc/testsuite/algol68/compile/error-string-break-2.a68 +++ b/gcc/testsuite/algol68/compile/error-string-break-2.a68 @@ -1,2 +1,3 @@ -begin puts ("hello '(U0000) world") # { dg-error "eight" } # +{ dg-require-effective-target posix_prelude } +begin puts ("hello '(U0000) world") { dg-error "eight" } end diff --git a/gcc/testsuite/algol68/compile/error-string-break-3.a68 b/gcc/testsuite/algol68/compile/error-string-break-3.a68 index e4cf8f6f1a3..5373c106e69 100644 --- a/gcc/testsuite/algol68/compile/error-string-break-3.a68 +++ b/gcc/testsuite/algol68/compile/error-string-break-3.a68 @@ -1,2 +1,3 @@ -begin puts ("hello '(u00) world") # { dg-error "four" } # +{ dg-require-effective-target posix_prelude } +begin puts ("hello '(u00) world") { dg-error "four" } end diff --git a/gcc/testsuite/algol68/compile/error-string-break-4.a68 b/gcc/testsuite/algol68/compile/error-string-break-4.a68 index 76adff9b2bc..85c2167fb8e 100644 --- a/gcc/testsuite/algol68/compile/error-string-break-4.a68 +++ b/gcc/testsuite/algol68/compile/error-string-break-4.a68 @@ -1,2 +1,3 @@ -begin puts ("hello '(u) world") # { dg-error "four" } # +{ dg-require-effective-target posix_prelude } +begin puts ("hello '(u) world") { dg-error "four" } end diff --git a/gcc/testsuite/algol68/compile/error-string-break-5.a68 b/gcc/testsuite/algol68/compile/error-string-break-5.a68 index c42589fde7c..58efac7306f 100644 --- a/gcc/testsuite/algol68/compile/error-string-break-5.a68 +++ b/gcc/testsuite/algol68/compile/error-string-break-5.a68 @@ -1,2 +1,3 @@ -begin puts ("hello '(u0010u0020) world") # { dg-error "" } # +{ dg-require-effective-target posix_prelude } +begin puts ("hello '(u0010u0020) world") { dg-error "" } end diff --git a/gcc/testsuite/algol68/compile/error-string-break-6.a68 b/gcc/testsuite/algol68/compile/error-string-break-6.a68 index fed7d84b221..07568373679 100644 --- a/gcc/testsuite/algol68/compile/error-string-break-6.a68 +++ b/gcc/testsuite/algol68/compile/error-string-break-6.a68 @@ -1,2 +1,3 @@ -begin puts ("hello '(u0010'/) world") # { dg-error "" } # +{ dg-require-effective-target posix_prelude } +begin puts ("hello '(u0010'/) world") { dg-error "" } end diff --git a/gcc/testsuite/algol68/compile/error-string-break-7.a68 b/gcc/testsuite/algol68/compile/error-string-break-7.a68 index 58545e01ce1..8fddd4dd8ab 100644 --- a/gcc/testsuite/algol68/compile/error-string-break-7.a68 +++ b/gcc/testsuite/algol68/compile/error-string-break-7.a68 @@ -1,2 +1,3 @@ -begin puts ("'") # { dg-error "" } # +{ dg-require-effective-target posix_prelude } +begin puts ("'") { dg-error "" } end diff --git a/gcc/testsuite/algol68/compile/include-supper.a68 b/gcc/testsuite/algol68/compile/include-supper.a68 index af0521be101..c3dc24b25ed 100644 --- a/gcc/testsuite/algol68/compile/include-supper.a68 +++ b/gcc/testsuite/algol68/compile/include-supper.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { dg-options "-I$srcdir/algol68/compile/a68includes" } { dg-additional-files "$srcdir/algol68/compile/a68includes/hello-supper.a68 $srcdir/algol68/compile/a68includes/goodbye-supper.a68" } diff --git a/gcc/testsuite/algol68/compile/include.a68 b/gcc/testsuite/algol68/compile/include.a68 index 6f4855b33da..494fe917476 100644 --- a/gcc/testsuite/algol68/compile/include.a68 +++ b/gcc/testsuite/algol68/compile/include.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-I$srcdir/algol68/compile/a68includes -fstropping=upper" } # # { dg-additional-files "$srcdir/algol68/compile/a68includes/hello.a68 $srcdir/algol68/compile/a68includes/goodbye.a68" } # diff --git a/gcc/testsuite/algol68/compile/module-1.a68 b/gcc/testsuite/algol68/compile/module-1.a68 index e4f3215cc35..417cf273dd2 100644 --- a/gcc/testsuite/algol68/compile/module-1.a68 +++ b/gcc/testsuite/algol68/compile/module-1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } module Argp = def mode ArgOpt = struct (char name, string long_name, bool arg_required, proc(string)bool handler); diff --git a/gcc/testsuite/algol68/compile/module-pub-mangling-8.a68 b/gcc/testsuite/algol68/compile/module-pub-mangling-8.a68 index 054befb7c6f..f55f6d435c4 100644 --- a/gcc/testsuite/algol68/compile/module-pub-mangling-8.a68 +++ b/gcc/testsuite/algol68/compile/module-pub-mangling-8.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { dg-options "-O0" } { Symbols that should _not_ include the module name. } diff --git a/gcc/testsuite/algol68/compile/module-top-down-1.a68 b/gcc/testsuite/algol68/compile/module-top-down-1.a68 index 3f130c25019..f37b09996fd 100644 --- a/gcc/testsuite/algol68/compile/module-top-down-1.a68 +++ b/gcc/testsuite/algol68/compile/module-top-down-1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { This test is to check that serial clauses and enquiry clauses are properly skipped in module texts. } module Foo = diff --git a/gcc/testsuite/algol68/compile/modules/module1.a68 b/gcc/testsuite/algol68/compile/modules/module1.a68 index f49a747033e..bc10ece1569 100644 --- a/gcc/testsuite/algol68/compile/modules/module1.a68 +++ b/gcc/testsuite/algol68/compile/modules/module1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # module Module1 = def pub mode MyInt = int; diff --git a/gcc/testsuite/algol68/compile/modules/program-error-outside-access-1.a68 b/gcc/testsuite/algol68/compile/modules/program-error-outside-access-1.a68 index 39f0f1896f8..bc2ca0d3460 100644 --- a/gcc/testsuite/algol68/compile/modules/program-error-outside-access-1.a68 +++ b/gcc/testsuite/algol68/compile/modules/program-error-outside-access-1.a68 @@ -1,3 +1,5 @@ +{ "module1" depends on POSIX prelude, so this program also depends on it. } +{ dg-require-effective-target posix_prelude } { dg-modules "module1" } begin int x = access Module1 ( beast_number ), diff --git a/gcc/testsuite/algol68/compile/nested-comment-1.a68 b/gcc/testsuite/algol68/compile/nested-comment-1.a68 index f5752435a0e..cb780144bdf 100644 --- a/gcc/testsuite/algol68/compile/nested-comment-1.a68 +++ b/gcc/testsuite/algol68/compile/nested-comment-1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { Comment delimiters within strings get ignored. } begin { puts { ("{""'n"); } } skip diff --git a/gcc/testsuite/algol68/compile/nested-comment-2.a68 b/gcc/testsuite/algol68/compile/nested-comment-2.a68 index 9fc912f2687..d1b0d63dbcc 100644 --- a/gcc/testsuite/algol68/compile/nested-comment-2.a68 +++ b/gcc/testsuite/algol68/compile/nested-comment-2.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { The string in nested comment is in one logical line. } begin { puts ("{'n\ diff --git a/gcc/testsuite/algol68/compile/snobol.a68 b/gcc/testsuite/algol68/compile/snobol.a68 index 9b6c4fc824f..df214626261 100644 --- a/gcc/testsuite/algol68/compile/snobol.a68 +++ b/gcc/testsuite/algol68/compile/snobol.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # # This is Frank Pagan's SNOBOL4 Interpreter in ALGOL 68 (1976), diff --git a/gcc/testsuite/algol68/compile/supper-1.a68 b/gcc/testsuite/algol68/compile/supper-1.a68 index a572f1e929f..b9483f2670f 100644 --- a/gcc/testsuite/algol68/compile/supper-1.a68 +++ b/gcc/testsuite/algol68/compile/supper-1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { dg-options {-fstropping=supper} } begin mode Some_Mode = real; diff --git a/gcc/testsuite/algol68/compile/supper-12.a68 b/gcc/testsuite/algol68/compile/supper-12.a68 index 497a88a2e66..4d6aff70e21 100644 --- a/gcc/testsuite/algol68/compile/supper-12.a68 +++ b/gcc/testsuite/algol68/compile/supper-12.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { dg-options {-fstropping=supper} } begin for i while i < 10 diff --git a/gcc/testsuite/algol68/compile/upper-1.a68 b/gcc/testsuite/algol68/compile/upper-1.a68 index 6fb7871301f..4f09cb9a06d 100644 --- a/gcc/testsuite/algol68/compile/upper-1.a68 +++ b/gcc/testsuite/algol68/compile/upper-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options {-fstropping=upper} } # BEGIN MODE SOME_MODE = REAL; diff --git a/gcc/testsuite/algol68/compile/warning-hidding-6.a68 b/gcc/testsuite/algol68/compile/warning-hidding-6.a68 index be419b30c56..148ec62201a 100644 --- a/gcc/testsuite/algol68/compile/warning-hidding-6.a68 +++ b/gcc/testsuite/algol68/compile/warning-hidding-6.a68 @@ -1,3 +1,5 @@ +{ Because of `getchar' we need POSIX prelude } +{ dg-require-effective-target posix_prelude } { dg-options "-Whidden-declarations=prelude" } begin real b; begin int maxint = 10; { dg-warning "hides" } diff --git a/gcc/testsuite/algol68/compile/warning-hidding-7.a68 b/gcc/testsuite/algol68/compile/warning-hidding-7.a68 index e641a93934e..6e436bd804f 100644 --- a/gcc/testsuite/algol68/compile/warning-hidding-7.a68 +++ b/gcc/testsuite/algol68/compile/warning-hidding-7.a68 @@ -1,3 +1,5 @@ +{ Because of `getchar' we need POSIX prelude } +{ dg-require-effective-target posix_prelude } { dg-options "-Whidden-declarations=all" } begin real b; begin int getchar = 10; { dg-warning "hides" } diff --git a/gcc/testsuite/algol68/compile/warning-module-hidding-1.a68 b/gcc/testsuite/algol68/compile/warning-module-hidding-1.a68 index 461cd468114..23f6f167e5e 100644 --- a/gcc/testsuite/algol68/compile/warning-module-hidding-1.a68 +++ b/gcc/testsuite/algol68/compile/warning-module-hidding-1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } { dg-options "-Whidden-declarations=all" } module Bar = diff --git a/gcc/testsuite/algol68/execute/assignation-multiple-2.a68 b/gcc/testsuite/algol68/execute/assignation-multiple-2.a68 index 22ff7e11942..c7954ea1125 100644 --- a/gcc/testsuite/algol68/execute/assignation-multiple-2.a68 +++ b/gcc/testsuite/algol68/execute/assignation-multiple-2.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } begin [5]struct(char i, real r) foo; { The stride in the single dimension of the multiple resulting diff --git a/gcc/testsuite/algol68/execute/fsize-1.a68 b/gcc/testsuite/algol68/execute/fsize-1.a68 index 17e3ef2ba9e..2e4fa76e2e1 100644 --- a/gcc/testsuite/algol68/execute/fsize-1.a68 +++ b/gcc/testsuite/algol68/execute/fsize-1.a68 @@ -1,2 +1,3 @@ +{ dg-require-effective-target posix_prelude } begin assert (fsize (-1) = - long long 1) end diff --git a/gcc/testsuite/algol68/execute/goto-5.a68 b/gcc/testsuite/algol68/execute/goto-5.a68 index a5c720e3e63..e54f8649bf1 100644 --- a/gcc/testsuite/algol68/execute/goto-5.a68 +++ b/gcc/testsuite/algol68/execute/goto-5.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN PROC is prime = (INT m) BOOL: BEGIN IF m < 2 diff --git a/gcc/testsuite/algol68/execute/modules/module1.a68 b/gcc/testsuite/algol68/execute/modules/module1.a68 index 7fad6e54cf7..0190d09d6e9 100644 --- a/gcc/testsuite/algol68/execute/modules/module1.a68 +++ b/gcc/testsuite/algol68/execute/modules/module1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } module Module1 = def pub mode MyInt = int, MyOtherInt = int; diff --git a/gcc/testsuite/algol68/execute/posix-argc-argv-1.a68 b/gcc/testsuite/algol68/execute/posix-argc-argv-1.a68 index a6380380ffe..95d8390f2bc 100644 --- a/gcc/testsuite/algol68/execute/posix-argc-argv-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-argc-argv-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN ASSERT (argc >= 1); ASSERT (argv (1000) = ""); diff --git a/gcc/testsuite/algol68/execute/posix-exit-1.a68 b/gcc/testsuite/algol68/execute/posix-exit-1.a68 index f62f61332ca..308eb93d554 100644 --- a/gcc/testsuite/algol68/execute/posix-exit-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-exit-1.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } begin posix_exit (0); assert (false) { if this assert triggers then posix_exit is broken } end diff --git a/gcc/testsuite/algol68/execute/posix-fopen-1.a68 b/gcc/testsuite/algol68/execute/posix-fopen-1.a68 index d2a0c406f2b..67f42bc3a89 100644 --- a/gcc/testsuite/algol68/execute/posix-fopen-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-fopen-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN INT fd = fopen ("doesn''t exist", file o default); ASSERT (fd = -1) diff --git a/gcc/testsuite/algol68/execute/posix-fputc-fputs-1.a68 b/gcc/testsuite/algol68/execute/posix-fputc-fputs-1.a68 index bf0af6e6e22..0bdbaee9542 100644 --- a/gcc/testsuite/algol68/execute/posix-fputc-fputs-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-fputc-fputs-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN fputc (stdout, "X"); ASSERT (fputs (stdout, "foo") = 3); diff --git a/gcc/testsuite/algol68/execute/posix-getenv-1.a68 b/gcc/testsuite/algol68/execute/posix-getenv-1.a68 index d1e69056812..07bfc501f7e 100644 --- a/gcc/testsuite/algol68/execute/posix-getenv-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-getenv-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN ASSERT (getenv ("") = ""); ASSERT (getenv ("DOESNT EXIST FOR SURE") = "") diff --git a/gcc/testsuite/algol68/execute/posix-lseek.a68 b/gcc/testsuite/algol68/execute/posix-lseek.a68 index 8f20dc53d97..34c30c0c348 100644 --- a/gcc/testsuite/algol68/execute/posix-lseek.a68 +++ b/gcc/testsuite/algol68/execute/posix-lseek.a68 @@ -1,3 +1,4 @@ +{ dg-require-effective-target posix_prelude } begin int fd = fopen ("../../ga68", file_o_rdonly); assert (fd /= -1); assert (errno = 0); diff --git a/gcc/testsuite/algol68/execute/posix-perror-1.a68 b/gcc/testsuite/algol68/execute/posix-perror-1.a68 index a349dd72ad8..4701c1de21b 100644 --- a/gcc/testsuite/algol68/execute/posix-perror-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-perror-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # # { dg-output "^something unique: " } # BEGIN INT fd = fopen ("doesn''t exist", file o default); diff --git a/gcc/testsuite/algol68/execute/posix-putchar-1.a68 b/gcc/testsuite/algol68/execute/posix-putchar-1.a68 index 01bfbbd371e..bd65a1143f7 100644 --- a/gcc/testsuite/algol68/execute/posix-putchar-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-putchar-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN putchar ("X"); putchar ("Y"); diff --git a/gcc/testsuite/algol68/execute/posix-stdinouterr-1.a68 b/gcc/testsuite/algol68/execute/posix-stdinouterr-1.a68 index dc5b373d938..ed0969bd756 100644 --- a/gcc/testsuite/algol68/execute/posix-stdinouterr-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-stdinouterr-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN ASSERT (stdin = 0); ASSERT (stdout = 1); diff --git a/gcc/testsuite/algol68/execute/posix-strerror-1.a68 b/gcc/testsuite/algol68/execute/posix-strerror-1.a68 index 607e40d0b9d..01a68983de9 100644 --- a/gcc/testsuite/algol68/execute/posix-strerror-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-strerror-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN INT fd = fopen ("doesn''t exist", file o default); IF fd = -1 THEN ASSERT (strerror (errno) /= "") FI diff --git a/gcc/testsuite/algol68/execute/posix-stride-1.a68 b/gcc/testsuite/algol68/execute/posix-stride-1.a68 index 6e7a79d2640..fe2a2c11e9d 100644 --- a/gcc/testsuite/algol68/execute/posix-stride-1.a68 +++ b/gcc/testsuite/algol68/execute/posix-stride-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN [,]CHAR matrix = (("1","H","3"), ("4","O","6"), diff --git a/gcc/testsuite/algol68/execute/procedured-goto-1.a68 b/gcc/testsuite/algol68/execute/procedured-goto-1.a68 index 8d3dc21c782..515b09f8816 100644 --- a/gcc/testsuite/algol68/execute/procedured-goto-1.a68 +++ b/gcc/testsuite/algol68/execute/procedured-goto-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN INT i := 4; beg: WHILE i > 0 diff --git a/gcc/testsuite/algol68/execute/quine.a68 b/gcc/testsuite/algol68/execute/quine.a68 index 9fd9e422fdc..afb6a9a95a2 100644 --- a/gcc/testsuite/algol68/execute/quine.a68 +++ b/gcc/testsuite/algol68/execute/quine.a68 @@ -1,2 +1,3 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # (STRING a="(STRING a="";puts(2*a[:19]+2*a[19:]);0)";puts(2*a[:19]+2*a[19:])) diff --git a/gcc/testsuite/algol68/execute/random-1.a68 b/gcc/testsuite/algol68/execute/random-1.a68 index 82cc6e3a576..c5644d3c5e4 100644 --- a/gcc/testsuite/algol68/execute/random-1.a68 +++ b/gcc/testsuite/algol68/execute/random-1.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN IF random > 0.5 THEN puts ("yes\n") ELSE puts ("no\n") FI; LONG REAL rr = long random; diff --git a/gcc/testsuite/algol68/execute/slice-indexing-4.a68 b/gcc/testsuite/algol68/execute/slice-indexing-4.a68 index bf3a3b18d70..2abf4293d98 100644 --- a/gcc/testsuite/algol68/execute/slice-indexing-4.a68 +++ b/gcc/testsuite/algol68/execute/slice-indexing-4.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN MODE PERSON = STRUCT (INT i, STRING s); []PERSON persons = ((10, "foo"), (20, "barbar"), (30, "baz")); diff --git a/gcc/testsuite/algol68/execute/string-2.a68 b/gcc/testsuite/algol68/execute/string-2.a68 index b0b898a51ef..a1bdae8aee9 100644 --- a/gcc/testsuite/algol68/execute/string-2.a68 +++ b/gcc/testsuite/algol68/execute/string-2.a68 @@ -1,3 +1,4 @@ +# { dg-require-effective-target posix_prelude } # # { dg-options "-fstropping=upper" } # BEGIN STRING s; ASSERT (LWB s = 1 AND UPB s = 0 AND ELEMS s = 0); diff --git a/gcc/testsuite/lib/algol68-dg.exp b/gcc/testsuite/lib/algol68-dg.exp index 21ff22945fd..7195af65c2b 100644 --- a/gcc/testsuite/lib/algol68-dg.exp +++ b/gcc/testsuite/lib/algol68-dg.exp @@ -15,6 +15,7 @@ # <http://www.gnu.org/licenses/>. load_lib gcc-dg.exp +load_lib algol68-target-supports.exp # Define ALGOL68 callbacks for dg.exp. diff --git a/gcc/testsuite/lib/algol68-target-supports.exp b/gcc/testsuite/lib/algol68-target-supports.exp new file mode 100644 index 00000000000..cc8026cc833 --- /dev/null +++ b/gcc/testsuite/lib/algol68-target-supports.exp @@ -0,0 +1,38 @@ +# Copyright (C) 2026 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +load_lib dg.exp + +# If this target does not enable POSIX prelude, skip this test. + +proc check_effective_target_posix_prelude {} { + global objdir + global srcdir + + set posix_supported 1 + + set filename $objdir/check-for-posix-prelude.a68 + set objfile $objdir/check-for-posix-prelude.o + set fd [open $filename w] + puts $fd {(stdin)} + close $fd + set comp_output [algol68_target_compile $filename $objfile object ""] + switch -glob -- $comp_output { + "* error: *" { set posix_supported 0 } + } + + return $posix_supported +} diff --git a/gcc/testsuite/lib/algol68-torture.exp b/gcc/testsuite/lib/algol68-torture.exp index 1638edde5a9..393038f72cf 100644 --- a/gcc/testsuite/lib/algol68-torture.exp +++ b/gcc/testsuite/lib/algol68-torture.exp @@ -18,10 +18,9 @@ # the author. load_lib dg.exp - load_lib target-supports.exp - load_lib target-utils.exp +load_lib algol68-target-supports.exp # The default option list can be overridden by # TORTURE_OPTIONS="{ { list1 } ... { listN } }" diff --git a/libga68/Makefile.am b/libga68/Makefile.am index 073e71c611e..7af6aea520a 100644 --- a/libga68/Makefile.am +++ b/libga68/Makefile.am @@ -125,7 +125,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 \ @@ -134,8 +133,8 @@ libga68_la_LIBTOOLFLAGS = libga68_la_CFLAGS = $(LIBGA68_GCFLAGS) $(LIBGA68_BOEHM_GC_INCLUDES) libga68_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ $(version_arg) $(lt_host_flags) $(extra_darwin_ldflags_libga68) -libga68_la_DEPENDENCIES = libga68.spec $(version_dep) standard.lo posix.lo -libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS) standard.lo posix.lo +libga68_la_DEPENDENCIES = libga68.spec $(version_dep) standard.lo +libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS) standard.lo # Rules to build the Algol 68 code in the library. @@ -153,6 +152,12 @@ standard.a68 : standard.a68.in BUILT_SOURCES = standard.a68 +if ENABLE_A68_POSIX_PRELUDE +libga68_la_SOURCES += ga68-posix.c +libga68_la_DEPENDENCIES += posix.lo +libga68_la_LIBADD += posix.lo +endif + # target overrides -include $(tmake_file) diff --git a/libga68/Makefile.in b/libga68/Makefile.in index 2b91a5e952f..1bb214fcd34 100644 --- a/libga68/Makefile.in +++ b/libga68/Makefile.in @@ -114,6 +114,9 @@ host_triplet = @host@ target_triplet = @target@ @ENABLE_DARWIN_AT_RPATH_TRUE@am__append_1 = -Wc,-nodefaultrpaths \ @ENABLE_DARWIN_AT_RPATH_TRUE@ -Wl,-rpath,@loader_path +@ENABLE_A68_POSIX_PRELUDE_TRUE@am__append_2 = ga68-posix.c +@ENABLE_A68_POSIX_PRELUDE_TRUE@am__append_3 = posix.lo +@ENABLE_A68_POSIX_PRELUDE_TRUE@am__append_4 = posix.lo subdir = . ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 am__aclocal_m4_deps = $(top_srcdir)/../config/acx.m4 \ @@ -170,10 +173,12 @@ am__installdirs = "$(DESTDIR)$(toolexeclibdir)" \ "$(DESTDIR)$(toolexeclibdir)" LTLIBRARIES = $(toolexeclib_LTLIBRARIES) am__DEPENDENCIES_1 = +@ENABLE_A68_POSIX_PRELUDE_TRUE@am__objects_1 = \ +@ENABLE_A68_POSIX_PRELUDE_TRUE@ libga68_la-ga68-posix.lo am_libga68_la_OBJECTS = libga68_la-libga68.lo \ - libga68_la-ga68-unistr.lo libga68_la-ga68-posix.lo \ - libga68_la-ga68-alloc.lo libga68_la-ga68-error.lo \ - libga68_la-ga68-standenv.lo + libga68_la-ga68-unistr.lo libga68_la-ga68-alloc.lo \ + libga68_la-ga68-error.lo libga68_la-ga68-standenv.lo \ + $(am__objects_1) libga68_la_OBJECTS = $(am_libga68_la_OBJECTS) AM_V_lt = $(am__v_lt_@AM_V@) am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) @@ -462,21 +467,17 @@ FLAGS_TO_PASS = $(AM_MAKEFLAGS) gcc_objdir = $(MULTIBUILDTOP)../../$(host_subdir)/gcc toolexeclib_DATA = libga68.spec toolexeclib_LTLIBRARIES = libga68.la -libga68_la_SOURCES = libga68.c \ - ga68-unistr.c \ - ga68-posix.c \ - ga68-alloc.c \ - ga68-error.c \ - ga68-standenv.c \ - ga68.h - +libga68_la_SOURCES = libga68.c ga68-unistr.c ga68-alloc.c ga68-error.c \ + ga68-standenv.c ga68.h $(am__append_2) libga68_la_LIBTOOLFLAGS = libga68_la_CFLAGS = $(LIBGA68_GCFLAGS) $(LIBGA68_BOEHM_GC_INCLUDES) libga68_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \ $(version_arg) $(lt_host_flags) $(extra_darwin_ldflags_libga68) -libga68_la_DEPENDENCIES = libga68.spec $(version_dep) standard.lo posix.lo -libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS) standard.lo posix.lo +libga68_la_DEPENDENCIES = libga68.spec $(version_dep) standard.lo \ + $(am__append_3) +libga68_la_LIBADD = $(LIBGA68_BOEHM_GC_LIBS) standard.lo \ + $(am__append_4) # Rules to build the Algol 68 code in the library. LTA68COMPILE = $(LIBTOOL) --tag=A68 $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ @@ -632,13 +633,6 @@ libga68_la-ga68-unistr.lo: ga68-unistr.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libga68_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libga68_la_CFLAGS) $(CFLAGS) -c -o libga68_la-ga68-unistr.lo `test -f 'ga68-unistr.c' || echo '$(srcdir)/'`ga68-unistr.c -libga68_la-ga68-posix.lo: ga68-posix.c -@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libga68_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libga68_la_CFLAGS) $(CFLAGS) -MT libga68_la-ga68-posix.lo -MD -MP -MF $(DEPDIR)/libga68_la-ga68-posix.Tpo -c -o libga68_la-ga68-posix.lo `test -f 'ga68-posix.c' || echo '$(srcdir)/'`ga68-posix.c -@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libga68_la-ga68-posix.Tpo $(DEPDIR)/libga68_la-ga68-posix.Plo -@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ga68-posix.c' object='libga68_la-ga68-posix.lo' libtool=yes @AMDEPBACKSLASH@ -@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libga68_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libga68_la_CFLAGS) $(CFLAGS) -c -o libga68_la-ga68-posix.lo `test -f 'ga68-posix.c' || echo '$(srcdir)/'`ga68-posix.c - libga68_la-ga68-alloc.lo: ga68-alloc.c @am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libga68_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libga68_la_CFLAGS) $(CFLAGS) -MT libga68_la-ga68-alloc.lo -MD -MP -MF $(DEPDIR)/libga68_la-ga68-alloc.Tpo -c -o libga68_la-ga68-alloc.lo `test -f 'ga68-alloc.c' || echo '$(srcdir)/'`ga68-alloc.c @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libga68_la-ga68-alloc.Tpo $(DEPDIR)/libga68_la-ga68-alloc.Plo @@ -660,6 +654,13 @@ libga68_la-ga68-standenv.lo: ga68-standenv.c @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libga68_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libga68_la_CFLAGS) $(CFLAGS) -c -o libga68_la-ga68-standenv.lo `test -f 'ga68-standenv.c' || echo '$(srcdir)/'`ga68-standenv.c +libga68_la-ga68-posix.lo: ga68-posix.c +@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libga68_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libga68_la_CFLAGS) $(CFLAGS) -MT libga68_la-ga68-posix.lo -MD -MP -MF $(DEPDIR)/libga68_la-ga68-posix.Tpo -c -o libga68_la-ga68-posix.lo `test -f 'ga68-posix.c' || echo '$(srcdir)/'`ga68-posix.c +@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libga68_la-ga68-posix.Tpo $(DEPDIR)/libga68_la-ga68-posix.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='ga68-posix.c' object='libga68_la-ga68-posix.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(libga68_la_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libga68_la_CFLAGS) $(CFLAGS) -c -o libga68_la-ga68-posix.lo `test -f 'ga68-posix.c' || echo '$(srcdir)/'`ga68-posix.c + mostlyclean-libtool: -rm -f *.lo diff --git a/libga68/config.h.in b/libga68/config.h.in index 1ba191b9772..16a0f730d2e 100644 --- a/libga68/config.h.in +++ b/libga68/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* Define if inclusion of POSIX prelude is expected */ +#undef ENABLE_A68_POSIX_PRELUDE + /* Define to 1 if the target supports __attribute__((visibility(...))). */ #undef HAVE_ATTRIBUTE_VISIBILITY diff --git a/libga68/configure b/libga68/configure index 01dc61e2d59..8e513e9efb1 100755 --- a/libga68/configure +++ b/libga68/configure @@ -638,6 +638,8 @@ LIBGA68_BOEHM_GC_LIBS LIBGA68_BOEHM_GC_INCLUDES LIBGA68_GCFLAGS extra_darwin_ldflags_libga68 +ENABLE_A68_POSIX_PRELUDE_FALSE +ENABLE_A68_POSIX_PRELUDE_TRUE LIBGA68_USE_SYMVER_SUN_FALSE LIBGA68_USE_SYMVER_SUN_TRUE LIBGA68_USE_SYMVER_GNU_FALSE @@ -807,6 +809,7 @@ enable_libtool_lock enable_darwin_at_rpath with_gcc_major_version_only enable_symvers +enable_algol68_posix_prelude enable_algol68_gc with_target_bdw_gc with_target_bdw_gc_include @@ -1462,6 +1465,9 @@ Optional Features: install libraries with @rpath/library-name, requires rpaths to be added to executables --disable-symvers disable symbol versioning for libga68 + --enable-algol68-posix-prelude + enable inclusion of POSIX prelude as part of GNU + Algol 68 runtime --enable-algol68-gc enable use of Boehm's garbage collector with the GNU Algol runtime --enable-algol68-gc-debug @@ -12833,7 +12839,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12836 "configure" +#line 12842 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -12939,7 +12945,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 12942 "configure" +#line 12948 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -13260,126 +13266,6 @@ $as_echo "#define HAVE_ATTRIBUTE_VISIBILITY 1" >>confdefs.h fi -# Search for needed functions in host libraries. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing malloc" >&5 -$as_echo_n "checking for library containing malloc... " >&6; } -if ${ac_cv_search_malloc+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char malloc (); -int -main () -{ -return malloc (); - ; - return 0; -} -_ACEOF -for ac_lib in '' c; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if test x$gcc_no_link = xyes; then - as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 -fi -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_malloc=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_malloc+:} false; then : - break -fi -done -if ${ac_cv_search_malloc+:} false; then : - -else - ac_cv_search_malloc=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_malloc" >&5 -$as_echo "$ac_cv_search_malloc" >&6; } -ac_res=$ac_cv_search_malloc -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing cosf" >&5 -$as_echo_n "checking for library containing cosf... " >&6; } -if ${ac_cv_search_cosf+:} false; then : - $as_echo_n "(cached) " >&6 -else - ac_func_search_save_LIBS=$LIBS -cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char cosf (); -int -main () -{ -return cosf (); - ; - return 0; -} -_ACEOF -for ac_lib in '' m; do - if test -z "$ac_lib"; then - ac_res="none required" - else - ac_res=-l$ac_lib - LIBS="-l$ac_lib $ac_func_search_save_LIBS" - fi - if test x$gcc_no_link = xyes; then - as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5 -fi -if ac_fn_c_try_link "$LINENO"; then : - ac_cv_search_cosf=$ac_res -fi -rm -f core conftest.err conftest.$ac_objext \ - conftest$ac_exeext - if ${ac_cv_search_cosf+:} false; then : - break -fi -done -if ${ac_cv_search_cosf+:} false; then : - -else - ac_cv_search_cosf=no -fi -rm conftest.$ac_ext -LIBS=$ac_func_search_save_LIBS -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_cosf" >&5 -$as_echo "$ac_cv_search_cosf" >&6; } -ac_res=$ac_cv_search_cosf -if test "$ac_res" != no; then : - test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - -fi - - # Determine what GCC version number to use in filesystem paths. get_gcc_base_ver="cat" @@ -13508,6 +13394,38 @@ else fi +# Check whether --enable-algol68-posix-prelude was given. +if test "${enable_algol68_posix_prelude+set}" = set; then : + enableval=$enable_algol68_posix_prelude; case "$enableval" in + yes) enable_algol68_posix_prelude=yes ;; + no) enable_algol68_posix_prelude=no;; + *) as_fn_error $? "bad value $enableval for --enable-algol68-posix-prelude" "$LINENO" 5 ;; +esac +else + enable_algol68_posix_prelude=default +fi + + +if test "x$enable_algol68_posix_prelude" = xdefault; then + unset LIBGA68_POSIXPRED_SUPPORTED + . "${srcdir}/configure.tgt" + enable_algol68_posix_prelude=$LIBGA68_POSIXPRED_SUPPORTED +fi + + if test "x$enable_algol68_posix_prelude" = xyes; then + ENABLE_A68_POSIX_PRELUDE_TRUE= + ENABLE_A68_POSIX_PRELUDE_FALSE='#' +else + ENABLE_A68_POSIX_PRELUDE_TRUE='#' + ENABLE_A68_POSIX_PRELUDE_FALSE= +fi + +if test "x$enable_algol68_posix_prelude" = xyes; then + +$as_echo "#define ENABLE_A68_POSIX_PRELUDE 1" >>confdefs.h + +fi + # The Boehm GC # Check whether --enable-algol68-gc was given. @@ -13913,6 +13831,10 @@ if test -z "${LIBGA68_USE_SYMVER_SUN_TRUE}" && test -z "${LIBGA68_USE_SYMVER_SUN as_fn_error $? "conditional \"LIBGA68_USE_SYMVER_SUN\" was never defined. Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi +if test -z "${ENABLE_A68_POSIX_PRELUDE_TRUE}" && test -z "${ENABLE_A68_POSIX_PRELUDE_FALSE}"; then + as_fn_error $? "conditional \"ENABLE_A68_POSIX_PRELUDE\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 +fi : "${CONFIG_STATUS=./config.status}" ac_write_fail=0 diff --git a/libga68/configure.ac b/libga68/configure.ac index 96b23f4a89b..118debb6f8e 100644 --- a/libga68/configure.ac +++ b/libga68/configure.ac @@ -173,10 +173,6 @@ AC_SUBST(CC_FOR_BUILD) # Check whether the target supports hidden visibility. LIBGA68_CHECK_ATTRIBUTE_VISIBILITY -# Search for needed functions in host libraries. -AC_SEARCH_LIBS([malloc], [c]) -AC_SEARCH_LIBS([cosf], [m]) - # Determine what GCC version number to use in filesystem paths. GCC_BASE_VER @@ -230,6 +226,29 @@ AM_CONDITIONAL(LIBGA68_USE_SYMVER, [test "x$ga68_use_symver" != xno]) AM_CONDITIONAL(LIBGA68_USE_SYMVER_GNU, [test "x$ga68_use_symver" = xgnu]) AM_CONDITIONAL(LIBGA68_USE_SYMVER_SUN, [test "x$ga68_use_symver" = xsun]) +AC_ARG_ENABLE(algol68-posix-prelude, +[AS_HELP_STRING([--enable-algol68-posix-prelude], + [enable inclusion of POSIX prelude as part of GNU Algol 68 + 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=default]) + +if test "x$enable_algol68_posix_prelude" = xdefault; then + unset LIBGA68_POSIXPRED_SUPPORTED + . "${srcdir}/configure.tgt" + enable_algol68_posix_prelude=$LIBGA68_POSIXPRED_SUPPORTED +fi + +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, diff --git a/libga68/configure.tgt b/libga68/configure.tgt new file mode 100644 index 00000000000..70d3324d9af --- /dev/null +++ b/libga68/configure.tgt @@ -0,0 +1,35 @@ +# -*- shell-script -*- +# Copyright (C) 2025 Free Software Foundation, Inc. +# +# GCC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3, or (at your option) +# any later version. +# +# GCC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# <http://www.gnu.org/licenses/>. + +# This is the target specific configuration file. This is invoked by the +# autoconf generated configure script. Putting it in a separate shell file +# lets us skip running autoconf when modifying target specific information. + +# Enable Algol68 POSIX prelude only on supported systems. +# You can override this with --enable-algol68-posix-prelude. +# Please keep this in-sync with "dg-require-posix" procedure in +# gcc/testsuite/lib/algol68-dg.exp. +LIBGA68_POSIXPRED_SUPPORTED=no +case "${target}" in +*-*-linux* | *-*-gnu* | *-*-k*bsd*-gnu | *-*-kopensolaris*-gnu | \ +*-*-netbsd* | *-*-freebsd* | *-*-openbsd* | *-*-dragonfly* | \ +*-*-solaris2* | *-*-hpux11* | *-*-darwin* | *-*-aix*) + LIBGA68_POSIXPRED_SUPPORTED=yes + ;; +*) + ;; +esac -- 2.53.0
