Re: [PATCH] Make gcc3.3 Eliminate Unused Static Functions

From: Rusty Russell (rusty@rustcorp.com.au)
Date: Thu Jun 19 2003 - 21:28:36 EST


In message <20030619121732.GQ29247@fs.tum.de> you write:
> On Fri, Jun 13, 2003 at 11:03:43AM +1000, Rusty Russell wrote:
> > Argh, bogus line pasted into Makefile turned up in patch.
> >
> > This should be better...
> >...
> > +# Needs gcc 3.3 or above to understand max-inline-insns-auto.
> > +INLINE_OPTS := $(shell $(CC) -o /non/existent/file -c --param max-i
nline-insns-auto=0 -xc /dev/null 2>&1 | grep /non/existent/file >/dev/null && e
cho -finline-functions --param max-inline-insns-auto=0)
> >...
>
> You have to add a -Wno-unused-function or you'll get a warning for every
> eliminated function.

No, suppressing warnings like that would be bad. Instead, you write
functions like this:

        #ifdef CONFIG_FOO
        extern int register_foo(foo_fn myfunction);
        #else
        static inline int register_foo(foo_fn myfunction)
        {
                return 0;
        }
        #endif /* CONFIG_FOO */

That way, there's no unused warning, but gcc knows enough to discard
the function.

Hope that clarifies!
Rusty.

--
  Anyone who quotes me in their sig is an idiot. -- Rusty Russell.
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon Jun 23 2003 - 22:00:31 EST