DragonFly bugs List (threaded) for 2007-05
DragonFly BSD
DragonFly bugs List (threaded) for 2007-05
[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]

Re: acpi module failing to load in 1.9.0 preview #4?


From: YONETANI Tomokazu <qhwt+dfly@xxxxxxxxxx>
Date: Tue, 29 May 2007 23:42:49 +0900

On Tue, May 29, 2007 at 12:28:43PM +0200, Simon 'corecode' Schubert wrote:
> YONETANI Tomokazu wrote:
> >On Mon, May 28, 2007 at 11:56:27AM -0700, Matthew Dillon wrote:
> >>:Yup, adding back the static and removing the initialiser also fixed the 
> >>:problem.
> >>:
> >>:So my fault for building with GCC 4, contrary to the instructions.  :-)
> >>:
> >>:It's the only problem I've found so far, though (apart from a barrel 
> >>:load of warnings!).
> >But a question remains: why the asm code can't see a static variable
> >with initializer only when it's compiled with GCC4.1?
> 
> I just tried with the initializer and gcc41 and I can not reproduce this 
> problem.  Can we get some more data points?

I think I managed to reproduce this with a smaller code, if OP
has -O2 in his CFLAG (this is with gcc 4.0.1 on Mac OS X, so you need
to remove the extra underscores before function and variable names
to try it on DragonFly).

%%%%
$ cat a.c
#include <stdio.h>

static int foo = 1;
int get_foo(void);
__asm__("\n\
	.text				\n\
	.p2align 2, 0x90		\n\
_get_foo:				\n\
	movl	_foo,%eax		\n\
	movl	$1,_foo			\n\
	ret				\n\
");

int
main()
{
	printf("foo: %d\n", get_foo());
	return 0;
}
$ gcc -W -Wall a.c
a.c:3: warning: 'foo' defined but not used
$ gcc -O2 -W -Wall a.c
a.c:3: warning: 'foo' defined but not used
/usr/bin/ld: Undefined symbols:
_foo
collect2: ld returned 1 exit status
%%%%

Apparently gcc-4 has no idea(or no longer cares?) that __asm__() code
does modify foo and it happily optimized the variable away to a constant.

Cheers.



[Date Prev][Date Next]  [Thread Prev][Thread Next]  [Date Index][Thread Index]