[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: sort dynamic linking overhead
From: |
Bruno Haible |
Subject: |
Re: sort dynamic linking overhead |
Date: |
Tue, 27 Feb 2024 12:15:50 +0100 |
Paul Eggert wrote:
> I installed the
> attached patch into coreutils. With it, 'sort -R' continues to use MD5
> but on GNUish platforms 'sort' links libcrypto dynamically only if -R is
> used (Bruno's suggestion). This doesn't significantly affect 'sort -R'
> performance, and reduces the startup overhead of plain 'sort'
The patch has no effect on openSUSE 15.5: DLOPEN_LIBCRYPTO is not defined
in config.h.
config.log shows a link error of the test program:
undefined reference to symbol 'dlopen@@GLIBC_2.2.5'
Both the test program and 'sort' need to link with -ldl.
This is generally true on the following platforms:
- glibc < 2.34,
- Android (with some compilers, not with Termux (*)).
(*) In the Android Termux environment, the compiler is configured to pass
the options '-ldl -lc', rather than just '-lc', to the linker. Thus,
we don't need to pass '-ldl' to the compiler. But the 'sort' program will
be linked with -ldl. In other Android environments, things may be different,
though.
The proposed attached patch fixes the problem: It defines a variable LIB_DL
that contains '-ldl' where needed or '' if not needed, and uses it with
the test program and with 'sort'.
You might think that this patch is no win, because it trades one link
dependency for another link dependency? But that's not what it does:
'ldd' shows that without the patch, 'sort' loads the libraries
linux-vdso.so.1
libcrypto.so.3
libpthread.so.0
libc.so.6
libz.so.1
libdl.so.2
/lib64/ld-linux-x86-64.so.2
and with the patch, 'sort' loads the libraries
linux-vdso.so.1
libdl.so.2
libpthread.so.0
libc.so.6
/lib64/ld-linux-x86-64.so.2
— that is, libdl.so.2 is getting loaded anyway.
0001-sort-Make-the-startup-time-optimization-effective-on.patch
Description: Text Data
Re: sort dynamic linking overhead, Pádraig Brady, 2024/02/26
Re: sort dynamic linking overhead,
Bruno Haible <=