![编译 Systemd 独立二进制文件时出现问题](https://linux22.com/image/211015/%E7%BC%96%E8%AF%91%20Systemd%20%E7%8B%AC%E7%AB%8B%E4%BA%8C%E8%BF%9B%E5%88%B6%E6%96%87%E4%BB%B6%E6%97%B6%E5%87%BA%E7%8E%B0%E9%97%AE%E9%A2%98.png)
来源:systemd-stable-251:https://github.com/systemd/systemd-stable
wget https://github.com/systemd/systemd-stable/archive/refs/heads/v251-stable.zip
unzip v251-stable.zip
cd systemd-stable-251-stable/
使用命令:
./configure --auto-features=disabled \
--default-library=static \
-D standalone-binaries=true \
-D static-libsystemd=true \
-D static-libudev=true \
-D link-udev-shared=false \
-D link-systemctl-shared=false \
-D link-networkd-shared=false \
-D link-timesyncd-shared=false \
-D link-boot-shared=false && make
还尝试仅使用静态库并仅启用独立选项。
配置:
Features
enabled : IMA, SELinux, SMACK, blkid, gcrypt, gnutls, libidn2, openssl, p11kit, xkbcommon, xz, zlib, bzip2, backlight, binfmt, coredump, environment.d, efi, firstboot, hibernate, hostnamed, hwdb, initrd, kernel-install, localed, logind, machined, networkd, nss-myhostname, nss-mymachines, nss-resolve, nss-systemd, oomd, portabled, pstore, quotacheck, randomseed, resolve, rfkill, sysext, systemd-analyze, sysusers, timedated, timesyncd, tmpfiles, userdb, vconsole, xdg-autostart, idn, polkit, nscd, dbus, glib, tpm, SysV compat, utmp, ldconfig, adm group, wheel group, gshadow, standalone-binaries, static-libsystemd(true), static-libudev(true), cryptolib(gcrypt), DNS-over-TLS(openssl)
disabled : ACL, AUDIT, AppArmor, PAM, SECCOMP, elfutils, libbpf, libcryptsetup, libcryptsetup-plugins, libcurl, libfdisk, libfido2, libidn, libiptc, microhttpd, pcre2, pwquality, qrencode, tpm2, zstd, lz4, bpf-framework, gnu-efi, homed, importd, repart, sysupdate, legacy-pkla, kmod, man pages, html pages, man page indices, compat-mutable-uid-boundaries, debug hashmap, debug mmap cache, debug siphash, valgrind, trace logging, install tests, link-udev-shared, link-systemctl-shared, link-networkd-shared, link-timesyncd-shared, link-boot-shared, fexecve, coverage
用户定义的选项 auto_features : 禁用 default_library : 静态 link-boot-shared : false link-networkd-shared : false link-systemctl-shared : false link-timesyncd-shared : false link-udev-shared : falsestandalone-binaries : true static -libsystemd : true 静态 libudev : true
共享对象:
# file build/udevadm
build/udevadm: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=f6b7c1a3509d45ebcafda9b49f4dd2332e786738, with debug_info, not stripped
我期望看到 ELF 可执行文件而不是共享对象文件。
答案1
选项的文档standalone-binaries
说:
还构建支持的二进制文件的独立版本
这充其量似乎是模棱两可的。查看该meson_build
文件,我们发现:
if have_standalone_binaries
exe = executable(
'systemd-sysusers.standalone',
[...]
if have_standalone_binaries
exe = executable(
'systemd-tmpfiles.standalone',
[...]
这似乎表明该选项仅影响systemd-sysusers
和systemd-tmpfiles
,事实上,当构建完成时,我们看到:
$ ls build/*.standalone
build/systemd-sysusers.standalone build/systemd-tmpfiles.standalone
看起来事情正在按设计进行。