Messages in this thread | | | Date | Wed, 23 Mar 2022 20:36:24 +0700 | Subject | Re: [PATCH 2/2] tools/nolibc/stdlib: only reference the external environ when inlined | From | Ammar Faizi <> |
| |
On 3/23/22 2:18 PM, Willy Tarreau wrote: > When building with gcc at -O0 we're seeing link errors due to the > "environ" variable being referenced by getenv(). The problem is that > at -O0 gcc will not inline getenv() and will not drop the external > reference. One solution would be to locally declare the variable as > weak, but then it would appear in all programs even those not using > it, and would be confusing to users of getenv() who would forget to > set environ to envp. > > An alternate approach used in this patch consists in always inlining > the outer part of getenv() that references this extern so that it's > always dropped when not used. The biggest part of the function was > now moved to a new function called _getenv() that's still not inlined > by default. > > Reported-by: Ammar Faizi <ammarfaizi2@gnuweeb.org> > Signed-off-by: Willy Tarreau <w@1wt.eu> > ---
This one works nicely. I will resend my previous RFC after this one lands in Paul's tree to avoid conflict.
Tested-by: Ammar Faizi <ammarfaizi2@gnuweeb.org>
Thanks!
-- Ammar Faizi
| |