From: Rusty Russell <rusty@rustcorp.com.au>
To: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Hollis Blanchard <hollisb@us.ibm.com>,
Jan Beulich <JBeulich@novell.com>,
akpm@linux-foundation.org, linuxppc-dev@lists.ozlabs.org,
kvm-ppc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-next@vger.kernel.org
Subject: Re: [PATCH] BUILD_BUG_ON: make it handle more cases
Date: Thu, 5 Nov 2009 16:58:36 +1030 [thread overview]
Message-ID: <200911051658.36265.rusty@rustcorp.com.au> (raw)
In-Reply-To: <20091105112020.33f02552.sfr@canb.auug.org.au>
On Thu, 5 Nov 2009 10:50:20 am Stephen Rothwell wrote:
> Hi Rusty,
>
> On Tue, 20 Oct 2009 14:15:33 +1030 Rusty Russell <rusty@rustcorp.com.au> wrote:
> >
> > +#ifndef __OPTIMIZE__
> > +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)]))
> > +#else
> > +extern int __build_bug_on_failed;
> > +#define BUILD_BUG_ON(condition) \
> > + do { \
> > + ((void)sizeof(char[1 - 2*!!(condition)])); \
> > + if (condition) __build_bug_on_failed = 1; \
> > + } while(0)
> > +#endif
> > +#define MAYBE_BUILD_BUG_ON(condition) BUILD_BUG_ON(condition)
> > +
>
> I decided to try this in linux-next, but an x86_64 allmodconfig build
> gave this (gcc 4.4.0):
>
> ERROR: "__build_bug_on_failed" [drivers/net/virtio_net.ko] undefined!
> ERROR: "__build_bug_on_failed" [drivers/block/virtio_blk.ko] undefined!
>
> I assume that this is caused by the "MAYBE_BUILD_BUG_ON(fbit >= 32)" in
> virtio_has_feature() (in include/linux/virtio_config.h) which is called
> all over the place. Unfortunately, virtio_has_feature() gets uninlined
> in those two files ...
Huh? virtio_has_feature does:
if (__builtin_constant_p(fbit))
BUILD_BUG_ON(fbit >= 32);
else
BUG_ON(fbit >= 32);
So, if it's not a constant, gcc should throw away that first branch. If it
is, it should optimize it away (and no, these are not real bugs AFAICT).
I did a 4.3.3 allmodconfig with this patch on 64-bit a few days back and all
was fine. Will try 4.4.0 now.
Thanks,
Rusty.
next prev parent reply other threads:[~2009-11-05 6:28 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-09-29 9:28 linux-next: tree build failure Jan Beulich
[not found] ` <4AC1E15502000078000516B5-Qfbpwmsw6RoS3W1tAdPHOtBPR1lH4CV8@public.gmane.org>
2009-09-29 9:51 ` roel kluin
[not found] ` <25e057c00909290251h55c0dc25o4ab1f2e84c920dca-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-09-30 6:29 ` Jan Beulich
2009-09-29 23:39 ` Hollis Blanchard
[not found] ` <1254267572.15622.1621.camel-yDUrRDS8jBVhsM67afOH+sxtgHpCUUYS@public.gmane.org>
2009-09-30 6:35 ` Jan Beulich
[not found] ` <4AC318450200007800017355-Qfbpwmsw6RoS3W1tAdPHOtBPR1lH4CV8@public.gmane.org>
2009-10-02 15:48 ` Hollis Blanchard
2009-10-05 6:58 ` Jan Beulich
2009-10-09 19:14 ` Hollis Blanchard
2009-10-14 22:57 ` Hollis Blanchard
2009-10-15 7:27 ` Jan Beulich
2009-10-19 18:19 ` Hollis Blanchard
2009-10-20 1:12 ` Rusty Russell
[not found] ` <200910201142.34006.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2009-10-20 1:29 ` Hollis Blanchard
2009-10-20 3:45 ` [PATCH] BUILD_BUG_ON: make it handle more cases Rusty Russell
2009-10-20 13:58 ` Américo Wang
2009-10-20 14:43 ` Alan Jenkins
[not found] ` <9b2b86520910200743h4e134cf8jd2860d42b3936597-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-10-23 1:50 ` Américo Wang
2009-10-29 21:30 ` Hollis Blanchard
[not found] ` <200910201415.34361.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2009-10-22 21:04 ` Hollis Blanchard
2009-11-05 0:20 ` Stephen Rothwell
2009-11-05 6:28 ` Rusty Russell [this message]
[not found] ` <200911051658.36265.rusty-8n+1lVoiYb80n/F98K4Iww@public.gmane.org>
2009-11-05 6:37 ` Rusty Russell
2009-11-05 6:38 ` Stephen Rothwell
[not found] ` <20091105173842.c94ba501.sfr-3FnU+UHB4dNDw9hX6IcOSA@public.gmane.org>
2009-11-06 6:30 ` Rusty Russell
2009-11-05 6:01 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200911051658.36265.rusty@rustcorp.com.au \
--to=rusty@rustcorp.com.au \
--cc=JBeulich@novell.com \
--cc=akpm@linux-foundation.org \
--cc=hollisb@us.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-next@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=sfr@canb.auug.org.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).