libctf doesn't build with Solaris sed
Nick Alcock
nick.alcock@oracle.com
Wed Oct 21 14:15:44 GMT 2020
On 18 Oct 2020, Simon Marchi told this:
> I'm trying to build GDB on Solaris (on machine gcc211 of the compile
> farm), and I stumbled on this error:
>
> In file included from /export/home/simark/src/binutils-gdb/libctf/ctf-error.c:41:0:
> ./ctf-error.h:1:4: error: expected specifier-qualifier-list before ‘ECTF_FMT’ 9]
> ECTF_FMT, /* File is not in CTF or ELF format. */
> ^
>
> I tracked it down to ctf-error.h (a generated file) having the wrong
> content:
>
> $ sed -nf /export/home/simark/src/binutils-gdb/libctf/mkerrors.sed < /export/home/simark/src/binutils-gdb/libctf/../include/ctf-api.h
> ECTF_FMT, /* File is not in CTF or ELF format. */
> ECTF_BFDERR, /* BFD error. */
> ...
>
> Normally, it should be like this:
>
> _CTF_STR (ECTF_FMT, "File is not in CTF or ELF format")
> _CTF_STR (ECTF_BFDERR, "BFD error")
>
> I presume that there is some GNU-ism in mkerrors.sed. When I replace
> sed with gsed in the Makefile, it gets generated correctly.
Curious! I tested this on Solaris: maybe it works with some versions of
Solaris sed and not others.
It looks like this regex is not matching:
s@^ *\(ECTF_[^[:blank:],]*\),\{0,1\}[[:blank:]]*/\* \(.*\). \*/$@_CTF_STR (\1, "\2")@;
IIRC, Solaris sed is so archaic that it doesn't understand [:blank:]. If
you replace it with [\t ] or someting, does it work better? (I really
should look into enabling my compile farm access so I could check this
myself!)
> If the script can be made to work with all seds, then great. Otherwise,
Almost certainly.
> you could verify that sed is GNU sed and allow the user to pass SED=gsed
> or something.
>
> Also, "make clean" does not remove ctf-error.h, I think it should.
Oops, I forgot to add it to CLEANFILES. Fixed locally, will be in my
next push.
On 19 Oct 2020, Tom Tromey told this:
>>>>>> "Simon" == Simon Marchi via Binutils <binutils@sourceware.org> writes:
>
> Simon> Normally, it should be like this:
>
> Simon> _CTF_STR (ECTF_FMT, "File is not in CTF or ELF format")
> Simon> _CTF_STR (ECTF_BFDERR, "BFD error")
>
> Simon> I presume that there is some GNU-ism in mkerrors.sed. When I replace
> Simon> sed with gsed in the Makefile, it gets generated correctly.
>
> Simon> If the script can be made to work with all seds, then great. Otherwise,
> Simon> you could verify that sed is GNU sed and allow the user to pass SED=gsed
> Simon> or something.
>
> Simon> Also, "make clean" does not remove ctf-error.h, I think it should.
>
> It seems to me that ctf-error.h could be removed entirely by changing
> this enum to a ".defs"-like file (see include/dwarf2.def for an example)
> or a C macro that can be used to expand multiple ways.
We could, yes, but the whole point of this dance is that ctf-errors.h is
generated from ctf-api.h, so that new errors and their descriptions only
need to be added in one place (the API definition itself) and then
everything else is generated from there. The only way we could use a
.defs file is to generate ctf-api.h itself, and... that feels likely to
annoy people who are using the copy in the source tree for reference
purposes.
(Also, there is no enum: it's a union of a structure and its
initializer. But your point stands :) ).
> .defs are used pretty frequently in gdb and gcc. The C macro trick is
> to do something like:
>
> #define BLAH \
> EXPAND (ONE, 1),
> EXPAND (TWO, 2)
Surely there's still a separate file to define BLAH in the first place,
unless we want to hardwire that list -- and avoiding that hardwiring is
the whole point of the sed in the first place.
More information about the Binutils
mailing list