This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 4/4][libbacktrace] Add tests for unused formats
- From: Gerald Pfeifer <gerald at pfeifer dot com>
- To: Tom de Vries <tdevries at suse dot de>, Ian Lance Taylor <ian at airs dot com>, gcc-patches at gcc dot gnu dot org
- Cc: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- Date: Fri, 28 Dec 2018 20:40:42 -1000 (-10)
- Subject: Re: [PATCH 4/4][libbacktrace] Add tests for unused formats
- References: <20181123205612.GA3609@delia>
On Fri, 23 Nov 2018, Tom de Vries wrote:
> When building libbacktrace, we typically use elf.c, and don't build
> pecoff.c, xcoff.c or unknown.c
>
> Add testcases that use unused format to ensure that we also build and
> test those on a typical development setup.
This is a good idea!
> Bootstrapped and reg-tested on x86_64.
Unfortunately, on i586-unknown-freebsd11 I'm now seeing the likes of
gmake[3]: *** [Makefile:1086: xcoff_32.lo] Error 1
xcoff_64.c:54:29: error: extra tokens at end of #undef directive [-Werror]
54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64
| ^
xcoff_64.c:54:29: warning: extra tokens at end of #undef directive
54 | #undef BACKTRACE_XCOFF_SIZEn#define BACKTRACE_XCOFF_SIZE 64
| ^
cc1: all warnings being treated as errors
gmake[3]: *** [Makefile:1086: xcoff_64.lo] Error 1
The reason is that GNU sed supports \n in the replacement pattern
% echo "abc" | sed -E 's:b:\n:'
a
c
whereas BSD sed does not
% echo "abc" | sed -E 's:b:\n:'
anc
so the following in libbacktrace/Makefile.am doesn't work:
xcoff_%.c: xcoff.c
SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
$(srcdir)/xcoff.c \
> $@
I believe that in addition to FreeBSD this probably also fails on
Solaris and Darwin.
The patch below should address this (and does in my tests), though
my tester seems to have unrelated(?) problems right now, so better
for one of you to give a spin as well, please.
Gerald
2018-12-28 Gerald Pfeifer <gerald@pfeifer.com>
* Makefile.am (xcoff_%.c): Use an actual newline instead of \n.
* Makefile.in: Regenerate.
Index: libbacktrace/Makefile.am
===================================================================
--- libbacktrace/Makefile.am (revision 267460)
+++ libbacktrace/Makefile.am (working copy)
@@ -105,7 +105,8 @@
xcoff_%.c: xcoff.c
SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
- REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+ REPLACE='#undef BACKTRACE_XCOFF_SIZE\
+ #define BACKTRACE_XCOFF_SIZE'; \
$(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
$(srcdir)/xcoff.c \
> $@
Index: libbacktrace/Makefile.in
===================================================================
--- libbacktrace/Makefile.in (revision 267460)
+++ libbacktrace/Makefile.in (working copy)
@@ -1733,7 +1733,8 @@
@NATIVE_TRUE@xcoff_%.c: xcoff.c
@NATIVE_TRUE@ SEARCH='#error "Unknown BACKTRACE_XCOFF_SIZE"'; \
-@NATIVE_TRUE@ REPLACE='#undef BACKTRACE_XCOFF_SIZE\n#define BACKTRACE_XCOFF_SIZE'; \
+@NATIVE_TRUE@ REPLACE='#undef BACKTRACE_XCOFF_SIZE\
+@NATIVE_TRUE@ #define BACKTRACE_XCOFF_SIZE'; \
@NATIVE_TRUE@ $(SED) "s/^$$SEARCH\$$/$$REPLACE $*/" \
@NATIVE_TRUE@ $(srcdir)/xcoff.c \
@NATIVE_TRUE@ > $@