Linker error of multiple definitions with static linking
Issue description
When building cryptsetup with static linking (e.g., for usage in initramfs) on Gentoo then the linker reports multiple definitions of the functions close_all_fds()
and mkdir_p()
:
(.text.close_all_fds+0x0): multiple definition of `close_all_fds'; /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../lib64/libblkid.a(libcommon_la-fileutils.o):(.text+0x180): first defined here
(.text.mkdir_p+0x0): multiple definition of `mkdir_p'; /usr/lib/gcc/x86_64-pc-linux-gnu/9.3.0/../../../../lib64/libblkid.a(libcommon_la-fileutils.o):(.text+0x320): first defined here
A Gentoo bug report with more details can be found here: https://bugs.gentoo.org/762008
The issue is that both, util-linux and systemd, define these two functions according to this bug report.