I think there should be consistency in what we use, so like
libgcobol-fp.h specifies, IEEE quad long double should have highest
priority, then _Float128 with *f128 APIs, then libquadmath.
And when we decide to use say long double, we shouldn't mix that with
strfromf128/strtof128.
Additionally, given that the *l vs. *f128 vs. *q API decision is done
solely in libgcobol and not in the compiler (which is different from
the Fortran case where compiled code emits say sinq or sinf128 calls),
I think libgcobol.spec should only have -lquadmath in any form only in
the case when using libquadmath for everything. In the Fortran case
it is for backwards compatibility purposes, if something has been
compiled with older gfortran which used say sinq and link is done by
gfortran which has been configured against new glibc with *f128, linking
would fail otherwise.
2025-04-15 Jakub Jelinek <jakub@redhat.com>
Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR cobol/119244
* acinclude.m4 (LIBGCOBOL_CHECK_FLOAT128): Ensure
libgcob_cv_have_float128 is not yes on targets with IEEE quad
long double. Don't check for --as-needed nor set LIBQUADSPEC
on targets which USE_IEC_60559.
* libgcobol-fp.h (FP128_FMT, strtofp128, strfromfp128): Define.
* intrinsic.cc (strtof128): Don't redefine.
(WEIRD_TRANSCENDENT_RETURN_VALUE): Use GCOB_FP128_LITERAL macro.
(__gg__numval_f): Use strtofp128 instead of strtof128.
* libgcobol.cc (strtof128): Don't redefine.
(format_for_display_internal): Use strfromfp128 instead of
strfromf128 or quadmath_snprintf and use FP128_FMT in the format
string.
(get_float128, __gg__compare_2, __gg__move, __gg__move_literala):
Use strtofp128 instead of strtof128.
* configure: Regenerate.
valconf.cc doesn't compile on Solaris:
cobol/valconv.cc: In function ‘bool __gg__string_to_numeric_edited(char*, char*, int, int, const char*)’:
cobol/valconv.cc:856:40: error: ‘index’ was not declared in this scope; did you mean ‘Rindex’?
856 | const char *decimal_location = index(dest, __gg__decimal_point); | ^~~~~
| Rindex
On Solaris, it's only declared in <strings.h>. While one could get that
included, it's way easier to just use strchr as is already the case in
other instances.
Bootstrapped without regressions on amd64-pc-solaris2.11,
sparcv9-sun-solaris2.11, and x86_64-pc-linux-gnu.
2025-04-08 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
libgcobol:
* valconv.cc (__gg__string_to_numeric_edited): Use strchr instead
of index.
Now that we have libquadmath support, we can enable for x86_64, at
least.
libgcobol/ChangeLog:
* configure.tgt: Enable for x86_64 Darwin.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Many of the changes are mechanical:
1. 'GCOB_FP128' in place of _Float128.
2. Using FP128_FUNC to represent the spelling of intrinsics.
3. Using GCOB_FP128_LITERAL() to choose the suffix for literals.
This allows for:
__float128 and 'q' as the suffix when libquadmath is configured.
_Float128 / 'f128' when IEC-60559 is available in libc
long double / 'l' when long double is ieee753 128b.
Add libquadmath to libgcobol.spec and its dependencies where the
platform needs it.
PR cobol/119244
libgcobol/ChangeLog:
* Makefile.am: Add support for libquadmath.
* Makefile.in: Regenerate.
* acinclude.m4: Add support for libquadmath.
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Configure libquadmath support.
* gmath.cc: Use GCOB_FP128 to represent the configured
128b floating point type. Use FP128_FUNC to represent
the naming of intrinsics in the configure 128b floating
point type. Render literals with GCOB_FP128_LITERAL.
* intrinsic.cc: Likewise.
* libgcobol.cc: Likewise.
* libgcobol.h: Likewise.
* libgcobol-fp.h: New file.
* gfileio.cc: Include libgcobol-fp.h.
* libgcobol.spec.in: Add libquadmath configure output.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
gcc/cobol
PR cobol/119682
* genapi.cc: (cobol_compare): Change the call to __gg__compare().
libgcobol
PR cobol/119682
* common-defs.h: Define the REFER_T_REFMOD constant.
* intrinsic.cc: (__gg__max): Change the calls to __gg__compare_2(),
(__gg__min): Likewise, (__gg__ord_min): Likewise,
(__gg__ord_max): Likewise.
* libgcobol.cc: (__gg__compare_2): Change definition of calling
parameters, eliminate separate flag bit for ALL and ADDRESS_OF,
change comparison of alphanumeric to numeric when the numeric
is a refmod.
* libgcobol.h: Change declaration of __gg__compare_2.
Ads support for using a library spec file (e.g. to include the
target requirements for non-standard libraries - or even libm
which we can now configure at the target side).
gcc/cobol/ChangeLog:
* gcobolspec.cc (SPEC_FILE): New.
(lang_specific_driver): Make the 'need libgcobol' flag global
so that the prelink callback can use it. Libm use is now handled
via the library spec.
(lang_specific_pre_link): Include libgcobol.spec where needed.
libgcobol/ChangeLog:
* Makefile.am: Add libgcobol.spec and dependency.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Add libgcobol.spec handling.
* libgcobol.spec.in: New file.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Currently, the library is configured as if it was written in C, however
all the sources are C++, so update to use C++ as the configure language
(and check the CXX instead of CC).
Reorder the configuration steps so that we setup the tools and environment
before carrying out tests.
Remove unused configuration machinery.
Also we configured extra ld flags but never used them. There is no need
to make these extra_ldflags darwin-specific, additions could be required
by other hosts.
libgcobol/ChangeLog:
* aclocal.m4: Regenerate.
* config.h.in: Regenerate.
* Makefile.am: Use the configured LIBS and extra_ldflags.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Shift configure to use c++. Order tests for tools
and environment before other tests.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Use the libtool config check and $(LIBM).
libgcobol/ChangeLog:
* Makefile.am: Use $(LIBM) to add the math lib when
it is needed.
* Makefile.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check if the target wants libm.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
Testcases compiled with -Os were failing because static functions and static
variables were being optimized away, because of improper data type casts, and
because strict aliasing (whatever that is) was resulting in some loss of data.
These changes eliminate those known problems.
gcc/cobol
* cobol1.cc: (cobol_langhook_post_options): Implemented in order to set
flag_strict_aliasing to zero.
* genapi.cc: (set_user_status): Add comment.
(parser_intrinsic_subst): Expand SHOW_PARSE information.
(psa_global): Change names of return-code and upsi globals,
(psa_FldLiteralA): Set DECL_PRESERVE_P for FldLiteralA.
* gengen.cc: (show_type): Add POINTER type.
(gg_define_function_with_no_parameters): Set DECL_PRESERVE_P for COBOL-
style nested programs. (gg_array_of_bytes): Fix bad cast.
libgcobol
* charmaps.h: Change __gg__data_return_code to 'short' type.
* constants.cc: Likewise.
strfrom{f,d,l,fN) are all C23 and might not be available in general.
This uses snprintf() to provide fall-backs where the libc does not
yet have support.
libgcobol/ChangeLog:
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Check for availability of strfromf32 and
strfromf64.
* libgcobol.cc (strfromf32, strfromf64): New.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
We do not have a replacement at the moment, so fall back to using
regular random and friends.
PR cobol/119295
libgcobol/ChangeLog:
* config.h.in: Regenerate.
* configure: Regenerate.
* configure.ac: Configure random_r and friends
* intrinsic.cc (__gg__random): Use random_r when available.
(__gg__random_next): Likewise.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
This includes config.h before any other project-related headers
or sources so that they properly make use of the values determined
by configure.
libgcobol/ChangeLog:
* gfileio.cc: Include config.h.
* gmath.cc: Likewise.
* io.cc: Likewise.
* libgcobol.cc: Likewise.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
COBOL variables with attribute intermediate_e are being allocated on
the stack frame, but their data was assigned using malloc(), without
a corresponding call to free(). For numerics, the problem is solved
with a fixed allocation of sixteen bytes for the cblc_field_t::data
member (sixteen is big enough for all data types) and with a fixed
allocation of 8,192 bytes for the alphanumeric type.
In use, the intermediate numeric data types are "shrunk" to the minimum
applicable size. The intermediate alphanumerics, generally used as
destination targets for functions, are trimmed as well.
gcc/cobol
PR cobol/119521
* genapi.cc: (parser_division): Change comment.
(parser_symbol_add): Change intermediate_t handling.
* parse.y: Multiple changes to new_alphanumeric() calls.
* parse_ante.h: Establish named constant for date function
calls. Change declaration of new_alphanumeric() function.
* symbols.cc: (new_temporary_impl): Use named constant
for default size of temporary alphanumerics.
* symbols.h: Establish MAXIMUM_ALPHA_LENGTH constant.
libgcobol
PR cobol/119521
* intrinsic.cc: (__gg__reverse): Trim final result for intermediate_e.
* libgcobol.cc: (__gg__adjust_dest_size): Abort on attempt to increase
the size of a result. (__gg__module_name): Formatting.
__gg__reverse(): Resize only intermediates
These changes are part of the effort to make possible cross compilation for
hosts that don't support __int128 or _Float128.
gcc/cobol
* Make-lang.in: Eliminate libgcobol.h from gcc/cobol files.
* genapi.cc: Eliminate "#include libgcobol.h".
(parser_display_internal): Change comment.
* genmath.cc: Eliminate "#include libgcobol.h".
* genutil.cc: Likewise.
(get_power_of_ten): Change comment.
* structs.cc: Eliminate cblc_int128_type_node.
* structs.h: Likewise.
* symbols.h: Receive comment from libgcobol.h
libgcobol
* charmaps.cc:Eliminate "#include libgcobol.h".
Change comment about _Float128.
* common-defs.h: Change comment about _Float128. Receive
#defines from libgcobol.h.
* constants.cc: Eliminate #include libgcobol.h. Eliminate other
unneeded #includes.
* ec.h: Receive declarations from libgcobol.h.
* gcobolio.h: Likewise.
* gfileio.cc: (__gg__file_init): Use file_flag_none_e instead of
zero in assignment. (__gg__file_reopen): Likewise.
(__io__file_open): Likewise.
* gfileio.h: Receive declarations from libgcobol.h.
* libgcobol.h: Numerous declarations moved elsewhere.
As explained in the libstdc++ manual[1] and elsewhere[2], using tolower
and toupper in std::transform directly is wrong. If char is signed then
non-ASCII characters with negative values lead to undefined behaviour.
Also, tolower and toupper are overloaded names in C++ so expecting them
to resolve to a unique function pointer is unreliable. Finally, the
<cctype> header was included, not <ctype.h>, so they should have been
qualified as std::tolower and std::toupper.
[1] https://gcc.gnu.org/onlinedocs/libstdc++/manual/strings.html#strings.string.simple
[2] https://en.cppreference.com/w/cpp/string/byte/tolower
libgcobol/ChangeLog:
* intrinsic.cc (is_zulu_format): Qualify toupper and cast
argument to unsigned char.
(fill_cobol_tm): Likewise.
(iscasematch): Likewise for to lower.
(numval): Qualify calls to tolower.
(__gg__lower_case): Use lambda expression for
tolower call.
(__gg__upper_case): Likewise for toupper call.
* libgcobol.cc (mangler_core): Cast tolower argument to unsigned
char.
* valconv.cc (__gg__string_to_numeric_edited): Cast to upper
arguments to unsigned char.
By setting "CXXFLAGS_FOR_TARGET=-ggdb -O0", a debuggable version
of libgcobol.so is created.
libgcobol
* Makefile.am: Incorporate AM_CXXFLAGS = $(CXXFLAGS_FOR_TARGET).
* Makefile.in: Regenerated.
This reduces the number of headers included in sources that are
shared with the Front End.
libgcobol/ChangeLog:
* charmaps.cc: Remove unused headers
* libgcobol.h: Likewise.
* valconv.cc: Likewise.
Signed-off-by: Iain Sandoe <iain@sandoe.co.uk>
When using --enable-version-specific-runtime-libs at least it's
required that $(gcc_version) is set to be able to expand
toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
The following fixes this by adjusting configure.ac to call GCC_BASE_VER
and Makefile.am to include a definition for gcc_version.
libgcobol/
* Makefile.am: Define gcc_version.
* configure.ac: Execute GCC_BASE_VER.
* Makefile.in: Regenerated.
* configure: Likewise.
Sorry, seems I've screwed up the earlier libgcobol/configure.tgt change.
Looking in more detail, the way e.g. libsanitizer/configure.tgt works is
that it is sourced twice, once at toplevel and there it just sets
UNSUPPORTED=1 for fully unsupported triplets, and then inside of
libsanitizer/configure where it decides to include or not include the
various sublibraries depending on the *_SUPPORTED flags.
So, the following patch attempts to do the same for libgcobol as well.
The BIULD_LIBGCOBOL automake conditional was unused, this patch guards it
on LIBGCOBOL_SUPPORTED as well and guards with it
toolexeclib_LTLIBRARIES = libgcobol.la
Also, AM_CFLAGS has been changed to AM_CXXFLAGS as there are just C++
sources in the library.
2025-03-11 Jakub Jelinek <jakub@redhat.com>
PR cobol/119216
* configure.ac: Check for UNSUPPORTED set by libgcobol/configure.tgt
rather than LIBGCOBOL_SUPPORTED.
* configure: Regenerate.
libgcobol/
* configure.tgt: On fully unsupported targets set UNSUPPORTED=1.
* configure.ac: Add AC_CHECK_SIZEOF([void *]), source in
configure.tgt and set BUILD_LIBGCOBOL also based on
LIBGCOBOL_SUPPORTED.
* Makefile.am (toolexeclib_LTLIBRARIES): Conditionalize on
BUILD_LIBGCOBOL.
(AM_CFLAGS): Rename to ...
(AM_CXXFLAGS): ... this.
(%.lo: %.cc): Use $(AM_CXXFLAGS) rather than $(AM_CFLAGS).
* configure: Regenerate.
* Makefile.in: Regenerate.
Looking at libgcobol.la, I see a lot of cruft, stuff that just shouldn't
be there because automake generates it otherwise right, but also stuff
using undefined variables etc.
libgcobol.{a,so*} seems to build and install the same as before.
Note, I stull see DT_RUNPATH in the installed libgcobol.so.1 before/after
this patch and I'd prefer not to see it, not seeing it in other libraries
like libstdc++.so.6 etc. Dunno if that is because of the dependency on
libstdc++ (but e.g. libstdc++ has dependency on libgcc_s and doesn't do
that).
2025-03-11 Jakub Jelinek <jakub@redhat.com>
* Makefile.am: Remove tons of VAR = @VAR@ style lines.
(libgcobol.la): Remove.
(libgcobol_la_LFLAGS): Remove.
(all): Remove.
(.PHONY): Remove.
(install): Remove.
(%.lo: %.c): Remove.
(doc): Remove.
(install-html install-pdf install-info): Remove.
* Makefile.in: Regenerate.
On Tue, Mar 11, 2025 at 10:45:09AM +0100, Andreas Schwab wrote:
> I think that makes the x32 match obsolete.
You're right. I've already committed the patch, so here is incremental one.
2025-03-11 Jakub Jelinek <jakub@redhat.com>
* configure.tgt: Remove x86_64-*-linux*x32 special case.
When we know libgcobol is unsupported on 32-bit arches, we should just say
so in configure.tgt, the same way as on other targets.
2025-03-11 Jakub Jelinek <jakub@redhat.com>
* configure.tgt: Only set LIBGCOBOL_SUPPORTED for lp64
multilibs of powerpc64le-*-linux* and x86_64-*-linux*. Handle
i?86-*-linux* the same as x86_64-*-linux*.
libgcobol/
* Makefile.am: New file.
* Makefile.in: Autogenerate.
* acinclude.m4: Likewise.
* aclocal.m4: Likewise.
* configure.ac: New file.
* configure: Autogenerate.
* configure.tgt: New file.
* README: New file.
* charmaps.cc: New file.
* config.h.in: New file.
* constants.cc: New file.
* gfileio.cc: New file.
* gmath.cc: New file.
* io.cc: New file.
* valconv.cc: New file.
* charmaps.h: New file.
* common-defs.h: New file.
* ec.h: New file.
* exceptl.h: New file.
* gcobolio.h: New file.
* gfileio.h: New file.
* gmath.h: New file.
* io.h: New file.
* libgcobol.h: New file.
* valconv.h: New file.
* libgcobol.cc: New file.
* intrinsic.cc: New file.