* [PATCH] eliminate warnings in generated module files
@ 2003-02-19 2:43 Richard Henderson
2003-02-19 3:29 ` Linus Torvalds
2003-02-25 4:32 ` Rusty Russell
0 siblings, 2 replies; 23+ messages in thread
From: Richard Henderson @ 2003-02-19 2:43 UTC (permalink / raw)
To: torvalds, rusty; +Cc: linux-kernel
The compiler.h fragment should describe the problem well enough.
r~
===== include/linux/compiler.h 1.10 vs edited =====
--- 1.10/include/linux/compiler.h Tue Dec 31 15:10:18 2002
+++ edited/include/linux/compiler.h Tue Feb 18 17:39:38 2003
@@ -25,6 +25,23 @@
#define __deprecated
#endif
+/*
+ * Allow us to avoid 'defined but not used' warnings on functions and data,
+ * as well as force them to be emitted to the assembly file.
+ *
+ * As of gcc 3.3, static functions that are not marked with attribute((used))
+ * may be elided from the assembly file. As of gcc 3.3, static data not so
+ * marked will not be elided, but this may change in a future gcc version.
+ *
+ * In prior versions of gcc, such functions and data would be emitted, but
+ * would be warned about except with attribute((unused)).
+ */
+#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
+#define __attribute_used__ __attribute__((__used__))
+#else
+#define __attribute_used__ __attribute__((__unused__))
+#endif
+
/* This macro obfuscates arithmetic on a variable address so that gcc
shouldn't recognize the original var, and make assumptions about it */
#define RELOC_HIDE(ptr, off) \
===== scripts/modpost.c 1.7 vs edited =====
--- 1.7/scripts/modpost.c Sun Feb 16 17:42:07 2003
+++ edited/scripts/modpost.c Tue Feb 18 17:41:54 2003
@@ -384,6 +384,7 @@
{
buf_printf(b, "#include <linux/module.h>\n");
buf_printf(b, "#include <linux/vermagic.h>\n");
+ buf_printf(b, "#include <linux/compiler.h>\n");
buf_printf(b, "\n");
buf_printf(b, "const char vermagic[]\n");
buf_printf(b, "__attribute__((section(\"__vermagic\"))) =\n");
@@ -449,6 +450,7 @@
buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n");
+ buf_printf(b, "__attribute_used__\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 2:43 [PATCH] eliminate warnings in generated module files Richard Henderson
@ 2003-02-19 3:29 ` Linus Torvalds
2003-02-19 3:43 ` Richard Henderson
2003-02-25 4:32 ` Rusty Russell
1 sibling, 1 reply; 23+ messages in thread
From: Linus Torvalds @ 2003-02-19 3:29 UTC (permalink / raw)
To: Richard Henderson; +Cc: rusty, linux-kernel
On Tue, 18 Feb 2003, Richard Henderson wrote:
>
> The compiler.h fragment should describe the problem well enough.
Have you tested this with older compilers?
In particular, I have this dim memory of gcc historically not liking
multiple separate __attribute__ bits, ie
__attribute__((unused,__section__ ...))
would be fine, but
__attribute__((unused)) __attribute__((__section__ ...))
would not compile.
But hey, my brain is cabbage, and my memory might be crap.
Linus
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 3:29 ` Linus Torvalds
@ 2003-02-19 3:43 ` Richard Henderson
2003-02-19 5:16 ` Linus Torvalds
0 siblings, 1 reply; 23+ messages in thread
From: Richard Henderson @ 2003-02-19 3:43 UTC (permalink / raw)
To: Linus Torvalds; +Cc: rusty, linux-kernel
On Tue, Feb 18, 2003 at 07:29:15PM -0800, Linus Torvalds wrote:
> Have you tested this with older compilers?
Nope.
> In particular, I have this dim memory of gcc historically not liking
> multiple separate __attribute__ bits, ie
>
> __attribute__((unused,__section__ ...))
>
> would be fine, but
>
> __attribute__((unused)) __attribute__((__section__ ...))
>
> would not compile.
>
> But hey, my brain is cabbage, and my memory might be crap.
Hmm. It was always supposed to have worked, but I suppose
there could have been bugs. How far back to I need to go
looking?
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 3:43 ` Richard Henderson
@ 2003-02-19 5:16 ` Linus Torvalds
2003-02-19 6:16 ` Richard Henderson
2003-02-19 23:41 ` Chris Wedgwood
0 siblings, 2 replies; 23+ messages in thread
From: Linus Torvalds @ 2003-02-19 5:16 UTC (permalink / raw)
To: Richard Henderson; +Cc: rusty, linux-kernel
On Tue, 18 Feb 2003, Richard Henderson wrote:
> >
> > But hey, my brain is cabbage, and my memory might be crap.
>
> Hmm. It was always supposed to have worked, but I suppose
> there could have been bugs. How far back to I need to go
> looking?
Some people are still using 2.95, I think anything past that is long since
unsupported and not worth worrying about.
Linus
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 5:16 ` Linus Torvalds
@ 2003-02-19 6:16 ` Richard Henderson
2003-02-19 20:11 ` Kai Germaschewski
2003-02-20 0:01 ` Rusty Russell
2003-02-19 23:41 ` Chris Wedgwood
1 sibling, 2 replies; 23+ messages in thread
From: Richard Henderson @ 2003-02-19 6:16 UTC (permalink / raw)
To: Linus Torvalds; +Cc: rusty, linux-kernel
On Tue, Feb 18, 2003 at 09:16:35PM -0800, Linus Torvalds wrote:
> Some people are still using 2.95, I think anything past that is long since
> unsupported and not worth worrying about.
[kanga:~] cat z.c
static char foo []
__attribute__((unused))
__attribute__((section(".data.foo")))
= "asdfasdf";
[kanga:~] /usr/bin/gcc -Wall -c z.c
[kanga:~] /usr/bin/gcc -v
Reading specs from /usr/lib/gcc-lib/alpha-linux/2.95.4/specs
gcc version 2.95.4 20011002 (Debian prerelease)
[kanga:~] objdump -h z.o | grep foo
3 .data.foo 00000009 0000000000000000 0000000000000000 00000040 2**0
Seems to work, both wrt the warning message and
honoring the section directive.
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 6:16 ` Richard Henderson
@ 2003-02-19 20:11 ` Kai Germaschewski
2003-02-19 21:05 ` Richard Henderson
2003-02-20 0:01 ` Rusty Russell
1 sibling, 1 reply; 23+ messages in thread
From: Kai Germaschewski @ 2003-02-19 20:11 UTC (permalink / raw)
To: Richard Henderson; +Cc: Linus Torvalds, rusty, linux-kernel
On Tue, 18 Feb 2003, Richard Henderson wrote:
> On Tue, Feb 18, 2003 at 09:16:35PM -0800, Linus Torvalds wrote:
> > Some people are still using 2.95, I think anything past that is long since
> > unsupported and not worth worrying about.
I tried egcs-2.91.66 (not sure if the sparc people are still using that?),
looks ok.
I merged the patch into my kbuild tree.
However, I'm not quite happy with "__attribute_used__".
Other examples of similar defines:
__deprecated
__init
__exit
So what about "__used" ? Admittedly, it's a bit short, but I like it
better anyhow.
--Kai
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 20:11 ` Kai Germaschewski
@ 2003-02-19 21:05 ` Richard Henderson
0 siblings, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2003-02-19 21:05 UTC (permalink / raw)
To: Kai Germaschewski; +Cc: Linus Torvalds, rusty, linux-kernel
On Wed, Feb 19, 2003 at 02:11:29PM -0600, Kai Germaschewski wrote:
> So what about "__used" ? Admittedly, it's a bit short, but I like it
> better anyhow.
I don't really like it, but don't care that much.
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 5:16 ` Linus Torvalds
2003-02-19 6:16 ` Richard Henderson
@ 2003-02-19 23:41 ` Chris Wedgwood
1 sibling, 0 replies; 23+ messages in thread
From: Chris Wedgwood @ 2003-02-19 23:41 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Richard Henderson, rusty, linux-kernel
On Tue, Feb 18, 2003 at 09:16:35PM -0800, Linus Torvalds wrote:
> Some people are still using 2.95, I think anything past that is long
> since unsupported and not worth worrying about.
I've recently started using 3.2 for testing and it seems, thus far, so
worse than 2.95.x and appears to have fewer bugs in some regards
(i.e. don't seem to go bonkers with register pressure form long long).
At some point, 2.95.x might be considered too old and gcc 3.2+ with
have to be the minimum --- is this time near?
What about MIPS and Sparc64 --- are they still using ancient
compilers?
--cw
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 6:16 ` Richard Henderson
2003-02-19 20:11 ` Kai Germaschewski
@ 2003-02-20 0:01 ` Rusty Russell
1 sibling, 0 replies; 23+ messages in thread
From: Rusty Russell @ 2003-02-20 0:01 UTC (permalink / raw)
To: Richard Henderson; +Cc: linux-kernel, torvalds, Kai Germaschewski
In message <20030218221656.A23989@twiddle.net> you write:
> gcc version 2.95.4 20011002 (Debian prerelease)
>
> Seems to work, both wrt the warning message and
> honoring the section directive.
Excellent. For Linus's (and Kai's) benefit, this is Richard's patch
again. Thanks Richard!
From: Richard Henderson <rth@twiddle.net>
===== include/linux/compiler.h 1.10 vs edited =====
--- 1.10/include/linux/compiler.h Tue Dec 31 15:10:18 2002
+++ edited/include/linux/compiler.h Tue Feb 18 17:39:38 2003
@@ -25,6 +25,23 @@
#define __deprecated
#endif
+/*
+ * Allow us to avoid 'defined but not used' warnings on functions and data,
+ * as well as force them to be emitted to the assembly file.
+ *
+ * As of gcc 3.3, static functions that are not marked with attribute((used))
+ * may be elided from the assembly file. As of gcc 3.3, static data not so
+ * marked will not be elided, but this may change in a future gcc version.
+ *
+ * In prior versions of gcc, such functions and data would be emitted, but
+ * would be warned about except with attribute((unused)).
+ */
+#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
+#define __attribute_used__ __attribute__((__used__))
+#else
+#define __attribute_used__ __attribute__((__unused__))
+#endif
+
/* This macro obfuscates arithmetic on a variable address so that gcc
shouldn't recognize the original var, and make assumptions about it */
#define RELOC_HIDE(ptr, off) \
===== scripts/modpost.c 1.7 vs edited =====
--- 1.7/scripts/modpost.c Sun Feb 16 17:42:07 2003
+++ edited/scripts/modpost.c Tue Feb 18 17:41:54 2003
@@ -384,6 +384,7 @@
{
buf_printf(b, "#include <linux/module.h>\n");
buf_printf(b, "#include <linux/vermagic.h>\n");
+ buf_printf(b, "#include <linux/compiler.h>\n");
buf_printf(b, "\n");
buf_printf(b, "const char vermagic[]\n");
buf_printf(b, "__attribute__((section(\"__vermagic\"))) =\n");
@@ -449,6 +450,7 @@
buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n");
+ buf_printf(b, "__attribute_used__\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-19 2:43 [PATCH] eliminate warnings in generated module files Richard Henderson
2003-02-19 3:29 ` Linus Torvalds
@ 2003-02-25 4:32 ` Rusty Russell
2003-02-25 7:58 ` Richard Henderson
1 sibling, 1 reply; 23+ messages in thread
From: Rusty Russell @ 2003-02-25 4:32 UTC (permalink / raw)
To: Richard Henderson; +Cc: linux-kernel, torvalds, Kai Germaschewski
In message <20030218184317.A20436@twiddle.net> you write:
> +#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
> +#define __attribute_used__ __attribute__((__used__))
> +#else
> +#define __attribute_used__ __attribute__((__unused__))
> +#endif
> +
After some thought, I prefer __optional. The unused attribute has
muddied the waters too badly for "used" or "unused" to be clear.
We could debate this for days. Linus, apply or don't.
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: __optional attribute
Author: Rusty Russell
Status: Trivial
D: Renames __attribute_used to __optional.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .21098-linux-2.5.63/include/linux/compiler.h .21098-linux-2.5.63.updated/include/linux/compiler.h
--- .21098-linux-2.5.63/include/linux/compiler.h 2003-02-25 10:11:08.000000000 +1100
+++ .21098-linux-2.5.63.updated/include/linux/compiler.h 2003-02-25 15:28:39.000000000 +1100
@@ -37,9 +37,9 @@
* would be warned about except with attribute((unused)).
*/
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
-#define __attribute_used__ __attribute__((__used__))
+#define __optional __attribute__((__used__))
#else
-#define __attribute_used__ __attribute__((__unused__))
+#define __optional __attribute__((__unused__))
#endif
/* This macro obfuscates arithmetic on a variable address so that gcc
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .21098-linux-2.5.63/scripts/modpost.c .21098-linux-2.5.63.updated/scripts/modpost.c
--- .21098-linux-2.5.63/scripts/modpost.c 2003-02-25 10:11:14.000000000 +1100
+++ .21098-linux-2.5.63.updated/scripts/modpost.c 2003-02-25 15:30:37.000000000 +1100
@@ -450,7 +450,7 @@ add_depends(struct buffer *b, struct mod
buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n");
- buf_printf(b, "__attribute_used__\n");
+ buf_printf(b, "__optional\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-25 4:32 ` Rusty Russell
@ 2003-02-25 7:58 ` Richard Henderson
2003-02-25 11:39 ` Rusty Russell
2003-02-25 21:42 ` Chris Wedgwood
0 siblings, 2 replies; 23+ messages in thread
From: Richard Henderson @ 2003-02-25 7:58 UTC (permalink / raw)
To: Rusty Russell; +Cc: linux-kernel, torvalds, Kai Germaschewski
On Tue, Feb 25, 2003 at 03:32:21PM +1100, Rusty Russell wrote:
> In message <20030218184317.A20436@twiddle.net> you write:
> > +#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
> > +#define __attribute_used__ __attribute__((__used__))
> > +#else
> > +#define __attribute_used__ __attribute__((__unused__))
> > +#endif
> > +
>
> After some thought, I prefer __optional.
Um, "optional" does not in any way accurately describe attribute used.
In fact, it means almost exactly the opposite.
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-25 7:58 ` Richard Henderson
@ 2003-02-25 11:39 ` Rusty Russell
2003-02-25 23:47 ` Linus Torvalds
2003-02-25 21:42 ` Chris Wedgwood
1 sibling, 1 reply; 23+ messages in thread
From: Rusty Russell @ 2003-02-25 11:39 UTC (permalink / raw)
To: Richard Henderson; +Cc: linux-kernel, torvalds, Kai Germaschewski
In message <20030224235829.A12782@twiddle.net> you write:
> On Tue, Feb 25, 2003 at 03:32:21PM +1100, Rusty Russell wrote:
> > After some thought, I prefer __optional.
>
> Um, "optional" does not in any way accurately describe attribute used.
> In fact, it means almost exactly the opposite.
Yep.
__optional should always be __attribute__((__unused__)), and
__required should be your __attribute_used__.
This one makes more sense to the user, I think:
/* May not be used depending on config options */
static ctl_table ip_conntrack_table[] __optional = { ...
/* Must be in binary for strings to find */
static char version_string[] = "Version foo.c 1.2.3" __required;
Thoughts?
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
Name: __optional attribute
Author: Rusty Russell
Status: Trivial
D: Renames __attribute_used to __required, and introduces __optional.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .25651-linux-2.5.63/include/linux/compiler.h .25651-linux-2.5.63.updated/include/linux/compiler.h
--- .25651-linux-2.5.63/include/linux/compiler.h 2003-02-25 10:11:08.000000000 +1100
+++ .25651-linux-2.5.63.updated/include/linux/compiler.h 2003-02-25 22:34:49.000000000 +1100
@@ -37,10 +37,11 @@
* would be warned about except with attribute((unused)).
*/
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
-#define __attribute_used__ __attribute__((__used__))
+#define __required __attribute__((__used__))
#else
-#define __attribute_used__ __attribute__((__unused__))
+#define __required __attribute__((__unused__))
#endif
+#define __optional __attribute__((__unused__))
/* This macro obfuscates arithmetic on a variable address so that gcc
shouldn't recognize the original var, and make assumptions about it */
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .25651-linux-2.5.63/scripts/modpost.c .25651-linux-2.5.63.updated/scripts/modpost.c
--- .25651-linux-2.5.63/scripts/modpost.c 2003-02-25 10:11:14.000000000 +1100
+++ .25651-linux-2.5.63.updated/scripts/modpost.c 2003-02-25 22:34:10.000000000 +1100
@@ -450,7 +450,7 @@ add_depends(struct buffer *b, struct mod
buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n");
- buf_printf(b, "__attribute_used__\n");
+ buf_printf(b, "__optional\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-25 7:58 ` Richard Henderson
2003-02-25 11:39 ` Rusty Russell
@ 2003-02-25 21:42 ` Chris Wedgwood
1 sibling, 0 replies; 23+ messages in thread
From: Chris Wedgwood @ 2003-02-25 21:42 UTC (permalink / raw)
To: Rusty Russell, linux-kernel, torvalds, Kai Germaschewski
On Mon, Feb 24, 2003 at 11:58:29PM -0800, Richard Henderson wrote:
> Um, "optional" does not in any way accurately describe attribute
> used. In fact, it means almost exactly the opposite.
ironically the same could be said for "used" and "unused" ...
--cw
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-25 11:39 ` Rusty Russell
@ 2003-02-25 23:47 ` Linus Torvalds
2003-02-26 1:22 ` Rusty Russell
0 siblings, 1 reply; 23+ messages in thread
From: Linus Torvalds @ 2003-02-25 23:47 UTC (permalink / raw)
To: Rusty Russell; +Cc: Richard Henderson, linux-kernel, Kai Germaschewski
On Tue, 25 Feb 2003, Rusty Russell wrote:
>
> __optional should always be __attribute__((__unused__)), and
> __required should be your __attribute_used__.
But I think rth's point was that "__module_depends" should definitely
_not_ be "optional", since that just means that the compiler can (and
will) optimize away the whole thing.
So marking it optional is definitely the wrong thing to do.
Linus
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-25 23:47 ` Linus Torvalds
@ 2003-02-26 1:22 ` Rusty Russell
2003-02-26 1:36 ` Kai Germaschewski
2003-02-26 3:35 ` Randy.Dunlap
0 siblings, 2 replies; 23+ messages in thread
From: Rusty Russell @ 2003-02-26 1:22 UTC (permalink / raw)
To: Linus Torvalds; +Cc: Richard Henderson, linux-kernel, Kai Germaschewski
In message <Pine.LNX.4.44.0302251546590.2185-100000@home.transmeta.com> you wri
te:
>
> On Tue, 25 Feb 2003, Rusty Russell wrote:
> >
> > __optional should always be __attribute__((__unused__)), and
> > __required should be your __attribute_used__.
>
> But I think rth's point was that "__module_depends" should definitely
> _not_ be "optional", since that just means that the compiler can (and
> will) optimize away the whole thing.
>
> So marking it optional is definitely the wrong thing to do.
This time for sure!
Name: __optional attribute
Author: Rusty Russell
Status: Trivial
D: Renames __attribute_used to __required, and introduces __optional.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .25651-linux-2.5.63/include/linux/compiler.h .25651-linux-2.5.63.updated/include/linux/compiler.h
--- .25651-linux-2.5.63/include/linux/compiler.h 2003-02-25 10:11:08.000000000 +1100
+++ .25651-linux-2.5.63.updated/include/linux/compiler.h 2003-02-25 22:34:49.000000000 +1100
@@ -37,10 +37,11 @@
* would be warned about except with attribute((unused)).
*/
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
-#define __attribute_used__ __attribute__((__used__))
+#define __required __attribute__((__used__))
#else
-#define __attribute_used__ __attribute__((__unused__))
+#define __required __attribute__((__unused__))
#endif
+#define __optional __attribute__((__unused__))
/* This macro obfuscates arithmetic on a variable address so that gcc
shouldn't recognize the original var, and make assumptions about it */
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .25651-linux-2.5.63/scripts/modpost.c .25651-linux-2.5.63.updated/scripts/modpost.c
--- .25651-linux-2.5.63/scripts/modpost.c 2003-02-25 10:11:14.000000000 +1100
+++ .25651-linux-2.5.63.updated/scripts/modpost.c 2003-02-25 22:34:10.000000000 +1100
@@ -450,7 +450,7 @@ add_depends(struct buffer *b, struct mod
buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n");
- buf_printf(b, "__attribute_used__\n");
+ buf_printf(b, "__required\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-26 1:22 ` Rusty Russell
@ 2003-02-26 1:36 ` Kai Germaschewski
2003-02-26 4:13 ` Rusty Russell
2003-02-26 3:35 ` Randy.Dunlap
1 sibling, 1 reply; 23+ messages in thread
From: Kai Germaschewski @ 2003-02-26 1:36 UTC (permalink / raw)
To: Rusty Russell; +Cc: Linus Torvalds, Richard Henderson, linux-kernel
On Wed, 26 Feb 2003, Rusty Russell wrote:
> In message <Pine.LNX.4.44.0302251546590.2185-100000@home.transmeta.com> you wri
> te:
> >
> > On Tue, 25 Feb 2003, Rusty Russell wrote:
> > >
> > > __optional should always be __attribute__((__unused__)), and
> > > __required should be your __attribute_used__.
> >
> > But I think rth's point was that "__module_depends" should definitely
> > _not_ be "optional", since that just means that the compiler can (and
> > will) optimize away the whole thing.
> >
> > So marking it optional is definitely the wrong thing to do.
>
> This time for sure!
FWIW, I think it's not a good idea. Why call it 'required' in the kernel
when the normal (gcc) expression for it is 'used'. - We didn't rename
'deprecated' to 'obsolete', either ;)
Also, I don't really see any use for __optional at this point, so why add
it at all?
So IMO, the only change which possibly makes sense is to rename
__attribute_used__ to __used, since it makes it more consistent with
similar things like __deprecated, __init, __exit etc.
--Kai
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
@ 2003-02-26 2:23 Milton D. Miller II
0 siblings, 0 replies; 23+ messages in thread
From: Milton D. Miller II @ 2003-02-26 2:23 UTC (permalink / raw)
To: linux-kernel
On Tue, 25 Feb 2003, Rusty Russell wrote:
>
> __optional should always be __attribute__((__unused__)), and
> __required should be your __attribute_used__.
How about __keep or __needed ?
milton
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-26 1:22 ` Rusty Russell
2003-02-26 1:36 ` Kai Germaschewski
@ 2003-02-26 3:35 ` Randy.Dunlap
2003-02-26 4:08 ` Rusty Russell
1 sibling, 1 reply; 23+ messages in thread
From: Randy.Dunlap @ 2003-02-26 3:35 UTC (permalink / raw)
To: rusty; +Cc: torvalds, rth, linux-kernel, kai
> In message <Pine.LNX.4.44.0302251546590.2185-100000@home.transmeta.com> you
> wri te:
>>
>> On Tue, 25 Feb 2003, Rusty Russell wrote:
>> >
>> > __optional should always be __attribute__((__unused__)), and
>> > __required should be your __attribute_used__.
>>
>> But I think rth's point was that "__module_depends" should definitely
>> _not_ be "optional", since that just means that the compiler can (and
>> will) optimize away the whole thing.
>>
>> So marking it optional is definitely the wrong thing to do.
>
> This time for sure!
>
> Name: __optional attribute
> Author: Rusty Russell
> Status: Trivial
I have to agree with Kai and Milton Miller on this (bad) naming.
__required and __optional don't generate the corrent connotations
of what is being attempted here.
Milton suggesting spelling __attribute_used__ as __keep or
__needed. I prefer __attribute_used__, but something like
__mark_as_used__ would be OK too.
And what uses __optional, however it is spelled?
Thanks,
~Randy
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-26 3:35 ` Randy.Dunlap
@ 2003-02-26 4:08 ` Rusty Russell
2003-02-26 13:45 ` Werner Almesberger
0 siblings, 1 reply; 23+ messages in thread
From: Rusty Russell @ 2003-02-26 4:08 UTC (permalink / raw)
To: Randy.Dunlap; +Cc: torvalds, rth, linux-kernel, kai, Milton D. Miller II
In message <1707.4.64.238.61.1046230558.squirrel@www.osdl.org> you write:
> I have to agree with Kai and Milton Miller on this (bad) naming.
> __required and __optional don't generate the corrent connotations
> of what is being attempted here.
The problem with "used" is that you're saying "compiler, treat this as
used, so you don't discard it".
The level of indirection seems completely natural to compiler people,
but as a coder I just want to say "don't discard this", hence "__keep"
is good.
OTOH, __optional is fairly clearly "you can drop it". "Unused" is
clearly a lie for some configurations.
Here's Take III:
Name: __keep and __optional attributes
Author: Rusty Russell
Status: Trivial
D: Renames __attribute_used to __keep, and introduces __optional.
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .25651-linux-2.5.63/include/linux/compiler.h .25651-linux-2.5.63.updated/include/linux/compiler.h
--- .25651-linux-2.5.63/include/linux/compiler.h 2003-02-25 10:11:08.000000000 +1100
+++ .25651-linux-2.5.63.updated/include/linux/compiler.h 2003-02-25 22:34:49.000000000 +1100
@@ -37,10 +37,11 @@
* would be warned about except with attribute((unused)).
*/
#if __GNUC__ == 3 && __GNUC_MINOR__ >= 3 || __GNUC__ > 3
-#define __attribute_used__ __attribute__((__used__))
+#define __keep __attribute__((__used__))
#else
-#define __attribute_used__ __attribute__((__unused__))
+#define __keep __attribute__((__unused__))
#endif
+#define __optional __attribute__((__unused__))
/* This macro obfuscates arithmetic on a variable address so that gcc
shouldn't recognize the original var, and make assumptions about it */
diff -urpN --exclude TAGS -X /home/rusty/devel/kernel/kernel-patches/current-dontdiff --minimal .25651-linux-2.5.63/scripts/modpost.c .25651-linux-2.5.63.updated/scripts/modpost.c
--- .25651-linux-2.5.63/scripts/modpost.c 2003-02-25 10:11:14.000000000 +1100
+++ .25651-linux-2.5.63.updated/scripts/modpost.c 2003-02-25 22:34:10.000000000 +1100
@@ -450,7 +450,7 @@ add_depends(struct buffer *b, struct mod
buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n");
- buf_printf(b, "__attribute_used__\n");
+ buf_printf(b, "__keep\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-26 1:36 ` Kai Germaschewski
@ 2003-02-26 4:13 ` Rusty Russell
2003-02-26 17:02 ` Horst von Brand
2003-02-26 17:04 ` Richard Henderson
0 siblings, 2 replies; 23+ messages in thread
From: Rusty Russell @ 2003-02-26 4:13 UTC (permalink / raw)
To: Kai Germaschewski; +Cc: Linus Torvalds, Richard Henderson, linux-kernel
In message <Pine.LNX.4.44.0302251930280.13501-100000@chaos.physics.uiowa.edu> y
ou write:
> FWIW, I think it's not a good idea. Why call it 'required' in the kernel
> when the normal (gcc) expression for it is 'used'. - We didn't rename
> 'deprecated' to 'obsolete', either ;)
But deprecated was a fine name. "used" is a terrible name, and since
we're renaming it via a macro anyway... (see "likey").
> Also, I don't really see any use for __optional at this point, so why add
> it at all?
>From ip_conntrack_core.c:
#ifdef CONFIG_SYSCTL
static struct ctl_table_header *ip_conntrack_sysctl_header;
static ctl_table ip_conntrack_table[] = {
{
.ctl_name = NET_IP_CONNTRACK_MAX,
.procname = NET_IP_CONNTRACK_MAX_NAME,
.data = &ip_conntrack_max,
.maxlen = sizeof(ip_conntrack_max),
.mode = 0644,
.proc_handler = proc_dointvec
},
{ .ctl_name = 0 }
};
static ctl_table ip_conntrack_dir_table[] = {
{
.ctl_name = NET_IPV4,
.procname = "ipv4",
.maxlen = 0,
.mode = 0555,
.child = ip_conntrack_table
},
{ .ctl_name = 0 }
};
static ctl_table ip_conntrack_root_table[] = {
{
.ctl_name = CTL_NET,
.procname = "net",
.maxlen = 0,
.mode = 0555,
.child = ip_conntrack_dir_table
},
{ .ctl_name = 0 }
};
#endif /*CONFIG_SYSCTL*/
I'd love to frop the #ifdef and just mark them __optional: before that
would just mean bloat, but when gcc 3.3 rolls in, they should vanish
nicely.
There are numerous other examples...
Rusty.
--
Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-26 4:08 ` Rusty Russell
@ 2003-02-26 13:45 ` Werner Almesberger
0 siblings, 0 replies; 23+ messages in thread
From: Werner Almesberger @ 2003-02-26 13:45 UTC (permalink / raw)
To: Rusty Russell
Cc: Randy.Dunlap, torvalds, rth, linux-kernel, kai,
Milton D. Miller II
Rusty Russell wrote:
> OTOH, __optional is fairly clearly "you can drop it". "Unused" is
> clearly a lie for some configurations.
__maybe_unused ? :-)
- Werner
--
_________________________________________________________________________
/ Werner Almesberger, Buenos Aires, Argentina wa@almesberger.net /
/_http://www.almesberger.net/____________________________________________/
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-26 4:13 ` Rusty Russell
@ 2003-02-26 17:02 ` Horst von Brand
2003-02-26 17:04 ` Richard Henderson
1 sibling, 0 replies; 23+ messages in thread
From: Horst von Brand @ 2003-02-26 17:02 UTC (permalink / raw)
To: Rusty Russell; +Cc: Linux Kernel Mailing List
> In message
> <Pine.LNX.4.44.0302251930280.13501-100000@chaos.physics.uiowa.edu> you
> write:
[...]
> > Also, I don't really see any use for __optional at this point, so why add
> > it at all?
> >From ip_conntrack_core.c:
> #ifdef CONFIG_SYSCTL
> [snipped largeish data structure]
> #endif /*CONFIG_SYSCTL*/
>
> I'd love to frop the #ifdef and just mark them __optional: before that
> would just mean bloat, but when gcc 3.3 rolls in, they should vanish
> nicely.
If gcc will just discard it, why bother marking it specially? Unless it
gives ugly warnings, that is.
--
Dr. Horst H. von Brand User #22616 counter.li.org
Departamento de Informatica Fono: +56 32 654431
Universidad Tecnica Federico Santa Maria +56 32 654239
Casilla 110-V, Valparaiso, Chile Fax: +56 32 797513
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH] eliminate warnings in generated module files
2003-02-26 4:13 ` Rusty Russell
2003-02-26 17:02 ` Horst von Brand
@ 2003-02-26 17:04 ` Richard Henderson
1 sibling, 0 replies; 23+ messages in thread
From: Richard Henderson @ 2003-02-26 17:04 UTC (permalink / raw)
To: Rusty Russell; +Cc: Kai Germaschewski, Linus Torvalds, linux-kernel
On Wed, Feb 26, 2003 at 03:13:09PM +1100, Rusty Russell wrote:
> I'd love to frop the #ifdef and just mark them __optional: before that
> would just mean bloat, but when gcc 3.3 rolls in, they should vanish
> nicely.
Um, no, as mentioned in the comment, at present only unused
static functions will get removed. Data isn't touched, yet.
r~
^ permalink raw reply [flat|nested] 23+ messages in thread
end of thread, other threads:[~2003-02-26 16:54 UTC | newest]
Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-02-19 2:43 [PATCH] eliminate warnings in generated module files Richard Henderson
2003-02-19 3:29 ` Linus Torvalds
2003-02-19 3:43 ` Richard Henderson
2003-02-19 5:16 ` Linus Torvalds
2003-02-19 6:16 ` Richard Henderson
2003-02-19 20:11 ` Kai Germaschewski
2003-02-19 21:05 ` Richard Henderson
2003-02-20 0:01 ` Rusty Russell
2003-02-19 23:41 ` Chris Wedgwood
2003-02-25 4:32 ` Rusty Russell
2003-02-25 7:58 ` Richard Henderson
2003-02-25 11:39 ` Rusty Russell
2003-02-25 23:47 ` Linus Torvalds
2003-02-26 1:22 ` Rusty Russell
2003-02-26 1:36 ` Kai Germaschewski
2003-02-26 4:13 ` Rusty Russell
2003-02-26 17:02 ` Horst von Brand
2003-02-26 17:04 ` Richard Henderson
2003-02-26 3:35 ` Randy.Dunlap
2003-02-26 4:08 ` Rusty Russell
2003-02-26 13:45 ` Werner Almesberger
2003-02-25 21:42 ` Chris Wedgwood
-- strict thread matches above, loose matches on Subject: below --
2003-02-26 2:23 Milton D. Miller II
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox