Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools/nolibc/stdlib: only reference the external environ when inlined
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 <[email protected]> Signed-off-by: Willy Tarreau <[email protected]> Tested-by: Ammar Faizi <[email protected]> Signed-off-by: Paul E. McKenney <[email protected]>
- Loading branch information