* [PATCH for 7.2] Fix broken configure with -Wunused-parameter
@ 2022-11-02 20:22 Stefan Weil via
2022-11-03 8:58 ` Daniel P. Berrangé
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Stefan Weil via @ 2022-11-02 20:22 UTC (permalink / raw)
To: qemu-trivial, qemu-devel; +Cc: Stefan Weil
The configure script fails because it tries to compile small C programs
with a main function which is declared with arguments argc and argv
although those arguments are unused.
Running `configure -extra-cflags=-Wunused-parameter` triggers the problem.
configure for a native build does abort but shows the error in config.log.
A cross build configure for Windows with Debian stable aborts with an
error.
Avoiding unused arguments fixes this.
Signed-off-by: Stefan Weil <sw@weilnetz.de>
---
See https://gitlab.com/qemu-project/qemu/-/issues/1295.
I noticed the problem because I often compile with -Wextra.
Stefan
configure | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/configure b/configure
index 4275f5419f..1106c04fea 100755
--- a/configure
+++ b/configure
@@ -1258,6 +1258,7 @@ if test "$stack_protector" != "no"; then
cat > $TMPC << EOF
int main(int argc, char *argv[])
{
+ (void)argc;
char arr[64], *p = arr, *c = argv[0];
while (*c) {
*p++ = *c++;
@@ -1607,7 +1608,7 @@ fi
if test "$safe_stack" = "yes"; then
cat > $TMPC << EOF
-int main(int argc, char *argv[])
+int main(void)
{
#if ! __has_feature(safe_stack)
#error SafeStack Disabled
@@ -1629,7 +1630,7 @@ EOF
fi
else
cat > $TMPC << EOF
-int main(int argc, char *argv[])
+int main(void)
{
#if defined(__has_feature)
#if __has_feature(safe_stack)
@@ -1675,7 +1676,7 @@ static const int Z = 1;
#define TAUT(X) ((X) == Z)
#define PAREN(X, Y) (X == Y)
#define ID(X) (X)
-int main(int argc, char *argv[])
+int main(void)
{
int x = 0, y = 0;
x = ID(x);
--
2.30.2
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH for 7.2] Fix broken configure with -Wunused-parameter
2022-11-02 20:22 [PATCH for 7.2] Fix broken configure with -Wunused-parameter Stefan Weil via
@ 2022-11-03 8:58 ` Daniel P. Berrangé
2022-11-03 9:19 ` Stefan Weil via
2022-11-03 17:16 ` Paolo Bonzini
2022-11-03 11:48 ` Peter Maydell
2022-11-03 17:22 ` Paolo Bonzini
2 siblings, 2 replies; 7+ messages in thread
From: Daniel P. Berrangé @ 2022-11-03 8:58 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel
On Wed, Nov 02, 2022 at 09:22:58PM +0100, Stefan Weil via wrote:
> The configure script fails because it tries to compile small C programs
> with a main function which is declared with arguments argc and argv
> although those arguments are unused.
>
> Running `configure -extra-cflags=-Wunused-parameter` triggers the problem.
> configure for a native build does abort but shows the error in config.log.
> A cross build configure for Windows with Debian stable aborts with an
> error.
>
> Avoiding unused arguments fixes this.
I'm not convinced that we should allow -extra-cflags to influence
the configure compile checks at all, as there are likely more cases
where arbitrary -W$warn flag will impact the checks, potentially
causing configure to silently take the wrong action.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> See https://gitlab.com/qemu-project/qemu/-/issues/1295.
>
> I noticed the problem because I often compile with -Wextra.
>
> Stefan
>
> configure | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 4275f5419f..1106c04fea 100755
> --- a/configure
> +++ b/configure
> @@ -1258,6 +1258,7 @@ if test "$stack_protector" != "no"; then
> cat > $TMPC << EOF
> int main(int argc, char *argv[])
> {
> + (void)argc;
> char arr[64], *p = arr, *c = argv[0];
> while (*c) {
> *p++ = *c++;
> @@ -1607,7 +1608,7 @@ fi
>
> if test "$safe_stack" = "yes"; then
> cat > $TMPC << EOF
> -int main(int argc, char *argv[])
> +int main(void)
> {
> #if ! __has_feature(safe_stack)
> #error SafeStack Disabled
> @@ -1629,7 +1630,7 @@ EOF
> fi
> else
> cat > $TMPC << EOF
> -int main(int argc, char *argv[])
> +int main(void)
> {
> #if defined(__has_feature)
> #if __has_feature(safe_stack)
> @@ -1675,7 +1676,7 @@ static const int Z = 1;
> #define TAUT(X) ((X) == Z)
> #define PAREN(X, Y) (X == Y)
> #define ID(X) (X)
> -int main(int argc, char *argv[])
> +int main(void)
> {
> int x = 0, y = 0;
> x = ID(x);
> --
> 2.30.2
>
>
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for 7.2] Fix broken configure with -Wunused-parameter
2022-11-03 8:58 ` Daniel P. Berrangé
@ 2022-11-03 9:19 ` Stefan Weil via
2022-11-03 17:16 ` Paolo Bonzini
1 sibling, 0 replies; 7+ messages in thread
From: Stefan Weil via @ 2022-11-03 9:19 UTC (permalink / raw)
To: Daniel P. Berrangé; +Cc: qemu-trivial, qemu-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 1141 bytes --]
Am 03.11.22 um 09:58 schrieb Daniel P. Berrangé:
> On Wed, Nov 02, 2022 at 09:22:58PM +0100, Stefan Weil via wrote:
>> The configure script fails because it tries to compile small C programs
>> with a main function which is declared with arguments argc and argv
>> although those arguments are unused.
>>
>> Running `configure -extra-cflags=-Wunused-parameter` triggers the problem.
>> configure for a native build does abort but shows the error in config.log.
>> A cross build configure for Windows with Debian stable aborts with an
>> error.
>>
>> Avoiding unused arguments fixes this.
> I'm not convinced that we should allow -extra-cflags to influence
> the configure compile checks at all, as there are likely more cases
> where arbitrary -W$warn flag will impact the checks, potentially
> causing configure to silently take the wrong action.
I partially agree, but configure should fail if invalid -extra-cflags
are specified, and the checks must also respect additional include paths
given by -extra-cflags of course.
And I think that the changes in my patch are an improvement in any case.
Stefan
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 6511 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for 7.2] Fix broken configure with -Wunused-parameter
2022-11-02 20:22 [PATCH for 7.2] Fix broken configure with -Wunused-parameter Stefan Weil via
2022-11-03 8:58 ` Daniel P. Berrangé
@ 2022-11-03 11:48 ` Peter Maydell
2022-11-03 12:08 ` Stefan Weil via
2022-11-03 17:22 ` Paolo Bonzini
2 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2022-11-03 11:48 UTC (permalink / raw)
To: Stefan Weil; +Cc: qemu-trivial, qemu-devel
On Wed, 2 Nov 2022 at 20:24, Stefan Weil via <qemu-devel@nongnu.org> wrote:
>
> The configure script fails because it tries to compile small C programs
> with a main function which is declared with arguments argc and argv
> although those arguments are unused.
>
> Running `configure -extra-cflags=-Wunused-parameter` triggers the problem.
> configure for a native build does abort but shows the error in config.log.
> A cross build configure for Windows with Debian stable aborts with an
> error.
>
> Avoiding unused arguments fixes this.
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
> ---
>
> See https://gitlab.com/qemu-project/qemu/-/issues/1295.
>
> I noticed the problem because I often compile with -Wextra.
>
> Stefan
>
> configure | 7 ++++---
> 1 file changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/configure b/configure
> index 4275f5419f..1106c04fea 100755
> --- a/configure
> +++ b/configure
> @@ -1258,6 +1258,7 @@ if test "$stack_protector" != "no"; then
> cat > $TMPC << EOF
> int main(int argc, char *argv[])
> {
> + (void)argc;
I'm not a huge fan of this syntax, and it doesn't match the way
we deal with "argument is unused" elsewhere in the codebase
(where we either don't care about it or else use the GCC 'unused'
attribute hidden behind the glib G_GNUC_UNUSED macro).
I am surprised that this didn't get caught by the check in
do_compiler_werror(), which is supposed to report "this
configure test passed without -Werror but failed with
-Werror, so configure is probably buggy.". That's what's
supposed to catch "your compiler warns on stuff our doesn't
in the test case programs".
If you're building with --disable-werror then configure
should be OK anyway. This is probably a good idea if you want
to build with extra warning arguments in --extra-cflags.
If it doesn't work right even with --disable-werror that's
also something we should investigate.
> char arr[64], *p = arr, *c = argv[0];
> while (*c) {
> *p++ = *c++;
> @@ -1607,7 +1608,7 @@ fi
>
> if test "$safe_stack" = "yes"; then
> cat > $TMPC << EOF
> -int main(int argc, char *argv[])
> +int main(void)
> {
> #if ! __has_feature(safe_stack)
> #error SafeStack Disabled
> @@ -1629,7 +1630,7 @@ EOF
> fi
> else
> cat > $TMPC << EOF
> -int main(int argc, char *argv[])
> +int main(void)
> {
> #if defined(__has_feature)
> #if __has_feature(safe_stack)
> @@ -1675,7 +1676,7 @@ static const int Z = 1;
> #define TAUT(X) ((X) == Z)
> #define PAREN(X, Y) (X == Y)
> #define ID(X) (X)
> -int main(int argc, char *argv[])
> +int main(void)
> {
> int x = 0, y = 0;
> x = ID(x);
No objection to the cases where we can pass "void", that's
a neater way to write the test anyway.
thanks
-- PMM
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for 7.2] Fix broken configure with -Wunused-parameter
2022-11-03 11:48 ` Peter Maydell
@ 2022-11-03 12:08 ` Stefan Weil via
0 siblings, 0 replies; 7+ messages in thread
From: Stefan Weil via @ 2022-11-03 12:08 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-trivial, qemu-devel
[-- Attachment #1.1.1: Type: text/plain, Size: 3545 bytes --]
Am 03.11.22 um 12:48 schrieb Peter Maydell:
> On Wed, 2 Nov 2022 at 20:24, Stefan Weil via <qemu-devel@nongnu.org> wrote:
>> The configure script fails because it tries to compile small C programs
>> with a main function which is declared with arguments argc and argv
>> although those arguments are unused.
>>
>> Running `configure -extra-cflags=-Wunused-parameter` triggers the problem.
>> configure for a native build does abort but shows the error in config.log.
>> A cross build configure for Windows with Debian stable aborts with an
>> error.
>>
>> Avoiding unused arguments fixes this.
>>
>> Signed-off-by: Stefan Weil <sw@weilnetz.de>
>> ---
>>
>> See https://gitlab.com/qemu-project/qemu/-/issues/1295.
>>
>> I noticed the problem because I often compile with -Wextra.
>>
>> Stefan
>>
>> configure | 7 ++++---
>> 1 file changed, 4 insertions(+), 3 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 4275f5419f..1106c04fea 100755
>> --- a/configure
>> +++ b/configure
>> @@ -1258,6 +1258,7 @@ if test "$stack_protector" != "no"; then
>> cat > $TMPC << EOF
>> int main(int argc, char *argv[])
>> {
>> + (void)argc;
> I'm not a huge fan of this syntax, and it doesn't match the way
> we deal with "argument is unused" elsewhere in the codebase
> (where we either don't care about it or else use the GCC 'unused'
> attribute hidden behind the glib G_GNUC_UNUSED macro).
Any other variant is also fine for me, for example "using" argc by a
"return argc == 0;" instead of "return 0;". Would that be better? If
there is an accepted variant, I can either send a v2 patch, or maybe
such a trivial change can be applied when merging.
> I am surprised that this didn't get caught by the check in
> do_compiler_werror(), which is supposed to report "this
> configure test passed without -Werror but failed with
> -Werror, so configure is probably buggy.". That's what's
> supposed to catch "your compiler warns on stuff our doesn't
> in the test case programs".
>
> If you're building with --disable-werror then configure
> should be OK anyway. This is probably a good idea if you want
> to build with extra warning arguments in --extra-cflags.
> If it doesn't work right even with --disable-werror that's
> also something we should investigate.
Cross builds for Windows fail with and without --disable-werror. See
also my bug report https://gitlab.com/qemu-project/qemu/-/issues/1295.
You are right that this is strange and should be investigated,
especially because native builds don't fail like that.
>> char arr[64], *p = arr, *c = argv[0];
>> while (*c) {
>> *p++ = *c++;
>> @@ -1607,7 +1608,7 @@ fi
>>
>> if test "$safe_stack" = "yes"; then
>> cat > $TMPC << EOF
>> -int main(int argc, char *argv[])
>> +int main(void)
>> {
>> #if ! __has_feature(safe_stack)
>> #error SafeStack Disabled
>> @@ -1629,7 +1630,7 @@ EOF
>> fi
>> else
>> cat > $TMPC << EOF
>> -int main(int argc, char *argv[])
>> +int main(void)
>> {
>> #if defined(__has_feature)
>> #if __has_feature(safe_stack)
>> @@ -1675,7 +1676,7 @@ static const int Z = 1;
>> #define TAUT(X) ((X) == Z)
>> #define PAREN(X, Y) (X == Y)
>> #define ID(X) (X)
>> -int main(int argc, char *argv[])
>> +int main(void)
>> {
>> int x = 0, y = 0;
>> x = ID(x);
> No objection to the cases where we can pass "void", that's
> a neater way to write the test anyway.
>
> thanks
> -- PMM
>
[-- Attachment #1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 6511 bytes --]
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for 7.2] Fix broken configure with -Wunused-parameter
2022-11-03 8:58 ` Daniel P. Berrangé
2022-11-03 9:19 ` Stefan Weil via
@ 2022-11-03 17:16 ` Paolo Bonzini
1 sibling, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2022-11-03 17:16 UTC (permalink / raw)
To: Daniel P. Berrangé, Stefan Weil; +Cc: qemu-trivial, qemu-devel
On 11/3/22 09:58, Daniel P. Berrangé wrote:
> On Wed, Nov 02, 2022 at 09:22:58PM +0100, Stefan Weil via wrote:
>> The configure script fails because it tries to compile small C programs
>> with a main function which is declared with arguments argc and argv
>> although those arguments are unused.
>>
>> Running `configure -extra-cflags=-Wunused-parameter` triggers the problem.
>> configure for a native build does abort but shows the error in config.log.
>> A cross build configure for Windows with Debian stable aborts with an
>> error.
>>
>> Avoiding unused arguments fixes this.
> I'm not convinced that we should allow -extra-cflags to influence
> the configure compile checks at all, as there are likely more cases
> where arbitrary -W$warn flag will impact the checks, potentially
> causing configure to silently take the wrong action.
Meson cc.compiles/cc.links tests never use -Werror to avoid this (which
has a different set of issues, but if you want you can add the argument
manually and 0.64 will also add a "werror: true|false" argument). Since
the last configure tests will go away in 8.0, I'm fine with just
applying this patch in the meanwhile.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH for 7.2] Fix broken configure with -Wunused-parameter
2022-11-02 20:22 [PATCH for 7.2] Fix broken configure with -Wunused-parameter Stefan Weil via
2022-11-03 8:58 ` Daniel P. Berrangé
2022-11-03 11:48 ` Peter Maydell
@ 2022-11-03 17:22 ` Paolo Bonzini
2 siblings, 0 replies; 7+ messages in thread
From: Paolo Bonzini @ 2022-11-03 17:22 UTC (permalink / raw)
To: Stefan Weil, qemu-trivial, qemu-devel
On 11/2/22 21:22, Stefan Weil via wrote:
> != "no"; then
> cat > $TMPC << EOF
> int main(int argc, char *argv[])
> {
> + (void)argc;
> char arr[64], *p = arr, *c = argv[0];
You could use argv[argc - 1] instead.
Paolo
> while (*c) {
> *p++ = *c++;
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2022-11-03 17:23 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-02 20:22 [PATCH for 7.2] Fix broken configure with -Wunused-parameter Stefan Weil via
2022-11-03 8:58 ` Daniel P. Berrangé
2022-11-03 9:19 ` Stefan Weil via
2022-11-03 17:16 ` Paolo Bonzini
2022-11-03 11:48 ` Peter Maydell
2022-11-03 12:08 ` Stefan Weil via
2022-11-03 17:22 ` Paolo Bonzini
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.