[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <5b611ae8-aca6-71c1-6a86-6234f61f1608@gnuweeb.org>
Date: Wed, 23 Mar 2022 20:36:24 +0700
From: Ammar Faizi <ammarfaizi2@...weeb.org>
To: Willy Tarreau <w@....eu>, "Paul E . McKenney" <paulmck@...nel.org>
Cc: linux-kernel@...r.kernel.org
Subject: Re: [PATCH 2/2] tools/nolibc/stdlib: only reference the external
environ when inlined
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@...weeb.org>
> Signed-off-by: Willy Tarreau <w@....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@...weeb.org>
Thanks!
--
Ammar Faizi
Powered by blists - more mailing lists