https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119217
--- Comment #10 from ro at CeBiTec dot Uni-Bielefeld.DE <ro at CeBiTec dot
Uni-Bielefeld.DE> ---
> --- Comment #5 from Rainer Orth <ro at gcc dot gnu.org> ---
Given the recent flurry of activity to make the COBOL frontend (and
libgcobol) more portable, I've given a Solaris/amd64 build another try.
Some issues remain, while others are new.
> * GLOB_BRACE and GLOB_TILDE are not in POSIX.1 and missing on Solaris:
>
> /vol/gcc/src/hg/master/local/gcc/cobol/cdf-copy.cc: In member function ‘int
> copybook_elem_t::open_file(const char*, bool)’:
> /vol/gcc/src/hg/master/local/gcc/cobol/cdf-copy.cc:317:34: error: ‘GLOB_BRACE’
> was not declared in this scope; did you mean ‘GLOB_ERR’?
> 317 | static int flags = GLOB_MARK | GLOB_BRACE | GLOB_TILDE;
> | ^~~~~~~~~~
> | GLOB_ERR
> /vol/gcc/src/hg/master/local/gcc/cobol/cdf-copy.cc:317:47: error: ‘GLOB_TILDE’
> was not declared in this scope
> 317 | static int flags = GLOB_MARK | GLOB_BRACE | GLOB_TILDE;
> | ^~~~~~~~~~
As a hack, I've simply defined both GLOB_BRACE and GLOB_TILDE as 0 if
they are missing. Alternatively, gnulib has a version glob that
supports both, although I don't know if we want to go this route (gdb
has, for example).
> * NAME_MAX is undefined on Solaris since it can vary by path, as allowed by
> POSIX.1:
>
> /vol/gcc/src/hg/master/local/gcc/cobol/symbols.h: At global scope:
> /vol/gcc/src/hg/master/local/gcc/cobol/symbols.h:1365:13: error: ‘NAME_MAX’
> was
> not declared in this scope
> 1365 | char name[NAME_MAX];
> | ^~~~~~~~
Again, I provided a fallback definition (255) for this case.
* valconv.cc uses index without a declaration:
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, this needs <strings.h>. One should simply use strchr instead.
* The initialization of regmatch_t breaks:
In file included from /vol/gcc/src/hg/master/local/gcc/cobol/lexio.h:208,
from /vol/gcc/src/hg/master/local/gcc/cobol/lexio.cc:36:
/vol/gcc/src/hg/master/local/gcc/cobol/dts.h: In constructor
‘dts::csub_match::csub_match(const char*)’:
/vol/gcc/src/hg/master/local/gcc/cobol/dts.h:36:35: error: invalid conversion
from ‘int’ to ‘const char*’ [-fpermissive]
36 | static regmatch_t empty = { -1, -1 };
| ^~
| |
| int
Solaris <regex.h> has
typedef struct {
const char *rm_sp, *rm_ep; /* Start pointer, end pointer */
regoff_t rm_so, rm_eo; /* Start offset, end offset */
int rm_ss, rm_es; /* Used internally */
} regmatch_t;
(additional members are always allowed). I didn't use designated
initializers here since that causes warnings like
/vol/gcc/src/hg/master/cobol/gcc/cobol/dts.h:36:60: warning: missing
initializer for member ‘regmatch_t::rm_ep’ [-Wmissing-field-initializers]
* Using timespec_t as a class name breaks:
/vol/gcc/src/hg/master/local/gcc/cobol/util.cc:2135:7: error: using
typedef-name ‘timespec_t’ after ‘class’
2135 | class timespec_t {
| ^~~~~~~~~~
Solaris <sys/time_impl.h> declares timespec_t itself. Besides, *_t
identifies are reserved by POSIX.1. I've renamed this to
cbl_timespec_t (should probably be cbl_timespec or some such instead).
* Solaris <math.h> defines OVERFLOW, clashing with the like-named
identifier in the scanner/parser:
cobol/parse.h:356:5: error: expected identifier before numeric constant
356 | OVERFLOW = 305, /* OVERFLOW */
| ^~~~~~~~
To avoid this, I've renamed it to OVERFLOW_kw in line with other such
cases.
With those changes/hacks (attached for reference), I managed to build
cobol1 on amd64-pc-solaris2.11.
libgcobol is another matter, primarily for lack of the C23 *128
functions, but also initstate_r, srandom_r, and tm_zone in struct tm.
I'll give that another try once Iain's work to use libquadmath lands.