This big commit:
* Adds support to the FFI mechanism to map Algol 68 procedures
returning strings to an equivalent C interface.
* Adds a new command-line option -fbuilding-libga68.
* Adds support for having modules in libga68 implicitly invoked in
user-written programs and modules.
* Using the infrastructure agove, removes the compiler-generated glue
to call the standard POSIX prelude shipped in libga68 to, instead, use
the formal holes mechanism for FFI.
* Adds posix.a68 to libga68.
* Adds standard.a68 to libga68.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
* a68-moids-misc.cc (a68_is_c_mode): Allow C formal holes for
routines yielding strings.
* a68-low-holes.cc (a68_wrap_formal_proc_hole): Support wrappers
that yield strings.
* a68.h: Remove a68_posix_* and a68_lower_posix* prototypes.
* a68-low-posix.cc: Remove.
* a68-imports.cc (a68_open_packet): Get argument filename.
* Make-lang.in (ALGOL68_OBJS): Remove algol68/a68-low-posix.o.
* a68-low-runtime.def: Remove POSIX_*.
* lang.opt (-fcheck): Add new undocumented option -fbuilding-libga68.
* a68-parser-prelude.cc (stand_transput): New function.
(posix_prelude): Remove hardcoded additions to the top-level
environment and use a68_extract_revelations instead.
* a68-parser-extract.cc (a68_extract_revelation): Renamed from
extract_revelation and made accessible externally.
* a68-low.cc (a68_make_formal_hole_decl): Remove unneeded check.
(lower_lude_decl): New function.
(lower_module_text): Add calls to preludes and postludes of
standard modules if not building libga68.
(a68_lower_particular_program): Likewise.
* a68-low-prelude.cc (a68_lower_posixargc): Remove.
(a68_lower_posixargv): Likewise.
(a68_lower_posixgetenv): Likewise.
(a68_lower_posixputchar): Likewise.
(a68_lower_posixputs): Likewise.
(a68_lower_posixfconnect): Likewise.
(a68_lower_posixfopen): Likewise.
(a68_lower_posixfcreate): Likewise.
(a68_lower_posixfclose): Likewise.
(a68_lower_posixfsize): Likewise.
(a68_lower_posixlseek): Likewise.
(a68_lower_posixseekcur): Likewise.
(a68_lower_posixseekend): Likewise.
(a68_lower_posixseekset): Likewise.
(a68_lower_posixstdinfiledes): Likewise.
(a68_lower_posixstdoutfiledes): Likewise.
(a68_lower_posixstderrfiledes): Likewise.
(a68_lower_posixfileodefault): Likewise.
(a68_lower_posixfileordwr): Likewise.
(a68_lower_posixfileordonly): Likewise.
(a68_lower_posixfileowronly): Likewise.
(a68_lower_posixfileotrunc): Likewise.
(a68_lower_posixerrno): Likewise.
(a68_lower_posixexit): Likewise.
(a68_lower_posixperror): Likewise.
(a68_lower_posixstrerror): Likewise.
(a68_lower_posixfputc): Likewise.
(a68_lower_posixfputs): Likewise.
(a68_lower_posixgetchar): Likewise.
(a68_lower_posixfgetc): Likewise.
(a68_lower_posixgets): Likewise.
(a68_lower_posixfgets): Likewise.
gcc/testsuite/ChangeLog
* lib/algol68.exp (algol68_init): Add -I options to
ALGOL68_UNDER_TEST so exports in libga68.{a,so} are found.
* algol68/compile/warning-hidding-6.a68: Likewise.
* algol68/compile/warning-hidding-5.a68: Use maxint instead of
getchar to trigger the warning.
* algol68/compile/error-nest-4.a68: Procedures yielding strings
are now on in C formal holes.
libga68/ChangeLog
* posix.a68: New file.
* standard.a68.in: Likewise.
* ga68-posix.c (_libga68_stdin): Define.
(_libga68_stdout): Likewise.
(_libga68_stderr): Likewise.
(_libga68_file_o_default): Likewise.
(_libga68_file_o_rdonly): Likewise.
(_libga68_file_o_rdwr): Likewise.
(_libga68_file_o_trunc): Likewise.
(_libga68_seek_cur): Likewise.
(_libga68_seek_end): Likewise.
(_libga68_seek_set): Likewise.
(_libga68_posixstrerror): Update interface to new way of returning
Algol 68 strings.
(_libga68_posixargv): Likewise.
(_libga68_posixfgets): Likewise.
(_libga68_posixgets): Likewise.
(_libga68_posixfopen): Use _libga68_file_o_default rather than FILE_O_DEFAULT.
(_libga68_posixfopen): Ditto for other FILE_O_* values.
* ga68.h: Update prototypes.
* Makefile.am (libga68_la_LIBADD): Add standard.lo.
(libga68_la_DEPENDENCIES): Likeise.
(.a68.o): Pass -fbuilding-libga68.
(.a68.lo): Likewise.
(standard.a68): New rule.
* Makefile.in: Regenerate.
* transput.a68.in: Add Emacs -*- mode: a68 -*- comment.
_libga68_u32_to_u8 called free on the result buffer on error, but the
buffer is allocated by the GC, so calling free on it is incorrect.
Instead of using the GC, use the internal malloc because this is an
internal function.
Remove the resultbuf parameter from the _libga68_u32_to_u8 since all
callers used NULL for it.
Last but not least, return a null-terminated char* from
_libga68_u32_to_u8.
libga68/ChangeLog:
* ga68-alloc.c (_libga68_realloc_internal): New function.
* ga68-posix.c (_libga68_posixperror): Adjust calls to _libga68_u32_to_u8.
(_libga68_posixfopen): Likewise.
(_libga68_posixcreat): Likewise.
(_libga68_posixgetenv): Likewise.
(_libga68_posixfputs): Likewise.
(_libga68_posixfconnect): Likewise.
* ga68-unistr.c (_libga68_u32_to_u8): Use internal allocator.
* ga68.h (_libga68_realloc_internal): New prototype.
(_libga68_u32_to_u8): Update prototype.
Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
gcc/algol68/ChangeLog
PR algol68/123733
* README: Mention minimum version of libgc.
libga68/ChangeLog
PR algol68/123733
* configure.ac: Check for GC_is_init_called in libgc.
* configure: Regenerate.
Boehm GC has a malloc_atomic function that doesn't clear the new
allocation and doesn't scan it for pointers.
Add a wrapper for the GC malloc_atomic in the run-time library and use it to
allocate GC-collectable strings in the library.
Change the lowering of malloc on the front end to select the run-time GC malloc
function to be used based on the mode having pointers or not. Use leaf
allocations for modes that are not refs or that don't contain refs.
A boolean `has_refs' member was added to MOID_T and the computation of the
atrribute is done by the parser when generating the mode list.
gcc/algol68/ChangeLog:
* a68-low-clauses.cc (a68_lower_collateral_clause): Update
call to a68_lower_alloca.
* a68-low-coercions.cc (a68_lower_widening): Likewise.
* a68-low-generator.cc (allocator_t): Adjust typedef.
(fill_in_buffer): Adjust call to allocator.
(gen_mode): Likewise.
* a68-low-multiples.cc (a68_row_malloc): Change type parameter to MOID_T
from tree. Adjust call to a68_lower_malloc.
* a68-low-posix.cc (a68_posix_fgets): Adjust call to a68_row_malloc.
(a68_posix_gets): Likewise.
* a68-low-runtime.def (MALLOC_LEAF): Add definition for
_libga68_malloc_leaf.
* a68-low-strings.cc (a68_string_concat): Adjust call to
a68_lower_malloc.
(a68_string_from_char): Likewise.
* a68-low-units.cc (a68_lower_slice): Likewise.
* a68-low.cc (a68_low_dup): Adjust calls to a68_lower_malloc
and a68_lower_alloca.
(a68_lower_alloca): Change type parameter to MOID_T from tree.
(a68_lower_malloc): Likewise. Use _libga68_malloc_leaf if the MOID_T
doesn't have refs, use _libga68_malloc otherwise.
* a68-parser-modes.cc (a68_create_mode): Set has_refs on the new mode.
(is_mode_has_refs): New function.
(compute_derived_modes): Set has_refs on the chain of modes.
* a68-parser.cc (a68_new_moid): Set has_refs to false by
default.
* a68-types.h (struct MOID_T): Add member `has_refs`.
(HAS_REFS): New macro.
* a68.h (a68_row_malloc): Update prototype.
(a68_lower_alloca): Likewise.
(a68_lower_malloc): Likewise.
libga68/ChangeLog:
* ga68-alloc.c (_libga68_malloc_leaf): New function.
* ga68-posix.c (_libga68_posixfgets): Use _libga68_malloc_leaf
instead of _libga68_malloc.
* ga68-unistr.c (_libga68_u32_to_u8): Likewise.
(_libga68_u8_to_u32): Likewise.
* ga68.h (_libga68_malloc_leaf): New prototype.
* ga68.map: Add _libga68_malloc_leaf to the global map.
Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
If GC_DEBUG is defined then all-upper-case macros will expand to calls
to the debug variant of collector functions.
So add the configury bit to define GC_DEBUG if the user wants and
switch all `GC_` calls to the corresponding macros.
libga68/ChangeLog:
* configure: Regenerate.
* configure.ac: Add --enable-algol68-gc-debug option and
define GC_DEBUG accordingly.
* ga68-alloc.c (_libga68_realloc): Use the C macro version of
the GC function.
(_libga68_realloc_unchecked): Likewise.
(_libga68_malloc): Likewise.
Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
The macOS awk seems to not like having an unparenthesized conditional
expression as the last argument to printf. This commit workarounds
this by simply replacing the conditional expression with a conditional
statement.
Tested with gawk and mawk.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
libga68/ChangeLog
* sppp.awk: Avoid conditional expression.
Happy new year!
Turns out the optional third argument of 'match' is a GNU extension
and is not POSIX. Also, POSIX doens't recognize interval expressions
in regexps.
This patch vandalizes sppp.awk to remove the use of these nonportable
(but nice) constructs.
Tested with mawk.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
libga68/ChangeLog
* sppp.awk: Fix non-portable uses of 'match'.
Most of the standard prelude is implemented in a combination of code
lowered by the front-end (standard operators, contants, etc) and
functions provided by the libga68 run-time library, to which the
former libcalls. Until now, all the support routines in libga68 were
written in C. However, many of the transput facilities are better
implemented in Algol 68.
The Revised Report includes a reference implementation (code listing)
of many of the standard routines. This implementation, however, makes
use of an "extended" program notation in order to denote certain
notions to avoid repetitive code. Therefore this commit includes
sppp, a build-time pre-processor written in awk that is only intended
to be used internally by the libga68 run-time library. This
preprocessor allows us to write code like:
proc subwhole = (Number v, int width) string:
case v in
{iter L {short short} {short} {} {long} {long long}}
{iter S {LENG LENG} {LENG} {} {SHORTEN} {SHORTEN SHORTEN}}
({L} int x):
begin string s, {L} int n := x;
while dig_char ({S} (n MOD {L} 10)) +=: s;
n %:= {L} 10; n /= {L} 0
do ~ od;
(UPB s > width | width * errorchar | s)
end
{reti {,}}
esac;
Resulting in cases for short short int, short int, int, long int and
long long int being macro-expanded in the routine's conformance
clause.
This commit also adds the necessary infrastructure for writing Algol
68 code in the libga68 library, including the ability of having
modules exported by libga68. An implementation of some of the
transput routines is also provided in standard.a68: whole, fixed,
float, string_to_L_real, char_in_string, L_int_width, L_real_width and
L_exp_with.
The build system changes include the backport of the Automake Algol 68
support, which is in a released version of Automake but not in the
version used for GCC, to libga68/m4/autoconf.m4.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>
ChangeLog
* Makefile.def (flags_to_pass): Rename GA68, GA68FLAGS,
GA68_FOR_TARGET, GA68FLAGS_FOR_TARGET to A68, A68FLAGS,
A68_FOR_TARGET and A68FLAGS_FOR_TARGET.
* Makefile.tpl: Use A68, A68FLAGS, A68_FOR_BUILD and
A68_FOR_TARGET rather than GA68, GA68FLAGS, GA68_FOR_BUILD and
GA68_FOR_TARGET.
* Makefile.in: Regenerate.
* configure.ac: Set A68_FOR_BUILD rather than GA68_FOR_BUILD, and
invoke ACX_PROG_A68 rather than ACX_PROG_GA68.
Subst A68_FOR_BUILD rather than GA68_FOR_BUILD.
Subst A68 and A68FLAGS rather than GA68 and GA68FLAGS.
Set A68_FOR_TARGET rather than GA68_FOR_TARGET.
* configure: Regenerate.
* config-ml.in: Handle A68FLAGS and define A68 in sub-configures.
config/ChangeLog
* acx.m4: Define ACX_PROG_A68 rather than ACX_PROG_GA68.
(ACX_PROG_A68): Set A68 rather than GA68.
gcc/algol68/ChangeLog
* a68-lang.cc (a68_init_options): Add an entry to A68_MODULE_FILES
to map module Transput to the basename ga68.
gcc/testsuite/ChangeLog
* algol68/execute/char-in-string-1.a68: New test.
libga68/ChangeLog
* m4/autoconf.m4: New file.
* configure.ac: Expand AC_PROG_A68.
* configure: Regenerate.
* Makefile.am: Add rules to build Algol 68 sources and to
build the transput module.
* Makefile.in: Regenerate.
* acinclude.m4: Include m4/autoconf.m4.
* sppp.awk: New file.
* transput.a68.in: Likewise.
libga68/ChangeLog:
* configure.ac: New test to determine if symbol versioning is
supported.
* Makefile.am: Use result of above test to add appropriate linker
flags.
* Makefile.in: Regenerated.
* aclocal.m4: Likewise.
* configure: Likewise.
* ga68.map: New file.
* libtool-version: New file.
Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
GNU ld gained separate Solaris-specific linker emulations (*_sol2) long
ago. Since their introduction, GCC has preferred them over their
non-*_sol2 counterparts but supported both forms. This has changed for
GCC 16: since all supported versions of GNU ld do support the *_sol2
emulations, GCC now uses them unconditionally.
libtool has also been updated to handle this since libtool 2.4.2 back in
2011. However, that change has only partially been backported to the
heavily patched libtool.m4 in the GCC tree: the sparcv9 part is there,
but the amd64 part is missing for some reason. This causes problems
with some recent binutils changes.
Therefore this patch cherry-picks the libtool patch to bring
Solaris/x86_64 in sync with Solaris/sparcv9 and upstream libtool.
Bootstrapped without regressions on {amd64,i386}-pc-solaris2.11 and
{sparcv9,sparc}-sun-solaris2.11.
2025-09-22 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* libtool.m4: Cherry-pick libtool commit
9196966580f6853a31187a7a3c7e7ff36ef08982.
gcc:
* configure: Regenerate.
libatomic:
* configure: Regenerate.
libbacktrace:
* configure: Regenerate.
libcc1:
* configure: Regenerate.
libffi:
* configure: Regenerate.
libga68:
* configure: Regenerate.
libgcobol:
* configure: Regenerate.
libgfortran:
* configure: Regenerate.
libgm2:
* configure: Regenerate.
libgomp:
* configure: Regenerate.
libgrust:
* configure: Regenerate.
libitm:
* configure: Regenerate.
libobjc:
* configure: Regenerate.
libphobos:
* configure: Regenerate.
libquadmath:
* configure: Regenerate.
libsanitizer:
* configure: Regenerate.
libssp:
* configure: Regenerate.
libstdc++-v3:
* configure: Regenerate.
libvtv:
* configure: Regenerate.
lto-plugin:
* configure: Regenerate.
zlib:
* configure: Regenerate.
Make sure all declarations added by autoconf are seen by system
headers.
libga68/ChangeLog:
* ga68-alloc.c: Include ga68.h before all includes.
* ga68-error.c: Likewise.
* ga68-standenv.c: Likewise.
* ga68-unistr.c: Likewise.
Signed-off-by: Pietro Monteiro <pietro@sociotechnical.xyz>
_libga68_u32_cmp is only used in the same translation unit, so make it
static.
libga68/ChangeLog:
* ga68-unistr.c (_libga68_u32_cmp): Add `static' specifier.
* ga68.h (_libga68_u32_cmp): Remove prototype.
This commit creates initial gcc/algol68/ChangeLog and
libga68/ChangeLog files with copyright notices and content moved from
the top-level ChangeLog and gcc/ChangeLog.
Signed-off-by: Jose E. Marchesi <jemarch@gnu.org>