Re: linux-next: build failure

Previous thread: [PATCH 4/4] Add kernel doc for the completion, fix kernel-doc-nano-HOWTO.txt by Kevin Diggs on Monday, August 25, 2008 - 4:25 am. (4 messages)

Next thread: by ohyama_sec on Monday, August 25, 2008 - 4:40 am. (1 message)
From: Stephen Rothwell
Date: Monday, August 25, 2008 - 4:28 am

Hi Ingo,

Today's linux-next build (sparc64 defconfig) failed like this:

ERROR: "__BUILD_BUG_ON_non_constant" [drivers/net/sunvnet.ko] undefined!
ERROR: "__BUILD_BUG_ON_non_constant" [drivers/block/sunvdc.ko] undefined!

Probably intorduced by commit f5b5d41dd51a31fe70e3a04fb80a3b90b84c6a4e
("debug: fix BUILD_BUG_ON() for non-constant expressions").

The preprocessed code looks like this:

static inline __attribute__((always_inline)) u32 vio_dring_avail(struct vio_dring_state *dr,
      unsigned int ring_size)
{
 do { (void)sizeof(char[1 - 2*!!(!is_power_of_2(ring_size))]); if (!__builtin_constant_p(!is_power_of_2(ring_size))) __BUILD_BUG_ON_non_constant++; } while (0);

 return (dr->pending -
  ((dr->prod - dr->cons) & (ring_size - 1)));
}

I tried turning the above inline function into a macro to no avail.

I applied the following patch (which is probably not what is wanted, but
puts back what was there before).

I see from LKML that this definition of BUILD_BUG_ON is to be replaced,
so this is just a temporary measure.

-- 
Cheers,
Stephen Rothwell                    sfr@canb.auug.org.au
http://www.canb.auug.org.au/~sfr/

From: Stephen Rothwell <sfr@canb.auug.org.au>
Date: Mon, 25 Aug 2008 21:16:14 +1000
Subject: [PATCH] revert BUILD_BUG_ON change

Signed-off-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 include/linux/compiler.h |    6 ------
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/include/linux/compiler.h b/include/linux/compiler.h
index d7d313b..a1c082d 100644
--- a/include/linux/compiler.h
+++ b/include/linux/compiler.h
@@ -206,15 +206,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
  * ( The linker trick relies on gcc optimizing out a multiplication with
  *   constant zero - which should be reasonable enough. )
  */
-#ifndef __ASSEMBLY__
-extern unsigned int __BUILD_BUG_ON_non_constant;
-#endif
-
 #define BUILD_BUG_ON(condition)					\
 do {								\
 	(void)sizeof(char[1 - 2*!!(condition)]);		\
-	if ...
From: Ingo Molnar
Date: Monday, August 25, 2008 - 5:40 am

yeah. Note that it will only be stricter, so more fallout is expected.

	Ingo
--

From: David Miller
Date: Thursday, August 28, 2008 - 12:40 am

From: Stephen Rothwell <sfr@canb.auug.org.au>

I think __builtin_constant_p() is not seeing something it
should here.

It isn't accepting:

--------------------
static inline __attribute__((const))
bool is_power_of_2(unsigned long n)
{
	return (n != 0 && ((n & (n - 1)) == 0));
}
--------------------

and thus is_power_of_2(256) as being a constant.

If a 'const' inline function being passed a const argument isn't
constant, what is! :-)

I bet the problem is the fact that is_power_of_2() is a function.

I did some tests and I can only trigger this problem with gcc-3.4 on
sparc, gcc-4.1 and gcc-4.2 worked fine.

It triggers with both -O2 and -Os for the following simple test case:

static inline __attribute__((const))
int is_power_of_2(unsigned long n)
{
	return (n != 0 && ((n & (n - 1)) == 0));
}

extern int bar;

int main(void)
{
	if (!__builtin_constant_p(is_power_of_2(256)))
		bar++;
	return 0;
}

davem@sunset:~/src/GIT/linux-2.6$ gcc-3.4  -Os -o x x.c
/tmp/ccy8FzD8.o: In function `main':
x.c:(.text+0x0): undefined reference to `bar'
x.c:(.text+0x4): undefined reference to `bar'
x.c:(.text+0xc): undefined reference to `bar'
collect2: ld returned 1 exit status
davem@sunset:~/src/GIT/linux-2.6$ gcc-3.4  -O2 -o x x.c
/tmp/ccQNzZuj.o: In function `main':
x.c:(.text+0x0): undefined reference to `bar'
x.c:(.text+0x4): undefined reference to `bar'
x.c:(.text+0xc): undefined reference to `bar'
collect2: ld returned 1 exit status
davem@sunset:~/src/GIT/linux-2.6$ 
--

Previous thread: [PATCH 4/4] Add kernel doc for the completion, fix kernel-doc-nano-HOWTO.txt by Kevin Diggs on Monday, August 25, 2008 - 4:25 am. (4 messages)

Next thread: by ohyama_sec on Monday, August 25, 2008 - 4:40 am. (1 message)