abicheck.sh portability
Guido Berhoerster
gber at opensuse.org
Wed Mar 23 18:55:12 CET 2011
* Adam Miller <maxamillion at fedoraproject.org> [2011-03-23 17:57]:
> On Wed, Mar 23, 2011 at 05:07:13PM +0100, Guido Berhoerster wrote:
> >
> > Hello,
> >
> > the abicheck.sh script included with libxfce4ui, exo, thunar,
> > xfce4-panel, xfconf, libxfce4util, and thunar-vfs which verifies
> > the symbol table uses non-portable constructs which currently
> > cause buildbot builds to fail on the Solaris platform.
> >
> > With the common build environment Solaris nm is in a $PATH ahead
> > of GNU nm and the "nm -D" output format differs. IMO the best
> > solution is using the -P option which produces a POSIX-specified
> > output format on both nm implementations, hence I'd suggest:
> >
> > nm -D -g -P libfoo.so | awk '$2~/^[DRT]$/&&$1~/^[^_]/{print $1}' >actual-abi
> >
> > (The alternative would be to add a Solaris-specific section and
> > either specify the full path /usr/gnu/bin/nm or use gnm instead
> > of nm, or use "elfdump -T SHT_DYNSYM libfoo.so | awk
> > '$8~/^\.(text|rodata)$/{print $9}' | sort >actual-abi".)
> >
> > While on OpenIndiana/Solaris Express both the gcc preprocessor
> > (/usr/gnu/bin/cpp) and a separate preprocessor (not in $PATH but
> > in /usr/lib/cpp) are available, SunStudio uses its own built-in
> > preprocessor. IMHO it might be a good idea to use the same
> > preprocessor used by the compiler and this can be achieved in a
> > portable way by invoking it with "$CC -E" (line markers can be
> > stripped with sed). How about:
> >
> > ${CC:-cc} -E -DINCLUDE_INTERNAL_SYMBOLS -DINCLUDE_VARIABLES -DALL_FILES ${srcdir:-.}/libfoo.symbols | sed 's/ G_GNUC.*$//;s/ PRIVATE//;/^[# ]*$/d' | sort >expected-abi
>
> I know I'm generally quiet on the mailing list and my code contributions
> are non existent thus far in life (heavily due to my lack of time and
> somewhat because of personal failures) so my opinion might not be looked
> at in high regard but I think remaining POSIX compliant where possible in
> shell scripting is likely the best route to go, so +1.
It is not really POSIX compliant, "nm -D" just happens to work on
both GNU and Solaris, it is not specified and I'm not sure there
even is a standards-compliant and portable way to extract the
SHT_DYNSYM section.
(The above cc could be replaced by c89 or c99 though if standards
matter here).
--
Guido Berhoerster
More information about the Xfce4-dev
mailing list