Re: Patch backport request: __USE_GNU breaks uclibc in the 2.1 branch

2020-06-12 Thread William Lallemand
On Fri, Jun 12, 2020 at 12:54:26PM +0200, Chris wrote:
> http://git.haproxy.org/?p=haproxy.git;a=commit;h=62af9c83f9ed2b25e0061798e29e3cccfce5fbdc).
> 
> So in conclusion, my request is to backport Willy's change to the 2.1
> tree, please.
> 

Hello Chris,

I just backported it and pushed it in the 2.1 git.

Regards,

-- 
William Lallemand



Patch backport request: __USE_GNU breaks uclibc in the 2.1 branch

2020-06-12 Thread Chris
Hello everybody,

I am one of the maintainers of the haproxy package for the OpenWRT
project. I am reaching out to you because - as of HAProxy version
2.1.5 - we experience build-issues on some of our build-targets.
We mostly use MUSL and uclibc as our c-libraries because they are more
suitable for embedded devices which are our main focus. Since HAProxy
version 2.1.5, the build is broken for all of our uclibc-targets:

src/standard.c: In function 'dladdr_and_size':
src/standard.c:4356:8: warning: implicit declaration of function
'dladdr1'; did you mean 'dladdr'? [-Wimplicit-function-declaration]
  ret = dladdr1(addr, dli, (void **), RTLD_DL_SYMENT);
^~~
dladdr
src/standard.c:4356:42: error: 'RTLD_DL_SYMENT' undeclared (first use
in this function); did you mean 'DT_SYMENT'?
  ret = dladdr1(addr, dli, (void **), RTLD_DL_SYMENT);
  ^~
  DT_SYMENT
src/standard.c:4356:42: note: each undeclared identifier is reported
only once for each function it appears in



The problem lies in the #ifdef in src/standard.c:

static int dladdr_and_size(const void *addr, Dl_info *dli, size_t *size)
{
int ret;
#ifdef __USE_GNU // most detailed one
const ElfW(Sym) *sym;

ret = dladdr1(addr, dli, (void **), RTLD_DL_SYMENT);
if (ret)
*size = sym ? sym->st_size : 0;
#else
ret = dladdr(addr, dli);
*size = 0;
#endif
return ret;
}



Neither MUSL nor uclibc support dladdr1() so both must fall back to
using dladdr(). However, __USE_GNU is defined in uclibc making it use
dladdr1() resulting in the compilation failure. Using __USE_GNU is
generally not recommended so I wrote a patch which changed the #ifdef
to check for GLIBC. When I was preparing for submitting the patch for
the haproxy dev-branch I realized that Willy already did basically the
exact same thing there (here:
http://git.haproxy.org/?p=haproxy.git;a=commit;h=62af9c83f9ed2b25e0061798e29e3cccfce5fbdc).

So in conclusion, my request is to backport Willy's change to the 2.1
tree, please.

Thanks a lot,
Christian