[PATCH v2] libsframe: testsuite: Fix testsuite build on Solaris
Indu Bhagat
indu.bhagat@oracle.com
Mon Sep 1 08:37:22 GMT 2025
On 8/31/25 12:15 PM, Rainer Orth wrote:
> As reported in PR libsframe/33168, the libsframe tests don't build on
> Solaris. The failure is
>
> In file included from libsframe/testsuite/libsframe.decode/be-flipping.c:28:
> /usr/include/dejagnu.h:48:1: error: conflicting types for ‘wait’; have ‘void(void)’
> 48 | wait (void)
> | ^~~~
> In file included from /usr/include/stdlib.h:16,
> from libsframe/testsuite/libsframe.decode/be-flipping.c:21:
> /usr/include/sys/wait.h:85:14: note: previous declaration of ‘wait’ with type ‘pid_t(int *)’ {aka ‘long int(int *)’}
> 85 | extern pid_t wait(int *);
> | ^~~~
>
> We have a combination of two factors here:
>
> * Solaris <stdlib.h> has
>
> #if defined(__EXTENSIONS__) || defined(_XPG4)
> #include <sys/wait.h>
> #endif
>
> and configure.ac predefines __EXTENSIONS__ due to the use of
> AC_USE_SYSTEM_EXTENSIONS.
>
> * This conflicts with <dejagnu.h>'s definition
>
> void
> wait (void)
> {
> ...
> }
>
> While this version of wait was removed in upstream DejaGnu, the removal
> only happened after the latest release, 1.6.3.
>
> To avoid this, I've moved all testsuite includes into a new
> sframe-test.h, adding a workaround for the wait conflict. I've put that
> header into the toplevel include to avoid having to add various -I flags
> all over the testsuite.
>
Thanks for taking care of this.
sframe-test.h in toplevel include/ looks odd IMO. Adding to
libsframe/testsuite/ folder along with the -I${top_srcdir}/testsuite
addition in libsframe/testsuite/libsframe.decode/local.mk,
libsframe/testsuite/libsframe.encode/local.mk,
libsframe/testsuite/libsframe.find/local.mk may be a better thing to do.
> Tested on {i386,amd64}-pc-solaris2.11, {sparc,sparcv9}-sun-solaris2.11,
> {x86_64,i686}-pc-linux-gnu, and amd64-pc-freebsd14.0.
>
> Ok for trunk?
>
> Rainer
>
> --
> ----------------------------------------------------------------------------- Rainer Orth, Center for Biotechnology, Bielefeld University 2025-08-31 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE> include: PR libsframe/33168 * sframe-test.h: New file. libsframe: PR libsframe/33168 * testsuite/sframe-test.h: New file. * testsuite/libsframe.decode/be-flipping.c: Replace includes by sframe-test.h. * testsuite/libsframe.decode/frecnt-1.c: Likewise. * testsuite/libsframe.decode/frecnt-2.c: Likewise. * testsuite/libsframe.encode/encode-1.c: Likewise. * testsuite/libsframe.find/findfre-1.c: Likewise. * testsuite/libsframe.find/findfunc-1.c: Likewise. * testsuite/libsframe.find/plt-findfre-1.c: Likewise. * testsuite/libsframe.find/plt-findfre-2.c: Likewise.
>
>
> sol2-libsframe-testsuite-dg.patch
>
> # HG changeset patch
> # Parent f5c24eceb5f6687b68d48dbe0cba289e6ad420f1
> libsframe: testsuite: Fix testsuite build on Solaris [PR33168]
>
> diff --git a/include/sframe-test.h b/include/sframe-test.h
> new file mode 100644
> --- /dev/null
> +++ b/include/sframe-test.h
> @@ -0,0 +1,40 @@
> +/* sframe-test.h -- Common libsframe testsuite header.
> +
> + Copyright (C) 2022-2025 Free Software Foundation, Inc.
> +
2022-2025 --> 2025
> + This program is free software; you can redistribute it and/or modify
> + it under the terms of the GNU General Public License as published by
> + the Free Software Foundation; either version 3 of the License, or
> + (at your option) any later version.
> +
> + This program is distributed in the hope that it will be useful,
> + but WITHOUT ANY WARRANTY; without even the implied warranty of
> + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + GNU General Public License for more details.
> +
> + You should have received a copy of the GNU General Public License
> + along with this program. If not, see<http://www.gnu.org/licenses/>. */
> +
> +#ifndef _SFRAME_TEST_H
> +#define _SFRAME_TEST_H
> +
> +#include "config.h"
> +
> +#include <stdio.h>
> +#include <stdlib.h>
> +#include <string.h>
> +#include <sys/stat.h>
> +
> +#include "sframe-api.h"
> +
> +/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> +#undef vsnprintf
> +
> +/* PR 33168: Solaris <sys/wait.h> with __EXTENSIONS__ defined gets a
> + declaration of wait(). This conflicts with <dejagnu.h>'s wait
> + definition that is only removed after DejaGnu 1.6.3. */
> +#define wait dg_wait
> +#include <dejagnu.h>
> +#undef wait
> +
Should we do a :
#define wait dg_wait
void wait (void);
#include <dejagnu.h>
#undef wait
to get rid of warnings like:
In file included from
<src>/binutils-gdb/libsframe/testsuite/libsframe.find/plt-findfre-2.c:19:
<src>/binutils-gdb/libsframe/../include/sframe-test.h:36:14: warning: no
previous prototype for ‘dg_wait’ [-Wmissing-prototypes]
36 | #define wait dg_wait
| ^~~~~~~
> +#endif /* _SFRAME_TEST_H */
> diff --git a/libsframe/testsuite/libsframe.decode/be-flipping.c b/libsframe/testsuite/libsframe.decode/be-flipping.c
> --- a/libsframe/testsuite/libsframe.decode/be-flipping.c
> +++ b/libsframe/testsuite/libsframe.decode/be-flipping.c
> @@ -15,17 +15,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see<http://www.gnu.org/licenses/>. */
>
> -#include "config.h"
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> /* SFrame info from the following source (1 fde 5 fres):
> static int cnt;
> diff --git a/libsframe/testsuite/libsframe.decode/frecnt-1.c b/libsframe/testsuite/libsframe.decode/frecnt-1.c
> --- a/libsframe/testsuite/libsframe.decode/frecnt-1.c
> +++ b/libsframe/testsuite/libsframe.decode/frecnt-1.c
> @@ -15,17 +15,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see<http://www.gnu.org/licenses/>. */
>
> -#include "config.h"
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> /*
> * SFrame info from the following source (1 fde 4 fres):
> diff --git a/libsframe/testsuite/libsframe.decode/frecnt-2.c b/libsframe/testsuite/libsframe.decode/frecnt-2.c
> --- a/libsframe/testsuite/libsframe.decode/frecnt-2.c
> +++ b/libsframe/testsuite/libsframe.decode/frecnt-2.c
> @@ -15,17 +15,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see<http://www.gnu.org/licenses/>. */
>
> -#include "config.h"
> -
> -#include <stdio.h>
> -#include <stdlib.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> /*
> * SFrame info from the following source (2 fde 8 fres):
> diff --git a/libsframe/testsuite/libsframe.encode/encode-1.c b/libsframe/testsuite/libsframe.encode/encode-1.c
> --- a/libsframe/testsuite/libsframe.encode/encode-1.c
> +++ b/libsframe/testsuite/libsframe.encode/encode-1.c
> @@ -15,17 +15,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see<http://www.gnu.org/licenses/>. */
>
> -#include "config.h"
> -
> -#include <stdlib.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> static int
> add_fde1 (sframe_encoder_ctx *encode, uint32_t start_pc_vaddr,
> diff --git a/libsframe/testsuite/libsframe.find/findfre-1.c b/libsframe/testsuite/libsframe.find/findfre-1.c
> --- a/libsframe/testsuite/libsframe.find/findfre-1.c
> +++ b/libsframe/testsuite/libsframe.find/findfre-1.c
> @@ -15,17 +15,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see<http://www.gnu.org/licenses/>. */
>
> -#include "config.h"
> -
> -#include <stdlib.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> static int
> add_fde1 (sframe_encoder_ctx *encode, uint32_t start_pc_vaddr,
> diff --git a/libsframe/testsuite/libsframe.find/findfunc-1.c b/libsframe/testsuite/libsframe.find/findfunc-1.c
> --- a/libsframe/testsuite/libsframe.find/findfunc-1.c
> +++ b/libsframe/testsuite/libsframe.find/findfunc-1.c
> @@ -22,17 +22,7 @@
> The tests in here stress the sframe_get_funcdesc_with_addr API via calls to
> the sframe_find_fre (). */
>
> -#include "config.h"
> -
> -#include <stdlib.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> static int
> add_fde1 (sframe_encoder_ctx *encode, uint32_t start_pc_vaddr,
> diff --git a/libsframe/testsuite/libsframe.find/plt-findfre-1.c b/libsframe/testsuite/libsframe.find/plt-findfre-1.c
> --- a/libsframe/testsuite/libsframe.find/plt-findfre-1.c
> +++ b/libsframe/testsuite/libsframe.find/plt-findfre-1.c
> @@ -15,17 +15,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see<http://www.gnu.org/licenses/>. */
>
> -#include "config.h"
> -
> -#include <stdlib.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> static int
> add_plt_fde1 (sframe_encoder_ctx *ectx, uint32_t plt_vaddr,
> diff --git a/libsframe/testsuite/libsframe.find/plt-findfre-2.c b/libsframe/testsuite/libsframe.find/plt-findfre-2.c
> --- a/libsframe/testsuite/libsframe.find/plt-findfre-2.c
> +++ b/libsframe/testsuite/libsframe.find/plt-findfre-2.c
> @@ -16,17 +16,7 @@
> You should have received a copy of the GNU General Public License
> along with this program. If not, see<http://www.gnu.org/licenses/>. */
>
> -#include "config.h"
> -
> -#include <stdlib.h>
> -#include <string.h>
> -#include <sys/stat.h>
> -
> -#include "sframe-api.h"
> -
> -/* DejaGnu should not use gnulib's vsnprintf replacement here. */
> -#undef vsnprintf
> -#include <dejagnu.h>
> +#include "sframe-test.h"
>
> /* s390x-specific size in bytes of plt0 and pltN. */
> #define PLT_SIZE 32
>
More information about the Binutils
mailing list