varnishcache / pkg-varnish-cache

Package building scripts for official Debian and Redhat packages of Varnish Cache.
21 stars 30 forks source link

Ubuntu 22.04 package distributed by packagecloud is compiled without jemalloc (6.0 LTS) #159

Closed fabianonunes closed 1 year ago

fabianonunes commented 1 year ago

I'm not sure if this is the best channel to open this type of ticket. If it is not, could you please inform me of the most appropriate channel?

I have noticed that the Ubuntu 22.04 packages distributed by packagecloud were compiled without jemalloc support, while the Ubuntu 20.04 packages were. In both Jammy and Focal, the version of libjemalloc2 in the repositories is 5.2.1.

Output on Ubuntu 20.04:

root@0f697a782d62:/# ldd /usr/sbin/varnishd
    linux-vdso.so.1 (0x00007ffdc667f000)
    libjemalloc.so.2 => /lib/x86_64-linux-gnu/libjemalloc.so.2 (0x00007f3e22b72000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f3e22aff000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3e22af9000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3e229aa000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3e22987000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3e22795000)
    libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3e225b1000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3e22596000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f3e22f8f000)
root@0f697a782d62:/# MALLOC_CONF="inexistent_attr:true" varnishd -V
<jemalloc>: Invalid conf pair: inexistent_attr:true
varnishd (varnish-6.0.11 revision a3bc025c2df28e4a76e10c2c41217c9864e9963b)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2022 Varnish Software

Output on Ubuntu 22.04:

root@7a3fff002835:/# ldd /usr/sbin/varnishd
    linux-vdso.so.1 (0x00007fff87992000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f90498ad000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f90497c6000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f904959e000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f9049a6b000)
root@7a3fff002835:/# MALLOC_CONF="inexistent_attr:true" varnishd -V
varnishd (varnish-6.0.11 revision a3bc025c2df28e4a76e10c2c41217c9864e9963b)
Copyright (c) 2006 Verdens Gang AS
Copyright (c) 2006-2022 Varnish Software
fabianonunes commented 1 year ago

I've found out that the issue lies with the GCC flags -flto=auto -ffat-lto-objects, which became default in Ubuntu 21.04 and onwards (turning on link time optimizations (LTO) for 21.04).

To disable LTO, it is necessary to include the environment variable export DEB_BUILD_MAINT_OPTIONS=optimize=-lto in the rules file (https://wiki.ubuntu.com/ToolChain/LTO)